Skip to content

Commit 58fea2a

Browse files
committed
增加垂直方向预测
1 parent 3744412 commit 58fea2a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

demo.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,18 @@
1919
def load_image(image_path):
2020
image = np.array(Image.open(image_path))
2121
h, w = image.shape[:2]
22-
if h != 32:
22+
if h != 32 and h < w:
2323
new_w = int(w * 32 / h)
2424
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))
2528

2629
image = Image.fromarray(image).convert('L')
2730
# cv2.imwrite(image_path, np.array(image))
28-
image = np.array(image).T # [W,H]
31+
image = np.array(image)
32+
if h < w:
33+
image = np.array(image).T # [W,H]
2934
image = image.astype(np.float32) / 255.
3035
image -= 0.5
3136
image /= 0.5

0 commit comments

Comments
 (0)