Skip to content

Commit 5a02f11

Browse files
authored
Merge pull request #317 from woctezuma/fix-rgb
Fix 3-channel images incorrectly read as if 1-channel
2 parents 85edbcd + 500bfbf commit 5a02f11

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import random
88
import pprint
99
import scipy.misc
10+
import cv2
1011
import numpy as np
1112
from time import gmtime, strftime
1213
from six.moves import xrange
@@ -36,7 +37,11 @@ def imread(path, grayscale = False):
3637
if (grayscale):
3738
return scipy.misc.imread(path, flatten = True).astype(np.float)
3839
else:
39-
return scipy.misc.imread(path).astype(np.float)
40+
# Reference: https://github.com/carpedm20/DCGAN-tensorflow/issues/162#issuecomment-315519747
41+
img_bgr = cv2.imread(path)
42+
# Reference: https://stackoverflow.com/a/15074748/
43+
img_rgb = img_bgr[..., ::-1]
44+
return img_rgb.astype(np.float)
4045

4146
def merge_images(images, size):
4247
return inverse_transform(images)

0 commit comments

Comments
 (0)