Procházet zdrojové kódy

[Fix] Fix predictor and imgdecoder

Bobholamovic před 2 roky
rodič
revize
bc56d25f17
2 změnil soubory, kde provedl 34 přidání a 10 odebrání
  1. 1 1
      paddlers/deploy/predictor.py
  2. 33 9
      paddlers/transforms/operators.py

+ 1 - 1
paddlers/deploy/predictor.py

@@ -275,7 +275,7 @@ class Predictor(object):
         self.timer.img_num = len(images)
         self.timer.img_num = len(images)
         self.timer.info(average=True)
         self.timer.info(average=True)
 
 
-        if isinstance(img_file, (str, np.ndarray)):
+        if isinstance(img_file, (str, np.ndarray, tuple)):
             results = results[0]
             results = results[0]
 
 
         return results
         return results

+ 33 - 9
paddlers/transforms/operators.py

@@ -35,13 +35,33 @@ from .functions import normalize, horizontal_flip, permute, vertical_flip, cente
     to_intensity, to_uint8, img_flip, img_simple_rotate
     to_intensity, to_uint8, img_flip, img_simple_rotate
 
 
 __all__ = [
 __all__ = [
-    "Compose", "ImgDecoder", "Resize", "RandomResize", "ResizeByShort",
-    "RandomResizeByShort", "ResizeByLong", "RandomHorizontalFlip",
-    "RandomVerticalFlip", "Normalize", "CenterCrop", "RandomCrop",
-    "RandomScaleAspect", "RandomExpand", "Padding", "MixupImage",
-    "RandomDistort", "RandomBlur", "RandomSwap", "Defogging", "DimReducing",
-    "BandSelecting", "ArrangeSegmenter", "ArrangeChangeDetector",
-    "ArrangeClassifier", "ArrangeDetector", "RandomFlipOrRotation",
+    "Compose",
+    "ImgDecoder",
+    "Resize",
+    "RandomResize",
+    "ResizeByShort",
+    "RandomResizeByShort",
+    "ResizeByLong",
+    "RandomHorizontalFlip",
+    "RandomVerticalFlip",
+    "Normalize",
+    "CenterCrop",
+    "RandomCrop",
+    "RandomScaleAspect",
+    "RandomExpand",
+    "Padding",
+    "MixupImage",
+    "RandomDistort",
+    "RandomBlur",
+    "RandomSwap",
+    "Defogging",
+    "DimReducing",
+    "BandSelecting",
+    "ArrangeSegmenter",
+    "ArrangeChangeDetector",
+    "ArrangeClassifier",
+    "ArrangeDetector",
+    "RandomFlipOrRotation",
 ]
 ]
 
 
 interp_dict = {
 interp_dict = {
@@ -179,13 +199,17 @@ class ImgDecoder(Transform):
     def apply(self, sample):
     def apply(self, sample):
         """
         """
         Args:
         Args:
-            sample (dict): Input sample, containing 'image' at least.
+            sample (dict): Input sample.
         Returns:
         Returns:
             dict: Decoded sample.
             dict: Decoded sample.
         """
         """
         if 'image' in sample:
         if 'image' in sample:
             sample['image'] = self.apply_im(sample['image'])
             sample['image'] = self.apply_im(sample['image'])
-        else:  # image_tx
+        if 'image2' in sample:
+            sample['image2'] = self.apply_im(sample['image2'])
+        if 'image_t1' in sample and not 'image' in sample:
+            if not ('image_t2' in sample and 'image2' not in sample):
+                raise ValueError
             sample['image'] = self.apply_im(sample['image_t1'])
             sample['image'] = self.apply_im(sample['image_t1'])
             sample['image2'] = self.apply_im(sample['image_t2'])
             sample['image2'] = self.apply_im(sample['image_t2'])
         if 'mask' in sample:
         if 'mask' in sample: