From d4861dd71ffe42a16d79136aa70b6fe192d825fc Mon Sep 17 00:00:00 2001 From: Jiahao Yao Date: Thu, 24 May 2018 16:11:17 +0800 Subject: [PATCH] change the input to float --- mmdnn/conversion/examples/imagenet_test.py | 8 ++++---- mmdnn/visualization/index.html | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mmdnn/conversion/examples/imagenet_test.py b/mmdnn/conversion/examples/imagenet_test.py index b75b0ced..9badc921 100644 --- a/mmdnn/conversion/examples/imagenet_test.py +++ b/mmdnn/conversion/examples/imagenet_test.py @@ -229,7 +229,7 @@ def __init__(self): def ZeroCenter(path, size, BGRTranspose=False): img = Image.open(path) img = img.resize((size, size)) - x = np.array(img, dtype=np.float64) + x = np.array(img, dtype=np.float32) # Reference: 1) Keras image preprocess: https://github.com/keras-team/keras/blob/master/keras/applications/imagenet_utils.py # 2) tensorflow github issue: https://github.com/tensorflow/models/issues/517 @@ -250,7 +250,7 @@ def ZeroCenter(path, size, BGRTranspose=False): def Normalize(path, size=224, scale=0.0392156863 ,mean=[-0.485, -0.456, -0.406], std=[0.229, 0.224, 0.225], BGRTranspose = False): img = Image.open(path) img = img.resize((size, size)) - x = np.array(img, dtype=np.float64) + x = np.array(img, dtype=np.float32) x *= scale for i in range(0, 3): x[..., i] += mean[i] @@ -264,7 +264,7 @@ def Normalize(path, size=224, scale=0.0392156863 ,mean=[-0.485, -0.456, -0.406], def Standard(path, size, BGRTranspose=False): img = Image.open(path) img = img.resize((size, size)) - x = np.array(img, dtype=np.float64) + x = np.array(img, dtype=np.float32) x /= 255.0 x -= 0.5 x *= 2.0 @@ -277,7 +277,7 @@ def Standard(path, size, BGRTranspose=False): def Identity(path, size, BGRTranspose=False): img = Image.open(path) img = img.resize((size, size)) - x = np.array(img, dtype=np.float64) + x = np.array(img, dtype=np.float32) if BGRTranspose == True: x = x[..., ::-1] return x diff --git a/mmdnn/visualization/index.html b/mmdnn/visualization/index.html index af7ef0da..ac607ceb 100644 --- a/mmdnn/visualization/index.html +++ b/mmdnn/visualization/index.html @@ -48,7 +48,7 @@

Tips

+ size="20" required>