Skip to content

Commit

Permalink
Fix issue with a few 3-channel images incorrectly read as if they wer…
Browse files Browse the repository at this point in the history
…e 1-channel images
  • Loading branch information
woctezuma committed Feb 15, 2019
1 parent 85edbcd commit 5958538
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import random
import pprint
import scipy.misc
import cv2
import numpy as np
from time import gmtime, strftime
from six.moves import xrange
Expand Down Expand Up @@ -36,7 +37,11 @@ def imread(path, grayscale = False):
if (grayscale):
return scipy.misc.imread(path, flatten = True).astype(np.float)
else:
return scipy.misc.imread(path).astype(np.float)
# Reference: https://github.com/carpedm20/DCGAN-tensorflow/issues/162#issuecomment-315519747
img_bgr = cv2.imread(path)
# Reference: https://stackoverflow.com/a/15074748/
img_rgb = img[..., ::-1]
return img_rgb.astype(np.float)

def merge_images(images, size):
return inverse_transform(images)
Expand Down

0 comments on commit 5958538

Please sign in to comment.