zhangyubo0722 10 mesi fa
parent
commit
5f150a8186

+ 7 - 3
paddlex/inference/common/result/mixin.py

@@ -63,7 +63,7 @@ class StrMixin:
         Returns:
             Dict[str, str]: The string representation of the result.
         """
-        return {"res": str(self)}
+        return {"res": self}
 
     def print(self) -> None:
         """Print the string representation of the result."""
@@ -177,9 +177,13 @@ class JsonMixin:
             ensure_ascii (bool): If True, ensure all characters are ASCII. Default is False.
         """
         if json_format:
-            str_ = json.dumps(self.json, indent=indent, ensure_ascii=ensure_ascii)
+            str_ = json.dumps(
+                self.__class__._to_str(self.json["res"]),
+                indent=indent,
+                ensure_ascii=ensure_ascii,
+            )
         else:
-            str_ = str(self.json)
+            str_ = str(self.__class__._to_str(self.json["res"]))
         logging.info(str_)
 
 

+ 0 - 1
paddlex/inference/models_new/anomaly_detection/result.py

@@ -60,7 +60,6 @@ class UadResult(BaseCVResult):
 
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         data["pred"] = "..."
         return StrMixin._to_str(data, *args, **kwargs)
 

+ 0 - 1
paddlex/inference/models_new/formula_recognition/result.py

@@ -35,7 +35,6 @@ from ....utils.file_interface import custom_open
 class FormulaRecResult(BaseCVResult):
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         _str = StrMixin._to_str(data, *args, **kwargs)["res"].replace("\\\\", "\\")
         return {"res": _str}
 

+ 0 - 1
paddlex/inference/models_new/image_classification/result.py

@@ -26,7 +26,6 @@ from ...common.result import BaseCVResult, StrMixin, JsonMixin
 class TopkResult(BaseCVResult):
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         return StrMixin._to_str(data, *args, **kwargs)
 
     def _to_json(self, *args, **kwargs):

+ 0 - 1
paddlex/inference/models_new/image_feature/result.py

@@ -24,7 +24,6 @@ class IdentityResult(BaseResult):
 
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         return StrMixin._to_str(data, *args, **kwargs)
 
     def _to_json(self, *args, **kwargs):

+ 0 - 1
paddlex/inference/models_new/image_multilabel_classification/result.py

@@ -25,7 +25,6 @@ from ...common.result import BaseCVResult, StrMixin, JsonMixin
 class MLClassResult(BaseCVResult):
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         return StrMixin._to_str(data, *args, **kwargs)
 
     def _to_json(self, *args, **kwargs):

+ 0 - 1
paddlex/inference/models_new/image_unwarping/result.py

@@ -35,7 +35,6 @@ class DocTrResult(BaseCVResult):
 
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         data["doctr_img"] = "..."
         return StrMixin._to_str(data, *args, **kwargs)
 

+ 0 - 1
paddlex/inference/models_new/instance_segmentation/result.py

@@ -151,7 +151,6 @@ class InstanceSegResult(BaseCVResult):
 
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         data["masks"] = "..."
         return StrMixin._to_str(data, *args, **kwargs)
 

+ 0 - 1
paddlex/inference/models_new/keypoint_detection/result.py

@@ -179,7 +179,6 @@ class KptResult(BaseCVResult):
 
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         return StrMixin._to_str(data, *args, **kwargs)
 
     def _to_json(self, *args, **kwargs):

+ 0 - 1
paddlex/inference/models_new/object_detection/result.py

@@ -104,7 +104,6 @@ class DetResult(BaseCVResult):
 
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         return StrMixin._to_str(data, *args, **kwargs)
 
     def _to_json(self, *args, **kwargs):

+ 0 - 1
paddlex/inference/models_new/open_vocabulary_segmentation/results/sam_result.py

@@ -138,7 +138,6 @@ class SAMSegResult(BaseCVResult):
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
         data["masks"] = "..."
-        data.pop("input_img")
         return StrMixin._to_str(data, *args, **kwargs)
 
     def _to_json(self, *args, **kwargs):

+ 0 - 1
paddlex/inference/models_new/semantic_segmentation/result.py

@@ -62,7 +62,6 @@ class SegResult(BaseCVResult):
 
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         data["pred"] = "..."
         return StrMixin._to_str(data, *args, **kwargs)
 

+ 0 - 1
paddlex/inference/models_new/table_structure_recognition/result.py

@@ -55,7 +55,6 @@ class TableRecResult(BaseCVResult):
 
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         return StrMixin._to_str(data, *args, **kwargs)
 
     def _to_json(self, *args, **kwargs):

+ 0 - 1
paddlex/inference/models_new/text_detection/result.py

@@ -35,7 +35,6 @@ class TextDetResult(BaseCVResult):
 
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         return StrMixin._to_str(data, *args, **kwargs)
 
     def _to_json(self, *args, **kwargs):

+ 0 - 1
paddlex/inference/models_new/text_recognition/result.py

@@ -24,7 +24,6 @@ class TextRecResult(BaseCVResult):
 
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         return StrMixin._to_str(data, *args, **kwargs)
 
     def _to_json(self, *args, **kwargs):

+ 0 - 1
paddlex/inference/pipelines_new/attribute_recognition/result.py

@@ -77,7 +77,6 @@ class AttributeRecResult(BaseCVResult):
 
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         return StrMixin._to_str(data, *args, **kwargs)
 
     def _to_json(self, *args, **kwargs):

+ 0 - 1
paddlex/inference/pipelines_new/face_recognition/result.py

@@ -34,7 +34,6 @@ class FaceRecResult(BaseCVResult):
 
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         return StrMixin._to_str(data, *args, **kwargs)
 
     def _to_json(self, *args, **kwargs):

+ 0 - 1
paddlex/inference/pipelines_new/pp_shitu_v2/result.py

@@ -113,7 +113,6 @@ class ShiTuResult(BaseCVResult):
 
     def _to_str(self, *args, **kwargs):
         data = copy.deepcopy(self)
-        data.pop("input_img")
         return StrMixin._to_str(data, *args, **kwargs)
 
     def _to_json(self, *args, **kwargs):