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