Drop real template library; keep CDN-only matching.

Remove build_library and runtime artifacts, ignore regenerable outputs, and add README/AGENTS/DESIGN/CHANGELOG for the simplified project.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
voson
2026-07-26 11:59:48 +08:00
co-authored by Cursor
parent f32d24b8f8
commit a089660ca9
69 changed files with 299 additions and 5050 deletions
+11 -9
View File
@@ -1,12 +1,13 @@
"""Recognize the 10 drafted heroes from a strategy-time screenshot.
Usage:
python recognize.py samples/shot2.png
python recognize.py samples/shot2.png --truth tinker,earthshaker,...,drow_ranger
python recognize.py samples/raw/draft.png
python recognize.py samples/raw/draft.png --truth tinker,earthshaker,...,drow_ranger
python recognize.py samples/raw/draft.png --sheet
Outputs per-slot JSON with top-1 hero, score and margin; slots failing the
confidence gate are reported as null. With --truth, prints accuracy and saves
misrecognized crops to failures/ for later labeling.
misrecognized crops to failures/ (debug only, gitignored).
recognize_image() is the reusable entry point used by gsi_watch.py.
"""
@@ -58,13 +59,14 @@ def write_sheet(img: np.ndarray, results: list[dict], cfg: dict) -> str:
def recognize_slot(crop, library, cfg, mask=None):
"""Return (best_hero, best_score, margin, scored list)."""
penalty = cfg["match"]["cdn_penalty"]
"""Return (best_hero, best_score, margin, scored list).
cfg is accepted for call-site compatibility; score gates are applied by the caller.
"""
_ = cfg
best_per_hero: dict[str, float] = {}
for hero, source, tmpl in library:
for hero, tmpl in library:
s = match_score(crop, tmpl, mask)
if source == "cdn":
s -= penalty
if s > best_per_hero.get(hero, -2.0):
best_per_hero[hero] = s
ranked = sorted(best_per_hero.items(), key=lambda kv: kv[1], reverse=True)
@@ -142,7 +144,7 @@ def main() -> None:
sys.exit("config.json has no slots - run calibrate.py first")
library = load_template_library()
if not library:
sys.exit("template library is empty - run fetch_cdn_templates.py and/or build_library.py")
sys.exit("template library is empty - run fetch_cdn_templates.py")
out = recognize_image(img, cfg, library)
results = out.pop("slots")