zhangyubo0722 пре 1 година
родитељ
комит
4753c10baf

+ 2 - 2
paddlex/inference/models/formula_recognition.py

@@ -16,7 +16,7 @@ import numpy as np
 
 from ...modules.formula_recognition.model_list import MODELS
 from ..components import *
-from ..results import TextRecResult
+from ..results import FormulaRecResult
 from .base import BasicPredictor
 
 
@@ -52,4 +52,4 @@ class LaTeXOCRPredictor(BasicPredictor):
 
     def _pack_res(self, single):
         keys = ["input_path", "rec_text"]
-        return TextRecResult({key: single[key] for key in keys})
+        return FormulaRecResult({key: single[key] for key in keys})

+ 3 - 27
paddlex/inference/results/formula_rec.py

@@ -17,6 +17,7 @@ import numpy as np
 from PIL import Image, ImageDraw
 
 from .base import CVResult
+from ...utils import logging
 
 
 class FormulaRecResult(CVResult):
@@ -29,30 +30,5 @@ class FormulaRecResult(CVResult):
         self,
     ):
         """draw formula result"""
-        boxes = self["dt_polys"]
-        formula = self["rec_formula"]
-        image = self._img_reader.read(self["input_path"])
-        if self._HARD_FLAG:
-            image_np = np.array(image)
-            image = Image.fromarray(image_np[:, :, ::-1])
-        img = image.copy()
-        random.seed(0)
-        draw_img = ImageDraw.Draw(img)
-        if formula is None or len(formula) != len(boxes):
-            formula = [None] * len(boxes)
-        for idx, (box, txt) in enumerate(zip(boxes, formula)):
-            try:
-                color = (
-                    random.randint(0, 255),
-                    random.randint(0, 255),
-                    random.randint(0, 255),
-                )
-                box = np.array(box)
-                pts = [(x, y) for x, y in box.tolist()]
-                draw_img.polygon(pts, outline=color, width=8)
-                draw_img.polygon(box, fill=color)
-            except:
-                continue
-
-        img = Image.blend(image, img, 0.5)
-        return img
+        logging.warning("FormulaRecResult don't support save to img!")
+        return None