feat: price-tag UI, still-image tag passes, and honest tag evidence
Web client: price-tag boxes in a distinct style (teal, chip with the parsed price), an OCR section in the product card showing the tag's price, name, discount and the reconciliation verdict with both values, and a compliance strip under the stage. The photo stage now draws the image into the canvas and uses the same containment as the media, so boxes cannot drift from the product (they did: the canvas stretched to the stage while the photo was contained). Server fixes the browser runs forced out: - Photo mode reconciled before identities existed, so every tag read "tag only". The tag bundle is cached with the still and classify re-reconciles against the identities it just produced, returning them per detection. - The still path only ever read the first four bands (plan hands out two per call); it now drains every band, twice at different upscales so the vote has independent reads. - Voting is confidence-weighted and a dead heat stays unread; the plausible shelf-price range is 10-9999, which stops a misread from becoming a ¥26,300 price. The compliance coverage bar moved to 0.7 after 0.5 produced a false "group without price tag" on a shelf where every facing has one. Measured on add/image6.jpg: 8 readable tags with names and prices, 942 ms for the whole still, 7 real price mismatches, no false violations, and hints that say plainly when a row could not be read. Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
parent
a27841afa4
commit
8f750c15c5
8 changed files with 330 additions and 60 deletions
|
|
@ -392,6 +392,7 @@ def create_app(
|
|||
result["compliance"] = bundle["compliance"]
|
||||
result["ocr_engine"] = ocr_engine.name
|
||||
result["tag_timing_ms"] = round(elapsed_ms, 1)
|
||||
engine.image_store.set_tag_bundle(result["image_id"], bundle)
|
||||
return result
|
||||
|
||||
@app.post("/v1/images/{image_id}/classify", dependencies=[Depends(authorize)])
|
||||
|
|
@ -413,22 +414,44 @@ def create_app(
|
|||
if row is not None:
|
||||
detection["identity"] = row["identity"]
|
||||
engine.image_store.update_detections(image_id, stored.detections)
|
||||
identities = [
|
||||
{
|
||||
|
||||
# Tags were read before the identities existed; reconcile them now.
|
||||
compliance = None
|
||||
if stored.tag_bundle:
|
||||
from reconcile import reconcile_bundle
|
||||
|
||||
catalog_by_sku = {product["sku_id"]: product for product in engine.catalog()}
|
||||
refreshed = reconcile_bundle(stored.tag_bundle, stored.detections, catalog_by_sku)
|
||||
for detection in stored.detections:
|
||||
decision = refreshed["reconciliations"].get(int(detection["id"]))
|
||||
if decision is not None:
|
||||
detection["reconciliation"] = decision
|
||||
compliance = refreshed["compliance"]
|
||||
identities = []
|
||||
for detection in detections:
|
||||
row = {
|
||||
"detection_id": int(detection["id"]),
|
||||
"box": list(detection["box"]),
|
||||
"identity": detection["identity"],
|
||||
}
|
||||
for detection in detections
|
||||
]
|
||||
# Re-reconciled after classification; without it a client would keep
|
||||
# the `tag_only` verdict it got when identities did not exist yet.
|
||||
if detection.get("reconciliation") is not None:
|
||||
row["reconciliation"] = detection["reconciliation"]
|
||||
if detection.get("price_tag") is not None:
|
||||
row["price_tag"] = detection["price_tag"]
|
||||
identities.append(row)
|
||||
summary = engine.summarize(stored.detections, [])
|
||||
return {
|
||||
payload = {
|
||||
"image_id": image_id,
|
||||
"method": method,
|
||||
"identities": identities,
|
||||
"summary": summary,
|
||||
"timing_ms": {"classify": round((time.perf_counter() - started) * 1000.0, 2)},
|
||||
}
|
||||
if compliance is not None:
|
||||
payload["compliance"] = compliance
|
||||
return payload
|
||||
|
||||
@app.post("/v1/images/{image_id}/inspect", dependencies=[Depends(authorize)])
|
||||
async def inspect_image(image_id: str, body: InspectBody) -> Dict[str, Any]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue