FIX web_demo upload was not processing grayscale correctly
authorSergey Karayev <sergeykarayev@gmail.com>
Tue, 26 Aug 2014 07:44:56 +0000 (00:44 -0700)
committerSergey Karayev <sergeykarayev@gmail.com>
Tue, 26 Aug 2014 07:45:19 +0000 (00:45 -0700)
examples/web_demo/exifutil.py

index 8c07aa8..01918b2 100644 (file)
@@ -23,7 +23,13 @@ def open_oriented_im(im_path):
         if exif is not None and 274 in exif:
             orientation = exif[274]
             im = apply_orientation(im, orientation)
-    return np.asarray(im).astype(np.float32) / 255.
+    img = np.asarray(im).astype(np.float32) / 255.
+    if img.ndim == 2:
+        img = img[:, :, np.newaxis]
+        img = np.tile(img, (1, 1, 3))
+    elif img.shape[2] == 4:
+        img = img[:, :, :3]
+    return img
 
 
 def apply_orientation(im, orientation):