快捷函数 - 处理问题区域 Args: elements: 现有元素列表 bad_regions: 问题区域列表(来自MetricEvaluator) image_path: 原始图片路径 config: 可选配置参数 Returns: 更新后的元素列表(包含新增的fallback元素) 使用示例: # 基本用法 elements = refine_bad_regions(elements, bad_re
(elements: List[ElementInfo],
bad_regions: List[Dict],
image_path: str,
config: Dict = None)
| 437 | # ======================== 快捷函数 ======================== |
| 438 | |
| 439 | def refine_bad_regions(elements: List[ElementInfo], |
| 440 | bad_regions: List[Dict], |
| 441 | image_path: str, |
| 442 | config: Dict = None) -> List[ElementInfo]: |
| 443 | """ |
| 444 | 快捷函数 - 处理问题区域 |
| 445 | |
| 446 | Args: |
| 447 | elements: 现有元素列表 |
| 448 | bad_regions: 问题区域列表(来自MetricEvaluator) |
| 449 | image_path: 原始图片路径 |
| 450 | config: 可选配置参数 |
| 451 | |
| 452 | Returns: |
| 453 | 更新后的元素列表(包含新增的fallback元素) |
| 454 | |
| 455 | 使用示例: |
| 456 | # 基本用法 |
| 457 | elements = refine_bad_regions(elements, bad_regions, "test.png") |
| 458 | |
| 459 | # 自定义配置 |
| 460 | elements = refine_bad_regions(elements, bad_regions, "test.png", { |
| 461 | 'default_confidence': 0.6, |
| 462 | 'skip_if_mostly_white': False |
| 463 | }) |
| 464 | """ |
| 465 | processor = RefinementProcessor(config) |
| 466 | context = ProcessingContext( |
| 467 | image_path=image_path, |
| 468 | elements=elements.copy() |
| 469 | ) |
| 470 | context.intermediate_results['bad_regions'] = bad_regions |
| 471 | |
| 472 | result = processor.process(context) |
| 473 | return result.elements |
| 474 | |
| 475 | def evaluate_and_refine(elements: List[ElementInfo], |
| 476 | image_path: str, |
nothing calls this directly
no test coverage detected