product-recognition-demo/recognization/data/external-eval/kewpie/_commons.py
kiyo9w 306ea9b3e8 test(external): score 8 independent-source images, 0 false accepts
Eight images for sku_l04, sku_l07 and sku_l09 from six source domains, scored
through the shipped LocalLaneAdapter and DecisionPolicy against
stock-lopia-clean: 4 correct accepts, 4 abstains, no false accepts.

Leak-tested first: the highest template match of any image against
add/image6.jpg is 0.675, so none is a crop of the evaluation photo.

The result that matters is sku_l07. It has no enrolled image, and both its
images accept through the text lane alone - one reads ラッキー フヨネーズ, the
other the rear label's 製造者:丸和油脂株式会社 with 内容量:200g, which
together name the row 丸和油脂 ラッキーマヨネーズ 200g. The text lane's
coverage claim holds on data that was not used to build it.

The four l04 abstentions are correct behaviour: l04 is also unenrolled and its
reads are weak (one reads only コと旨 タ 味, another scores 0.379 against a
0.45 accept line).

Also records the l12 reconciliation, the Kewpie 450 g research, and two
reusable pan clips with 11 rejected candidates for a future Tier-3 replay.
Nothing here is Tier 2 or Tier 3 and every manifest says so.
2026-09-29 03:13:16 +09:00

37 lines
1.1 KiB
Python

"""Wikimedia Commons search helper for the kewpie external-proxy collection."""
import json
import sys
import urllib.parse
import _fetch
def csearch(q, limit=30):
u = (
"https://commons.wikimedia.org/w/api.php?action=query&generator=search"
f"&gsrsearch={urllib.parse.quote(q)}&gsrnamespace=6&gsrlimit={limit}"
"&prop=imageinfo&iiprop=url|size|extmetadata&format=json"
)
d = json.loads(_fetch.text(u))
out = []
for p in d.get("query", {}).get("pages", {}).values():
ii = (p.get("imageinfo") or [{}])[0]
em = ii.get("extmetadata", {})
out.append(
(
p["title"],
ii.get("width"),
ii.get("height"),
em.get("LicenseShortName", {}).get("value"),
em.get("Artist", {}).get("value", "")[:60],
ii.get("url"),
)
)
return out
if __name__ == "__main__":
for q in sys.argv[1:]:
print("###", q)
for t in csearch(q):
print(" ", t[0], "|", t[1], "x", t[2], "|", t[3], "|", t[4])