Skip to content

Commit 02f95ae

Browse files
committed
update load cyclegan and threading_data -> return no numpy array
1 parent 5fb7478 commit 02f95ae

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

tensorlayer/files.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,18 @@ def load_image_from_folder(path):
635635
im_test_A = load_image_from_folder(path+"/"+filename+"/testA")
636636
im_test_B = load_image_from_folder(path+"/"+filename+"/testB")
637637

638+
def if_2d_to_3d(images): # [h, w] --> [h, w, 3]
639+
for i in range(len(images)):
640+
if len(images[i].shape) == 2:
641+
images[i] = images[i][:, :, np.newaxis]
642+
images[i] = np.tile(images[i], (1, 1, 3))
643+
return images
644+
645+
im_train_A = if_2d_to_3d(im_train_A)
646+
im_train_B = if_2d_to_3d(im_train_B)
647+
im_test_A = if_2d_to_3d(im_test_A)
648+
im_test_B = if_2d_to_3d(im_test_B)
649+
638650
return im_train_A, im_train_B, im_test_A, im_test_B
639651

640652

tensorlayer/prepro.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ def apply_fn(results, i, data, kwargs):
129129
t.join()
130130

131131
if thread_count is None:
132-
return np.asarray(results)
132+
try:
133+
return np.asarray(results)
134+
except: # if dim don't match
135+
return results
133136
else:
134137
return np.concatenate(results)
135138

0 commit comments

Comments
 (0)