Skip to content

Add hybrid vision + spatial reasoning pattern (35)#263

Open
didhd wants to merge 1 commit into
aws-samples:mainfrom
didhd:add-hybrid-vision-spatial-reasoning
Open

Add hybrid vision + spatial reasoning pattern (35)#263
didhd wants to merge 1 commit into
aws-samples:mainfrom
didhd:add-hybrid-vision-spatial-reasoning

Conversation

@didhd
Copy link
Copy Markdown

@didhd didhd commented May 26, 2026

Summary

Adds a new repeatable pattern under multimodal-understanding/repeatable-patterns/35-hybrid-vision-spatial-reasoning/ that matches printed names to the photographs they belong to on a scanned page.

The pipeline runs two Amazon Bedrock calls per page:

  1. Amazon Nova 2 Lite (Pro Preview is a drop-in) — one InvokeModel call returns photo bounding boxes, every printed name with its position, and page-level metadata in a single response. All bounding boxes use a 0–1000 normalized grid.
  2. Claude Sonnet 4.6 with adaptive thinking (effort=high) — receives the original page image plus Nova's structured output and reasons over the spatial layout to map names to faces.

The two stages stay on the same coordinate space so no conversion happens between calls. The pattern works on yearbook-style layouts in the included samples but generalizes to any document where the link between a photo and the people in it only lives in the page layout (real estate listings, personnel directories, magazine spreads, etc.).

Contents

  • 01_yearbook_name_face_matching.ipynb — walkthrough notebook
  • utils.py — Stage 1 + Stage 2 helpers, structured-output prompt with assistant prefill, robust JSON parser, visualization helper
  • samples/ — three synthetic yearbook pages (portrait grid, mixed floor show, group decathlon) generated for this sample with no real student data
  • results/ — JSON output and *_links.jpg visualizations from running the notebook end-to-end
  • README.md — pattern overview with ASCII architecture diagram, model-choice guidance, and per-page results

Test plan

  • Notebook executed end-to-end against us-west-2 with us.amazon.nova-2-pro-preview-20251202-v1:0 and us.anthropic.claude-sonnet-4-6
  • All three sample pages produce 100% name-to-face associations (20/20, 5/5 with one correctly unmatched group photo, 8/8)
  • Notebook outputs cleared before commit
  • No real student data; sample names are synthetic

@review-notebook-app
Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

Two-stage pipeline that matches printed names to photographs on a scanned
page. Stage 1 calls an Amazon Nova multimodal model (Nova 2 Lite by default,
Nova 2 Pro Preview as a drop-in) to extract photo bounding boxes, printed
names with positions, and page-level metadata in a single InvokeModel call.
Stage 2 calls Claude Sonnet 4.6 with adaptive thinking on the same image
plus Nova's structured output and reasons over the spatial layout to map
names to faces.

Includes utils.py, the walkthrough notebook, three synthetic yearbook
sample pages with no real student data, and the corresponding result JSON
plus visualization JPEGs. README contains an ASCII architecture diagram
and per-page results.
@didhd didhd force-pushed the add-hybrid-vision-spatial-reasoning branch from a2bdd3e to 7beef2e Compare May 26, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant