Эх сурвалжийг харах

Merge pull request #851 from will-jl944/develop_jf

batch_prediction of segmenter returns list of dict
FlyingQianMM 4 жил өмнө
parent
commit
406b67066a

+ 7 - 1
dygraph/paddlex/cv/models/segmenter.py

@@ -463,7 +463,13 @@ class BaseSegmenter(BaseModel):
         label_map = label_map.numpy().astype('uint8')
         score_map = outputs['score_map']
         score_map = score_map.numpy().astype('float32')
-        return {'label_map': label_map, 'score_map': score_map}
+        prediction = [{
+            'label_map': l,
+            'score_map': s
+        } for l, s in zip(label_map, score_map)]
+        if isinstance(img_file, (str, np.ndarray)):
+            prediction = prediction[0]
+        return prediction
 
     def _preprocess(self, images, transforms, model_type):
         arrange_transforms(

+ 4 - 1
dygraph/paddlex/cv/transforms/operators.py

@@ -867,13 +867,16 @@ class RandomCrop(Transform):
 
 class RandomExpand(Transform):
     """
-    Randomly expand the input by padding to the lower right side of the image(s) in input.
+    Randomly expand the input by padding according to random offsets.
 
     Args:
         upper_ratio(float, optional): The maximum ratio to which the original image is expanded. Defaults to 4..
         prob(float, optional): The probability of apply expanding. Defaults to .5.
         im_padding_value(List[float] or Tuple[float], optional): RGB filling value for the image. Defaults to (127.5, 127.5, 127.5).
         label_padding_value(int, optional): Filling value for the mask. Defaults to 255.
+
+    See Also:
+        paddlex.transforms.Padding
     """
 
     def __init__(self,