Kaynağa Gözat

feat(增强调试选项): 在BasePreprocessor和BaseLayoutDetector类中添加subdir参数,优化输出目录配置,提升调试过程的灵活性和可维护性。

zhch158_admin 5 gün önce
ebeveyn
işleme
dec64903d5

+ 4 - 1
ocr_tools/universal_doc_parser/models/adapters/base.py

@@ -88,6 +88,7 @@ class BasePreprocessor(BaseAdapter):
                 processing_params=params,
                 image_format=opts.get("image_format") or "png",
                 save_compare=opts.get("save_compare", True),
+                subdir=opts.get("subdir", "watermark_removal"),
             )
         except Exception as e:
             logger.warning(f"Watermark debug save failed: {e}")
@@ -441,6 +442,8 @@ class BaseLayoutDetector(BaseAdapter):
             output_dir = self.config.get('output_dir')
         if output_dir is None:
             output_dir = self._layout_debug_options().get('output_dir')
+        if output_dir is not None:
+            output_dir = str(output_dir)
 
         page_name = getattr(self, 'page_name', None)
         if page_name is None:
@@ -471,7 +474,7 @@ class BaseLayoutDetector(BaseAdapter):
             page_name,
             suffix=suffix,
             subdir=opts.get('subdir', 'layout_detection'),
-            image_format=opts.get('image_format', 'jpg'),
+            image_format=opts.get('image_format', 'png'),
             save_json=bool(opts.get('save_json', True)),
         )