Sfoglia il codice sorgente

expand dimension only for a image with shape WxHx1 after resizing but not for label

FlyingQianMM 4 anni fa
parent
commit
23206d5708
1 ha cambiato i file con 2 aggiunte e 1 eliminazioni
  1. 2 1
      paddlex/cv/transforms/ops.py

+ 2 - 1
paddlex/cv/transforms/ops.py

@@ -43,9 +43,10 @@ def resize_long(im, long_size=224, interpolation=cv2.INTER_LINEAR):
     resized_width = int(round(im.shape[1] * scale))
     resized_height = int(round(im.shape[0] * scale))
 
+    im_dims = im.ndim
     im = cv2.resize(
         im, (resized_width, resized_height), interpolation=interpolation)
-    if im.ndim < 3:
+    if im_dims >= 3 and im.ndim < 3:
         im = np.expand_dims(im, axis=-1)
     return im