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

support get_pipeline_config for new_pipeline

cuicheng01 10 сар өмнө
parent
commit
dbd1c1fd5d

+ 1 - 0
paddlex/inference/pipelines_new/ocr/pipeline.py

@@ -267,6 +267,7 @@ class OCRPipeline(BasePipeline):
             dt_polys = self._sort_boxes(dt_polys)
 
             single_img_res = {
+                "input_path": input,
                 "doc_preprocessor_image": doc_preprocessor_image,
                 "doc_preprocessor_res": doc_preprocessor_res,
                 "dt_polys": dt_polys,

+ 8 - 0
paddlex/inference/pipelines_new/ocr/result.py

@@ -40,8 +40,11 @@ class OCRResult(BaseCVResult):
             *args: Additional positional arguments.
             **kwargs: Additional keyword arguments.
         """
+
         input_params = self["input_params"]
         img_id = self["img_id"]
+
+        # TODO : Support determining the output name based on the input name.
         if input_params["use_doc_preprocessor"]:
             save_img_path = (
                 Path(save_path) / f"doc_preprocessor_result_img_{img_id}.jpg"
@@ -73,6 +76,11 @@ class OCRResult(BaseCVResult):
             **kwargs: Additional keyword arguments to pass to the underlying writer.
         """
         img_id = self["img_id"]
+
+        # TODO : Support determining the output name based on the input name.
+        os.makedirs(save_path, exist_ok=True)
+        save_path = os.path.join(save_path, 'res.json')
+
         base_name, ext = os.path.splitext(save_path)
         save_path = f"{base_name}_{img_id}{ext}"
 

+ 3 - 1
paddlex/inference/utils/get_pipeline_path.py

@@ -19,7 +19,9 @@ from pathlib import Path
 def get_pipeline_path(pipeline_name):
     # XXX: using dict class to handle all pipeline configs
     pipeline_path = (
-        Path(__file__).parent.parent.parent / "pipelines" / f"{pipeline_name}.yaml"
+        Path(__file__).parent.parent.parent
+        / "configs/pipelines"
+        / f"{pipeline_name}.yaml"
     ).resolve()
     if not Path(pipeline_path).exists():
         return None