Skip to content

Commit ba5037c

Browse files
committed
update gear inventory
1 parent dc50366 commit ba5037c

2 files changed

Lines changed: 31 additions & 22 deletions

File tree

evaluation_function/evaluation.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@
120120
"- big gear: {biggear}\n"
121121
"Good. No obvious gear mismatch was detected."
122122
),
123+
"contact_consistency_fail": (
124+
"Detected gears:\n"
125+
"- driving gear: {driving_gear}\n"
126+
"- small gear: {smallgear}\n"
127+
"- 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."
131+
),
123132
"mismatch_fail": (
124133
"Detected gears:\n"
125134
"- driving gear: {driving_gear}\n"
@@ -258,7 +267,6 @@ def keep(e: Dict[str, Any]) -> bool:
258267

259268
if task == "precheck":
260269
return code in {
261-
"E_PRECHECK_COUNT_RULE_FAIL",
262270
"E_PRECHECK_BIG_SMALL_INCONSISTENT",
263271
"E_NO_GEARS",
264272
}
@@ -290,6 +298,7 @@ def keep(e: Dict[str, Any]) -> bool:
290298
return code in {
291299
"E_NO_GEARS",
292300
"E_MESH_MISMATCH",
301+
"E_GEAR_CONTACT_INCONSISTENT",
293302
}
294303

295304
if task == "mesh_ratio":
@@ -712,6 +721,13 @@ def _build_student_message(
712721
biggear=biggear,
713722
)
714723

724+
if "E_GEAR_CONTACT_INCONSISTENT" in codes:
725+
return False, MESSAGE_POLICY["gear_inventory"]["contact_consistency_fail"].format(
726+
driving_gear=driving_gear,
727+
smallgear=smallgear,
728+
biggear=biggear,
729+
)
730+
715731
if task_has_error:
716732
return False, MESSAGE_POLICY["gear_inventory"]["fail"].format(
717733
driving_gear=driving_gear,

evaluation_function/yolo_pipeline.py

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -719,27 +719,6 @@ def evaluate_precheck_consistency(
719719
errs: List[Dict[str, str]] = []
720720

721721
counts = get_gear_counts(gears)
722-
total_contact = len(mesh_boxes) + len(mismesh_boxes)
723-
gear_count = len(gears)
724-
725-
expected_contact, ok = expected_contact_boxes_from_gear_count(gear_count)
726-
727-
if (not ok) or (expected_contact is None):
728-
errs.append({
729-
"code": "E_PRECHECK_COUNT_RULE_FAIL",
730-
"message": (
731-
f"Precheck failed: detected gear_count={gear_count}, which does not fit "
732-
f"the expected contact rule."
733-
),
734-
})
735-
elif total_contact != expected_contact:
736-
errs.append({
737-
"code": "E_PRECHECK_COUNT_RULE_FAIL",
738-
"message": (
739-
f"Precheck failed: mesh+mismesh={total_contact}, expected={expected_contact} "
740-
f"for gear_count={gear_count}."
741-
),
742-
})
743722

744723
if counts["biggear"] != counts["smallgear"]:
745724
errs.append({
@@ -847,6 +826,7 @@ def evaluate_parts_inventory(
847826
# =========================
848827
def evaluate_gear_inventory_step(
849828
gears: List[Dict[str, Any]],
829+
mesh_boxes: List[Tuple[float, float, float, float]],
850830
mismesh_boxes: List[Tuple[float, float, float, float]],
851831
) -> Tuple[List[Dict[str, str]], Dict[str, int]]:
852832
errs: List[Dict[str, str]] = []
@@ -859,6 +839,18 @@ def evaluate_gear_inventory_step(
859839
})
860840
return errs, counts
861841

842+
total_contact = len(mesh_boxes) + len(mismesh_boxes)
843+
gear_count = len(gears)
844+
expected_contact, ok = expected_contact_boxes_from_gear_count(gear_count)
845+
if (not ok) or (expected_contact is None) or (total_contact != expected_contact):
846+
errs.append({
847+
"code": "E_GEAR_CONTACT_INCONSISTENT",
848+
"message": (
849+
f"Gear inventory consistency check failed: mesh+mismesh={total_contact}, "
850+
f"expected={expected_contact} for gear_count={gear_count}."
851+
),
852+
})
853+
862854
if len(mismesh_boxes) > 0:
863855
errs.append({
864856
"code": "E_MESH_MISMATCH",
@@ -2286,6 +2278,7 @@ def _need_shafts() -> bool:
22862278
if task == TASK_GEAR_INV:
22872279
errors, counts = evaluate_gear_inventory_step(
22882280
gears=gears,
2281+
mesh_boxes=mesh_boxes,
22892282
mismesh_boxes=mismesh_boxes,
22902283
)
22912284

0 commit comments

Comments
 (0)