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

fix channal order from RGB to BGR

gaotingquan 1 жил өмнө
parent
commit
e11e7f63c7

+ 1 - 1
paddlex/inference/pipelines/layout_parsing/layout_parsing.py

@@ -109,7 +109,7 @@ class LayoutParsingPipeline(_TableRecPipeline):
         else:
             self.uvdoc_predictor = None
 
-        self.img_reader = ReadImage(format="RGB")
+        self.img_reader = ReadImage(format="BGR")
         self.cropper = CropByBoxes()
 
     def set_predictor(

+ 2 - 1
paddlex/inference/pipelines/ppchatocrv3/ppchatocrv3.py

@@ -133,7 +133,7 @@ class PPChatOCRPipeline(_TableRecPipeline):
         else:
             self.doc_image_unwarp_predictor = None
 
-        self.img_reader = ReadImage(format="RGB")
+        self.img_reader = ReadImage(format="BGR")
         self.llm_api = create_llm_api(
             llm_name,
             llm_params,
@@ -248,6 +248,7 @@ class PPChatOCRPipeline(_TableRecPipeline):
                 img_info_list, self.doc_image_unwarp_predictor
             )
         img_list = [img_info["img"] for img_info in img_info_list]
+
         for idx, (img_info, layout_pred) in enumerate(
             zip(img_info_list, self.layout_predictor(img_list))
         ):

+ 0 - 6
paddlex/inference/results/chat_ocr.py

@@ -66,12 +66,10 @@ class VisualResult(BaseResult):
         oricls_save_path = f"{save_path}_oricls.jpg"
         oricls_result = self["oricls_result"]
         if oricls_result:
-            oricls_result._HARD_FLAG = True
             oricls_result.save_to_img(oricls_save_path)
         uvdoc_save_path = f"{save_path}_uvdoc.jpg"
         unwarp_result = self["unwarp_result"]
         if unwarp_result:
-            # unwarp_result._HARD_FLAG = True
             unwarp_result.save_to_img(uvdoc_save_path)
         curve_save_path = f"{save_path}_curve"
         curve_results = self["curve_result"]
@@ -79,21 +77,17 @@ class VisualResult(BaseResult):
         if isinstance(curve_results, dict):
             curve_results = [curve_results]
         for idx, curve_result in enumerate(curve_results):
-            curve_result._HARD_FLAG = True if not unwarp_result else False
             curve_result.save_to_img(f"{curve_save_path}_{idx}.jpg")
         layout_save_path = f"{save_path}_layout.jpg"
         layout_result = self["layout_result"]
         if layout_result:
-            layout_result._HARD_FLAG = True if not unwarp_result else False
             layout_result.save_to_img(layout_save_path)
         ocr_save_path = f"{save_path}_ocr.jpg"
         table_save_path = f"{save_path}_table"
         ocr_result = self["ocr_result"]
         if ocr_result:
-            ocr_result._HARD_FLAG = True if not unwarp_result else False
             ocr_result.save_to_img(ocr_save_path)
         for idx, table_result in enumerate(self["table_result"]):
-            table_result._HARD_FLAG = True if not unwarp_result else False
             table_result.save_to_img(f"{table_save_path}_{idx}.jpg")
 
 

+ 0 - 4
paddlex/inference/results/clas.py

@@ -24,7 +24,6 @@ from .base import CVResult
 
 
 class TopkResult(CVResult):
-    _HARD_FLAG = False
 
     def _to_img(self):
         """Draw label on image"""
@@ -32,9 +31,6 @@ class TopkResult(CVResult):
         label_str = f"{labels[0]} {self['scores'][0]:.2f}"
 
         image = self._img_reader.read(self["input_path"])
-        if self._HARD_FLAG:
-            image_np = np.array(image)
-            image = Image.fromarray(image_np[:, :, ::-1])
         image_size = image.size
         draw = ImageDraw.Draw(image)
         min_font_size = int(image_size[0] * 0.02)

+ 0 - 5
paddlex/inference/results/det.py

@@ -78,14 +78,9 @@ def draw_box(img, boxes):
 class DetResult(CVResult):
     """Save Result Transform"""
 
-    _HARD_FLAG = False
-
     def _to_img(self):
         """apply"""
         boxes = self["boxes"]
         image = self._img_reader.read(self["input_path"])
-        if self._HARD_FLAG:
-            image_np = np.array(image)
-            image = Image.fromarray(image_np[:, :, ::-1])
         image = draw_box(image, boxes)
         return image

+ 0 - 4
paddlex/inference/results/formula_rec.py

@@ -71,7 +71,6 @@ class FormulaRecResult(CVResult):
 
 
 class FormulaResult(CVResult):
-    _HARD_FLAG = False
 
     def _to_str(self, *args, **kwargs):
         return super()._to_str(*args, **kwargs).replace("\\\\", "\\")
@@ -84,9 +83,6 @@ class FormulaResult(CVResult):
         boxes = self["dt_polys"]
         formulas = 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])
         h, w = image.height, image.width
         img_left = image.copy()
         img_right = np.ones((h, w, 3), dtype=np.uint8) * 255

+ 0 - 4
paddlex/inference/results/ocr.py

@@ -24,7 +24,6 @@ from .base import CVResult
 
 
 class OCRResult(CVResult):
-    _HARD_FLAG = False
 
     def get_minarea_rect(self, points):
         bounding_box = cv2.minAreaRect(points)
@@ -61,9 +60,6 @@ class OCRResult(CVResult):
         txts = self["rec_text"]
         scores = self["rec_score"]
         image = self._img_reader.read(self["input_path"])
-        if self._HARD_FLAG:
-            image_np = np.array(image)
-            image = Image.fromarray(image_np[:, :, ::-1])
         h, w = image.height, image.width
         img_left = image.copy()
         img_right = np.ones((h, w, 3), dtype=np.uint8) * 255

+ 0 - 5
paddlex/inference/results/table_rec.py

@@ -25,16 +25,11 @@ from .base import BaseResult, CVResult
 class TableRecResult(CVResult):
     """SaveTableResults"""
 
-    _HARD_FLAG = False
-
     def __init__(self, data):
         super().__init__(data)
 
     def _to_img(self):
         image = self._img_reader.read(self["input_path"])
-        if self._HARD_FLAG:
-            image_np = np.array(image)
-            image = Image.fromarray(image_np[:, :, ::-1])
         bbox_res = self["bbox"]
         if len(bbox_res) > 0 and len(bbox_res[0]) == 4:
             vis_img = self.draw_rectangle(image, bbox_res)