Retrieve a bounded visual region and preserve its asset version, crop coordinates and supporting labels.
Image-region retrieval: cite the object, not merely the image
Index regions with their parent asset
Image-region retrieval searches a part of an image that can support a specific claim. A maintenance photo may show several pumps, warning tags and gauges; an image-level match for 'P-47 gauge' says little about which gauge carries the reading. Store asset ID, version, image dimensions, region coordinates and any reviewed label. A crop is not an independent source: it inherits access rules and revision from the parent image. Asset identity prevents a crop coordinate from silently pointing at a replacement photograph.
Generate and score candidates
Regions can come from reviewed annotations, object proposals or a grid of crops. Search their labels and visual representations, then cap the candidate window before expensive inspection. Overlapping proposals for one object should not consume every slot. Group them by parent asset and approximate overlap, retaining a precise box when evidence supports it. A predicted label is a search hint, not proof that the pictured valve is P-47. Duplicate control helps keep copied crops from masquerading as independent sightings.
Ground the claim spatially
The answer should point to a region whose visible pixels support it. A caption outside the crop may identify the object, but the caption and image need separate provenance. If the query asks whether a red lockout tag is attached, a close crop of the tag alone might hide whether it is attached to the requested pump. Keep enough surrounding context to verify the relationship without turning the citation into the whole image. Claim support must inspect the crop and its parent context.
Account for transformations
Resizing, rotation and cropping change coordinates. Store boxes in a stable source coordinate system and record any display transform; never reuse pixel positions on a newly cropped image without mapping them. Check privacy masks at the source and crop levels. A face blurred in the full image can reappear if an unredacted original is cropped and served separately. Reject regions whose bounds fall outside the asset or whose version mismatches the current display. Lifecycle rules include withdrawing all derived crops after an asset is removed.
Evaluate region-level evidence
Judge both parent-image recall and region overlap with the answer-bearing object. Include small objects, similar gauges, partially occluded labels, repeated components and misleading captions. A system that finds the correct photo but draws a box around the wrong gauge should fail. Track unsupported confident labels and missing-evidence abstentions separately. Measure the cost of finer crops against their improvement in supported claims, rather than indexing thousands of near-identical patches without a clear gain.
Worked contract
from dataclasses import dataclass
@dataclass(frozen=True)
class ImageRegion:
asset_id: str
version: str
width: int
height: int
box: tuple[int, int, int, int]
label: str
def checked_region(region: ImageRegion, expected_version: str) -> tuple[float, float, float, float]:
if region.version != expected_version:
raise ValueError("asset version mismatch")
left, top, right, bottom = region.box
if region.width <= 0 or region.height <= 0 or not (0 <= left < right <= region.width):
raise ValueError("invalid horizontal bounds")
if not 0 <= top < bottom <= region.height:
raise ValueError("invalid vertical bounds")
return (left / region.width, top / region.height,
right / region.width, bottom / region.height)
gauge = ImageRegion("plant-photo-47", "v3", 1200, 800,
(240, 160, 600, 560), "P-47 pressure gauge")
assert checked_region(gauge, "v3") == (.2, .2, .5, .7)
try:
checked_region(gauge, "v2")
except ValueError:
pass
else:
raise AssertionError("stale crop accepted")Performance and operating cost
Validating one region is O(1) time and space. A full image with R proposed regions needs storage and embedding work proportional to R, plus overlap grouping if many proposals duplicate the same object. Candidate generation can be bounded by asset and region counts; visual inspection is the costly stage. Keep source-resolution crops only for regions that survive retrieval and access checks.
Common Mistakes
- Citing an image when the requested object is not identifiable within it.
- Using crop coordinates from a different image version.
- Treating a detector's label as verified identity.
- Serving an unredacted crop of a redacted parent asset.
Validation drill
Judge 41 questions over 23 photographs containing repeated gauges, tags and valves. Score asset recall, region overlap and claim support; require rejection of stale-version boxes.
