Kaynağa Gözat

更新默认配置,简化字体大小设置,调整布局高度,新增图片方向检测和置信度字段,优化OCR工具描述及旋转处理配置

zhch158_admin 2 ay önce
ebeveyn
işleme
904cfe7449
1 değiştirilmiş dosya ile 66 ekleme ve 15 silme
  1. 66 15
      ocr_validator_utils.py

+ 66 - 15
ocr_validator_utils.py

@@ -30,41 +30,92 @@ def load_config(config_path: str = "config.yaml") -> Dict:
 
 
 def get_default_config() -> Dict:
-    """获取默认配置"""
+    """获取默认配置 - 与config.yaml保持一致"""
     return {
         'styles': {
-            'font_sizes': {'small': 10, 'medium': 12, 'large': 14, 'extra_large': 16},
+            'font_size': 8,  # 修改:从字典改为单个数值
             'colors': {
-                'primary': '#0288d1', 'secondary': '#ff9800', 'success': '#4caf50',
-                'error': '#f44336', 'warning': '#ff9800', 'background': '#fafafa', 'text': '#333333'
+                'primary': '#0288d1', 
+                'secondary': '#ff9800', 
+                'success': '#4caf50',
+                'error': '#f44336', 
+                'warning': '#ff9800', 
+                'background': '#fafafa', 
+                'text': '#333333'
             },
-            'layout': {'default_zoom': 1.0, 'default_height': 600, 'sidebar_width': 0.3, 'content_width': 0.7}
+            'layout': {
+                'default_zoom': 1.0, 
+                'default_height': 800,  # 修改:从600改为800
+                'sidebar_width': 1,     # 修改:从0.3改为1
+                'content_width': 0.7
+            }
         },
         'ui': {
-            'page_title': 'OCR可视化校验工具', 'page_icon': '🔍', 'layout': 'wide',
-            'sidebar_state': 'expanded', 'default_font_size': 'medium', 'default_layout': '标准布局'
+            'page_title': 'OCR可视化校验工具', 
+            'page_icon': '🔍', 
+            'layout': 'wide',
+            'sidebar_state': 'expanded'
+            # 移除:default_font_size和default_layout
         },
         'paths': {
-            'ocr_out_dir': './sample_data', 'src_img_dir': './sample_data',
+            # 修改:使用config.yaml中的实际路径
+            'ocr_out_dir': '/Users/zhch158/workspace/data/至远彩色印刷工业有限公司/data_DotsOCR_Results',
+            'src_img_dir': '/Users/zhch158/workspace/data/至远彩色印刷工业有限公司/data_PPStructureV3_Results/2023年度报告母公司',
             'supported_image_formats': ['.png', '.jpg', '.jpeg']
         },
         'ocr': {
-            'min_text_length': 2, 'default_confidence': 1.0, 'exclude_texts': ['Picture', ''],
+            'min_text_length': 2,
+            'default_confidence': 1.0,
+            'exclude_texts': ['Picture', ''],
+            
+            # 新增:图片方向检测配置
+            'orientation_detection': {
+                'enabled': True,
+                'confidence_threshold': 0.3,
+                'methods': ['opencv_analysis'],
+                'cache_results': True
+            },
+            
             'tools': {
                 'dots_ocr': {
-                    'name': 'Dots OCR', 'json_structure': 'array',
-                    'text_field': 'text', 'bbox_field': 'bbox', 'category_field': 'category'
+                    'name': 'Dots OCR',
+                    'description': '专业VLM OCR',  # 新增描述
+                    'json_structure': 'array',
+                    'text_field': 'text', 
+                    'bbox_field': 'bbox', 
+                    'category_field': 'category',
+                    'confidence_field': 'confidence',  # 新增置信度字段
+                    # 新增:旋转处理配置
+                    'rotation': {
+                        'coordinates_are_pre_rotated': False
+                    }
                 },
                 'ppstructv3': {
-                    'name': 'PPStructV3', 'json_structure': 'object', 'parsing_results_field': 'parsing_res_list',
-                    'text_field': 'block_content', 'bbox_field': 'block_bbox', 'category_field': 'block_label'
+                    'name': 'PPStructV3',
+                    'description': 'PaddleOCR PP-StructureV3',  # 新增描述
+                    'json_structure': 'object',
+                    'parsing_results_field': 'parsing_res_list',
+                    'text_field': 'block_content', 
+                    'bbox_field': 'block_bbox', 
+                    'category_field': 'block_label',
+                    'confidence_field': 'confidence',  # 新增置信度字段
+                    # 新增:旋转处理配置
+                    'rotation': {
+                        'coordinates_are_pre_rotated': True
+                    }
                 }
             },
             'auto_detection': {
                 'enabled': True,
                 'rules': [
-                    {'field_exists': 'parsing_res_list', 'tool_type': 'ppstructv3'},
-                    {'json_is_array': True, 'tool_type': 'dots_ocr'}
+                    {
+                        'field_exists': 'parsing_res_list', 
+                        'tool_type': 'ppstructv3'
+                    },
+                    {
+                        'json_is_array': True, 
+                        'tool_type': 'dots_ocr'
+                    }
                 ]
             }
         }