feat: Enhance logging and parameter tracking capabilities
- Refactor `gui_core.py` to improve code readability and maintainability by adding line breaks for long statements. - Introduce `inspect_lines.py` script for inspecting specific line ranges in files. - Add `generate_param_locations.py` to scan the repository and generate a report of function definitions, argparse parameters, and tracking calls. - Implement `param_usage_tool.py` for analyzing `param_usage.json` records and scanning code for tracking calls. - Create `simulate_reservation_preempted_flow.py` and `simulate_reservation_preempted_flow_dynamic.py` to validate behavior of reservation logic under specific conditions. - Add global parameter tracking feature in `run_cli.py` to enable detailed usage tracing.
This commit is contained in:
1 parent
68c8ccea66
commit
95b4517bdd
23 files changed
+1560
-849
No files matched your search
+41
-15
@@ -1504,22 +1504,48 @@ class underlying_operations:
|
||||
# 用于收集置信度信息
|
||||
ocr_confidence_info = None
|
||||
|
||||
if getattr(self, "ocr_type", None) == "easyocr":
|
||||
result = self.ocr.readtext(img_np)
|
||||
extract_result = self.extract_ocr_content(result, return_confidence=True)
|
||||
if isinstance(extract_result, tuple):
|
||||
text, ocr_confidence_info = extract_result
|
||||
# 如果 OCR 未初始化(例如 EasyOCR/PaddleOCR 均不可用),安全降级为不识别
|
||||
try:
|
||||
ocr_obj = getattr(self, "ocr", None)
|
||||
ocr_type = getattr(self, "ocr_type", None)
|
||||
except Exception:
|
||||
ocr_obj = None
|
||||
ocr_type = None
|
||||
|
||||
if ocr_obj is None:
|
||||
try:
|
||||
logging.warning("OCR 未初始化,跳过识别:picname=%s", picname)
|
||||
except Exception:
|
||||
pass
|
||||
return ""
|
||||
|
||||
try:
|
||||
if ocr_type == "easyocr":
|
||||
result = ocr_obj.readtext(img_np)
|
||||
extract_result = self.extract_ocr_content(
|
||||
result, return_confidence=True
|
||||
)
|
||||
if isinstance(extract_result, tuple):
|
||||
text, ocr_confidence_info = extract_result
|
||||
else:
|
||||
text = extract_result
|
||||
else:
|
||||
text = extract_result
|
||||
else:
|
||||
result = self.ocr.ocr(img_np)
|
||||
if result == [None]:
|
||||
return ""
|
||||
extract_result = self.extract_ocr_content(result, return_confidence=True)
|
||||
if isinstance(extract_result, tuple):
|
||||
text, ocr_confidence_info = extract_result
|
||||
else:
|
||||
text = extract_result
|
||||
result = ocr_obj.ocr(img_np)
|
||||
if result == [None]:
|
||||
return ""
|
||||
extract_result = self.extract_ocr_content(
|
||||
result, return_confidence=True
|
||||
)
|
||||
if isinstance(extract_result, tuple):
|
||||
text, ocr_confidence_info = extract_result
|
||||
else:
|
||||
text = extract_result
|
||||
except Exception as e:
|
||||
try:
|
||||
logging.warning("OCR 调用失败,返回空结果:%s", e)
|
||||
except Exception:
|
||||
pass
|
||||
return ""
|
||||
|
||||
# Initialize variables to avoid unbound variable issues
|
||||
img1 = img # img1 is used later, initialize from img
|
||||
|
||||
Reference in new issue
Block a user