Commit 05494dd6 authored by Yuxin Wu's avatar Yuxin Wu

fix decoding

parent be7eae86
......@@ -35,6 +35,7 @@ class ImageDataFromZIPFile(RNGDataFlow):
self.archivefiles = random.sample(self.archivefiles, self.max)
for archive in self.archivefiles:
im_data = archive[0].read(archive[1])
im_data = np.asarray(bytearray(im_data), dtype='uint8')
yield [im_data]
......@@ -47,7 +48,7 @@ class ImageEncode(MapDataComponent):
class ImageDecode(MapDataComponent):
def __init__(self, ds, mode='.jpg', index=0):
def __init__(self, ds, index=0):
def func(im_data):
img = cv2.imdecode(im_data, cv2.IMREAD_COLOR)
return img
......
......@@ -83,9 +83,7 @@ def run_test(path, input):
# VGG16 requires channelwise mean substraction
VGG_MEAN = [103.939, 116.779, 123.68]
im[:, :, :, 0] -= VGG_MEAN[2]
im[:, :, :, 1] -= VGG_MEAN[1]
im[:, :, :, 2] -= VGG_MEAN[0]
im -= VGG_MEAN[::-1]
outputs = predict_func(im)[0]
prob = outputs[0]
......
......@@ -79,9 +79,7 @@ def run_test(path, input):
# VGG19 requires channelwise mean substraction
VGG_MEAN = [103.939, 116.779, 123.68]
im[:, :, :, 0] -= VGG_MEAN[2]
im[:, :, :, 1] -= VGG_MEAN[1]
im[:, :, :, 2] -= VGG_MEAN[0]
im -= VGG_MEAN[::-1]
outputs = predict_func(im)[0]
prob = outputs[0]
ret = prob.argsort()[-10:][::-1]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment