Skip to content

Commit

Permalink
change the input to float
Browse files Browse the repository at this point in the history
  • Loading branch information
JiahaoYao committed May 24, 2018
1 parent 15e821b commit d4861dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions mmdnn/conversion/examples/imagenet_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mmdnn/visualization/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h4 >Tips</h4>
<div>
<input type="text" id="uname" name="name"
placeholder="Search for Layer Name"
size="30" required>
size="20" required>
</div>

</li>
Expand Down

0 comments on commit d4861dd

Please sign in to comment.