Duy commited on
Commit ·
ed0c8d7
1
Parent(s): 7330864
fix: eval_drawings.py — correct template pairings and document baselines
Browse files- scripts/eval_drawings.py +43 -30
scripts/eval_drawings.py
CHANGED
|
@@ -1,5 +1,11 @@
|
|
| 1 |
-
"""
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
"""
|
| 4 |
import sys
|
| 5 |
import os
|
|
@@ -10,39 +16,46 @@ from src.pipeline import PatternDetectionPipeline # noqa: E402
|
|
| 10 |
|
| 11 |
DRAWINGS_DIR = r"D:\Sotatek_Assessment\drawings"
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
if not os.path.exists(pattern):
|
| 19 |
-
print(f"MISSING pattern: {pattern}")
|
| 20 |
-
return
|
| 21 |
|
|
|
|
|
|
|
| 22 |
summary = {}
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
for i in range(1, 7):
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
flag = " <-- DIFF" if on != off else ""
|
| 45 |
-
print(f" {name}: ON={on} OFF={off}{flag}")
|
| 46 |
|
| 47 |
|
| 48 |
if __name__ == "__main__":
|
|
|
|
| 1 |
+
"""Evaluate the pipeline on the 6 assessment drawings.
|
| 2 |
+
|
| 3 |
+
Template pairings (established in session 5):
|
| 4 |
+
Drawing 1 (resistor circuit) + test_pattern_d1_2.png -> baseline 10 dets
|
| 5 |
+
Drawing 4 (bridge rectifier) + test_pattern_d1.png -> baseline 4 dets
|
| 6 |
+
Drawings 2,3,5,6 + test_pattern_d1_2.png -> expected 0 dets
|
| 7 |
+
|
| 8 |
+
DINODense Pass C was shown to be dormant (ON==OFF everywhere) in session 6.
|
| 9 |
"""
|
| 10 |
import sys
|
| 11 |
import os
|
|
|
|
| 16 |
|
| 17 |
DRAWINGS_DIR = r"D:\Sotatek_Assessment\drawings"
|
| 18 |
|
| 19 |
+
# Primary evaluation: resistor template vs all 6 drawings
|
| 20 |
+
RESISTOR_PAT = os.path.join(DRAWINGS_DIR, "test_pattern_d1_2.png")
|
| 21 |
+
# Secondary: bridge rectifier template vs drawing 4
|
| 22 |
+
BRIDGE_PAT = os.path.join(DRAWINGS_DIR, "test_pattern_d1.png")
|
| 23 |
|
| 24 |
+
BASELINES = {
|
| 25 |
+
("resistor", "1.png"): 10,
|
| 26 |
+
("resistor", "4.png"): None, # not expected
|
| 27 |
+
("bridge", "4.png"): 4,
|
| 28 |
+
}
|
| 29 |
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
+
def main():
|
| 32 |
+
pipe = PatternDetectionPipeline()
|
| 33 |
summary = {}
|
| 34 |
+
|
| 35 |
+
print("\n===== Resistor template (test_pattern_d1_2.png) =====")
|
| 36 |
+
for i in range(1, 7):
|
| 37 |
+
dpath = os.path.join(DRAWINGS_DIR, f"{i}.png")
|
| 38 |
+
if not os.path.exists(dpath):
|
| 39 |
+
print(f" SKIP {i}.png (not found)")
|
| 40 |
+
continue
|
| 41 |
+
r = pipe.detect_auto(RESISTOR_PAT, dpath, return_visualization=False)
|
| 42 |
+
n = r["total_detections"]
|
| 43 |
+
summary[("resistor", f"{i}.png")] = n
|
| 44 |
+
base = BASELINES.get(("resistor", f"{i}.png"))
|
| 45 |
+
tag = f" (baseline {base})" if base is not None else ""
|
| 46 |
+
print(f" {i}.png: {n}{tag}")
|
| 47 |
+
|
| 48 |
+
print("\n===== Bridge-rectifier template (test_pattern_d1.png) vs drawing 4 =====")
|
| 49 |
+
dpath = os.path.join(DRAWINGS_DIR, "4.png")
|
| 50 |
+
r = pipe.detect_auto(BRIDGE_PAT, dpath, return_visualization=False)
|
| 51 |
+
n = r["total_detections"]
|
| 52 |
+
print(f" 4.png: {n} (baseline 4)")
|
| 53 |
+
|
| 54 |
+
print("\n===== SUMMARY =====")
|
| 55 |
for i in range(1, 7):
|
| 56 |
+
k = ("resistor", f"{i}.png")
|
| 57 |
+
if k in summary:
|
| 58 |
+
print(f" resistor + {i}.png: {summary[k]}")
|
|
|
|
|
|
|
| 59 |
|
| 60 |
|
| 61 |
if __name__ == "__main__":
|