F-G Fernandez commited on
Commit
102be41
1 Parent(s): 0eaa0ad

fix: Fixed PIL resizing

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -31,8 +31,8 @@ def preprocess_image(pil_img: Image.Image) -> np.ndarray:
31
  the resized and normalized image of shape (1, C, H, W)
32
  """
33
 
34
- # Resizing
35
- img = pil_img.resize(cfg["input_shape"][-2:], Image.BILINEAR)
36
  # (H, W, C) --> (C, H, W)
37
  img = np.asarray(img).transpose((2, 0, 1)).astype(np.float32) / 255
38
  # Normalization
31
  the resized and normalized image of shape (1, C, H, W)
32
  """
33
 
34
+ # Resizing (PIL takes (W, H) order for resizing)
35
+ img = pil_img.resize(cfg["input_shape"][-2:][::-1], Image.BILINEAR)
36
  # (H, W, C) --> (C, H, W)
37
  img = np.asarray(img).transpose((2, 0, 1)).astype(np.float32) / 255
38
  # Normalization