7
7
from PIL import Image
8
8
from tqdm import tqdm
9
9
from torchvision .transforms import functional as trans_fn
10
- from torchvision .transforms import InterpolationMode
11
10
import os
12
11
from pathlib import Path
13
12
import lmdb
@@ -28,7 +27,7 @@ def image_convert_bytes(img):
28
27
return buffer .getvalue ()
29
28
30
29
31
- def resize_multiple (img , sizes = (16 , 128 ), resample = InterpolationMode .BICUBIC , lmdb_save = False ):
30
+ def resize_multiple (img , sizes = (16 , 128 ), resample = Image .BICUBIC , lmdb_save = False ):
32
31
lr_img = resize_and_convert (img , sizes [0 ], resample )
33
32
hr_img = resize_and_convert (img , sizes [1 ], resample )
34
33
sr_img = resize_and_convert (lr_img , sizes [1 ], resample )
@@ -98,7 +97,7 @@ def all_threads_inactive(worker_threads):
98
97
return False
99
98
return True
100
99
101
- def prepare (img_path , out_path , n_worker , sizes = (16 , 128 ), resample = InterpolationMode .BICUBIC , lmdb_save = False ):
100
+ def prepare (img_path , out_path , n_worker , sizes = (16 , 128 ), resample = Image .BICUBIC , lmdb_save = False ):
102
101
resize_fn = partial (resize_worker , sizes = sizes ,
103
102
resample = resample , lmdb_save = lmdb_save )
104
103
files = [p for p in Path (
@@ -133,7 +132,6 @@ def prepare(img_path, out_path, n_worker, sizes=(16, 128), resample=Interpolatio
133
132
while not all_threads_inactive (worker_threads ):
134
133
print ("{}/{} images processed" .format (wctx .value (), total_count ))
135
134
time .sleep (0.1 )
136
- print ("{}/{} images processed" .format (wctx .value (), total_count ))
137
135
138
136
else :
139
137
total = 0
@@ -175,7 +173,7 @@ def prepare(img_path, out_path, n_worker, sizes=(16, 128), resample=Interpolatio
175
173
176
174
args = parser .parse_args ()
177
175
178
- resample_map = {'bilinear' : InterpolationMode .BILINEAR , 'bicubic' : InterpolationMode .BICUBIC }
176
+ resample_map = {'bilinear' : Image .BILINEAR , 'bicubic' : Image .BICUBIC }
179
177
resample = resample_map [args .resample ]
180
178
sizes = [int (s .strip ()) for s in args .size .split (',' )]
181
179
0 commit comments