-
Notifications
You must be signed in to change notification settings - Fork 33
/
get_data.py
36 lines (29 loc) · 1.01 KB
/
get_data.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import sys
import movies_dataset as movies
download = '-download' in sys.argv
resize = '-resize' in sys.argv
min_year = 0
for arg in sys.argv:
if arg.startswith('-min_year='):
min_year = int(arg.split('=')[1])
ratios = [30, 40, 50, 60, 70]
images_path = 'data/images/'
base_images_path = images_path + '100/'
# create images directory if not exists
if not os.path.isdir(base_images_path):
os.makedirs(base_images_path)
# download posters
if download:
movies.download_posters(min_year=min_year)
# resize images (so we can build test models more quickly)
if resize:
for ratio in ratios:
directory_path = images_path + str(ratio)
# directory = os.path.join(os.getcwd(), directory_path)
if not os.path.isdir(directory_path):
os.makedirs(directory_path)
command = 'mogrify -path "' + directory_path + '/" -resize ' \
+ str(ratio) + '% ' + base_images_path + '*.jpg -verbose'
print(command)
os.system(command)