|
36 | 36 | "fail": "Some parts could not be detected clearly. Please separate the parts and retake the photo.", |
37 | 37 | }, |
38 | 38 | "precheck": { |
39 | | - "pass": "Good. The detected setup is consistent. You can proceed.", |
40 | | - "count_rule_fail": ( |
41 | | - "The detected numbers of gears and gear-contact regions are not consistent. " |
42 | | - "Please make sure all gears and contact regions are clearly visible, then retake the photo." |
| 39 | + "report": ( |
| 40 | + "Photo quality reference values:\n" |
| 41 | + "- brightness: {brightness_mean}\n" |
| 42 | + "- contrast: {contrast_std}\n" |
| 43 | + "- sharpness: {sharpness_score}\n" |
| 44 | + "- lighting uniformity: {illumination_nonuniformity}\n" |
| 45 | + "These values are provided as reference only and do not determine whether the assembly is correct." |
43 | 46 | ), |
44 | | - "big_small_inconsistent": ( |
45 | | - "The detected numbers of big gears and small gears are not consistent. " |
46 | | - "Please make sure all gears are clearly visible, then retake the photo." |
47 | | - ), |
48 | | - "fail": "Please retake the photo. The detected setup is not consistent enough for reliable checking.", |
49 | 47 | }, |
50 | 48 | "single_stage": { |
51 | 49 | "pass": ( |
|
125 | 123 | "- driving gear: {driving_gear}\n" |
126 | 124 | "- small gear: {smallgear}\n" |
127 | 125 | "- big gear: {biggear}\n" |
128 | | - "The detected gears and contact regions are not consistent enough for reliable checking. " |
129 | | - "Please make sure only the intended gears are visible, that meshing areas can be seen clearly, " |
130 | | - "and then retake the photo." |
| 126 | + "The system cannot reliably evaluate the gear meshing due to unclear or inconsistent detection results. " |
| 127 | + "Please ensure that only the required gears are visible in the image, and that the gear meshing areas " |
| 128 | + "are clearly shown before retaking the photo." |
| 129 | + ), |
| 130 | + "big_small_inconsistent": ( |
| 131 | + "Detected gears:\n" |
| 132 | + "- driving gear: {driving_gear}\n" |
| 133 | + "- small gear: {smallgear}\n" |
| 134 | + "- big gear: {biggear}\n" |
| 135 | + "The detected numbers of big gears and small gears are not consistent. " |
| 136 | + "Please check the gear setup and retake the photo." |
131 | 137 | ), |
132 | 138 | "mismatch_fail": ( |
133 | 139 | "Detected gears:\n" |
@@ -299,6 +305,7 @@ def keep(e: Dict[str, Any]) -> bool: |
299 | 305 | "E_NO_GEARS", |
300 | 306 | "E_MESH_MISMATCH", |
301 | 307 | "E_GEAR_CONTACT_INCONSISTENT", |
| 308 | + "E_GEAR_BIG_SMALL_INCONSISTENT", |
302 | 309 | } |
303 | 310 |
|
304 | 311 | if task == "mesh_ratio": |
@@ -513,25 +520,20 @@ def _build_student_message( |
513 | 520 | task_has_error = _has_selected_pipeline_error(selected_errors) |
514 | 521 |
|
515 | 522 | if task == "precheck": |
516 | | - codes = { |
517 | | - str(e.get("code", "")).upper() |
518 | | - for e in selected_errors |
519 | | - if isinstance(e, dict) |
520 | | - } |
521 | | - |
522 | | - if "E_NO_GEARS" in codes: |
523 | | - return False, MESSAGE_POLICY["precheck"]["fail"] |
524 | | - |
525 | | - if "E_PRECHECK_BIG_SMALL_INCONSISTENT" in codes: |
526 | | - return False, MESSAGE_POLICY["precheck"]["big_small_inconsistent"] |
527 | | - |
528 | | - if "E_PRECHECK_COUNT_RULE_FAIL" in codes: |
529 | | - return False, MESSAGE_POLICY["precheck"]["count_rule_fail"] |
530 | | - |
531 | | - if task_has_error: |
532 | | - return False, MESSAGE_POLICY["precheck"]["fail"] |
533 | | - |
534 | | - return True, MESSAGE_POLICY["precheck"]["pass"] |
| 523 | + quality = out.get("quality", {}) if isinstance(out.get("quality"), dict) else {} |
| 524 | + |
| 525 | + def qfmt(key: str) -> str: |
| 526 | + try: |
| 527 | + return f"{float(quality.get(key, 0.0)):.2f}" |
| 528 | + except Exception: |
| 529 | + return str(quality.get(key, "N/A")) |
| 530 | + |
| 531 | + return True, MESSAGE_POLICY["precheck"]["report"].format( |
| 532 | + brightness_mean=qfmt("brightness_mean"), |
| 533 | + contrast_std=qfmt("contrast_std"), |
| 534 | + sharpness_score=qfmt("sharpness_score"), |
| 535 | + illumination_nonuniformity=qfmt("illumination_nonuniformity"), |
| 536 | + ) |
535 | 537 |
|
536 | 538 | if task == "single_stage": |
537 | 539 | codes = { |
@@ -721,6 +723,13 @@ def _build_student_message( |
721 | 723 | biggear=biggear, |
722 | 724 | ) |
723 | 725 |
|
| 726 | + if "E_GEAR_BIG_SMALL_INCONSISTENT" in codes: |
| 727 | + return False, MESSAGE_POLICY["gear_inventory"]["big_small_inconsistent"].format( |
| 728 | + driving_gear=driving_gear, |
| 729 | + smallgear=smallgear, |
| 730 | + biggear=biggear, |
| 731 | + ) |
| 732 | + |
724 | 733 | if "E_GEAR_CONTACT_INCONSISTENT" in codes: |
725 | 734 | return False, MESSAGE_POLICY["gear_inventory"]["contact_consistency_fail"].format( |
726 | 735 | driving_gear=driving_gear, |
|
0 commit comments