"""Which facings are falsely accepted, and as what.""" import sys, cv2 sys.path.insert(0, "code") from eval_identity import LocalLaneAdapter, load_labels, at_live_resolution, leaked, UNKNOWN, crop_of from identity_lanes import DecisionPolicy payload = load_labels("eval/labels/image6.json") image = cv2.imread("add/image6.jpg") facings = [f for f in payload["facings"] if f["label"] != "exclude"] facings = [f for f in facings if leaked(image, f["box"], "stock-lopia-clean") is None] enrolled = {"sku_l01","sku_l02","sku_l03","sku_l05","sku_l06","sku_l09","sku_l10","sku_l11"} for live in (False, True): picture = at_live_resolution(image) if live else image scaled = facings if not live else [ {**f, "box": [int(round(v * picture.shape[1] / image.shape[1])) for v in f["box"]]} for f in facings] lane = LocalLaneAdapter("stock-lopia-clean") print(f"=== {'live' if live else 'full'} ===") for f in scaled: crop = crop_of(picture, f["box"]) if crop.size == 0: continue ranked = lane.rank(crop) d = lane.decide(crop, ranked, accept=2.0, margin=0.0, scale="local") ans = d.get("best_sku") if d.get("identity_level") == "accepted" else None if ans and ans != f["label"]: print(f" #{f['index']:>3} truth={f['label']:<9} answered={ans:<9} enrolled={f['label'] in enrolled}")