Add hybrid vision + spatial reasoning pattern (35)#263
Open
didhd wants to merge 1 commit into
Open
Conversation
|
Check out this pull request on 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.
a2bdd3e to
7beef2e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
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 notebookutils.py— Stage 1 + Stage 2 helpers, structured-output prompt with assistant prefill, robust JSON parser, visualization helpersamples/— three synthetic yearbook pages (portrait grid, mixed floor show, group decathlon) generated for this sample with no real student dataresults/— JSON output and*_links.jpgvisualizations from running the notebook end-to-endREADME.md— pattern overview with ASCII architecture diagram, model-choice guidance, and per-page resultsTest plan
us-west-2withus.amazon.nova-2-pro-preview-20251202-v1:0andus.anthropic.claude-sonnet-4-6