Add aspect-ratio measurement as a soft trimming signal, reported against every standard card size
This commit is contained in:
parent
b28305dd25
commit
f464faca43
5 changed files with 139 additions and 2 deletions
35
vision.py
35
vision.py
|
|
@ -643,6 +643,7 @@ def grade_card(images, api_key=None, model=None, effort=None, zoom_details=True)
|
|||
can_measure = zoom_details and images and cardimage.available()
|
||||
measured = cardimage.edge_wear_profile(images[0][0]) if can_measure else None
|
||||
centering = cardimage.centering_profile(images[0][0]) if can_measure else None
|
||||
aspect = cardimage.aspect_profile(images[0][0]) if can_measure else None
|
||||
|
||||
prompt_parts = []
|
||||
if centering:
|
||||
|
|
@ -705,6 +706,39 @@ def grade_card(images, api_key=None, model=None, effort=None, zoom_details=True)
|
|||
"strip images to describe what the wear looks like and to "
|
||||
"catch what the measurement does not look for at all, such as "
|
||||
"a nick, a chip, or a crushed edge.")
|
||||
if aspect:
|
||||
standard_rows = "\n".join(
|
||||
" {}: {:.4f} standard → {:.1f}% deviation".format(
|
||||
name, data["standard_ratio"], data["deviation_percent"])
|
||||
for name, data in aspect["against_standards"].items())
|
||||
prompt_parts.append(
|
||||
"MEASURED CARD PROPORTIONS — the width:height ratio of the card's "
|
||||
"own detected outline in this photo, computed from the pixels: "
|
||||
"{:.4f}. Compared against every standard card size, since which "
|
||||
"one is relevant depends on the card's era, which is for you to "
|
||||
"judge, not this measurement:\n{}\n"
|
||||
"Use the deviation against whichever standard actually matches "
|
||||
"the card type and era you're identifying it as — a modern card "
|
||||
"compared against the tobacco-era ratio, or vice versa, will show "
|
||||
"a large 'deviation' that means nothing at all.\n"
|
||||
"Unlike the centering and edge numbers above, this one comes with "
|
||||
"NO reliability check already applied, because the code cannot "
|
||||
"tell a genuinely non-standard card apart from one simply "
|
||||
"photographed at a slight rotation — both inflate the measured "
|
||||
"box the same way. That call needs the photo, which only you "
|
||||
"have: look at whether the card actually sits square in the "
|
||||
"frame before trusting this number at all. A deviation under "
|
||||
"roughly 3% against the RELEVANT standard is normal photo-crop "
|
||||
"noise and means nothing either way. A larger one on a photo that "
|
||||
"looks square-on is worth connecting to the corner-squareness "
|
||||
"guidance above — it can corroborate a miscut or trimming "
|
||||
"suspicion you already have visual grounds for, but it should "
|
||||
"never be the ONLY reason you raise one; a rotated or "
|
||||
"slightly-cropped photo produces exactly the same number on a "
|
||||
"perfectly normal card. This only catches UNEVEN trimming (more "
|
||||
"removed from one side than another) — it cannot see a symmetric "
|
||||
"trim taken off all four sides evenly.".format(
|
||||
aspect["measured_ratio"], standard_rows))
|
||||
if crops:
|
||||
prompt_parts.append(
|
||||
"The close-ups above are upscaled crops of the full card photo, each "
|
||||
|
|
@ -734,6 +768,7 @@ def grade_card(images, api_key=None, model=None, effort=None, zoom_details=True)
|
|||
"card_note": (parsed.get("card_note") or "").strip(),
|
||||
"edge_measurements": measured,
|
||||
"centering_measurement": centering,
|
||||
"aspect_measurement": aspect,
|
||||
"estimated_grade": _clean_grade(parsed.get("estimated_grade")),
|
||||
"grade_low": low,
|
||||
"grade_high": high,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue