We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3744412 commit 58fea2aCopy full SHA for 58fea2a
demo.py
@@ -19,13 +19,18 @@
19
def load_image(image_path):
20
image = np.array(Image.open(image_path))
21
h, w = image.shape[:2]
22
- if h != 32:
+ if h != 32 and h < w:
23
new_w = int(w * 32 / h)
24
image = cv2.resize(image, (new_w, 32))
25
+ if w != 32 and w < h:
26
+ new_h = int(h * 32 / w)
27
+ image = cv2.resize(image, (32, new_h))
28
29
image = Image.fromarray(image).convert('L')
30
# cv2.imwrite(image_path, np.array(image))
- image = np.array(image).T # [W,H]
31
+ image = np.array(image)
32
+ if h < w:
33
+ image = np.array(image).T # [W,H]
34
image = image.astype(np.float32) / 255.
35
image -= 0.5
36
image /= 0.5
0 commit comments