Repository navigation
Introduce BoundingBox field and define_regions admin UI - #63
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #63 +/- ##
===========================================
+ Coverage 99.09% 99.18% +0.08%
===========================================
Files 74 78 +4
Lines 1659 1837 +178
Branches 123 149 +26
===========================================
+ Hits 1644 1822 +178
Misses 8 8
Partials 7 7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
JackW09
force-pushed
the
feature/archive-define-regions
branch
from
October 23, 2026 10:33
3d725c5 to
6645c6f
Compare
domdinicola
force-pushed
the
feature/archive-define-regions
branch
from
October 23, 2026 11:11
6645c6f to
51bfec9
Compare
Add Point and BoundingBox frozen dataclasses with BoundingBoxField (JSONField subclass) to replace the raw JSONField on DocumentAttribute.region. Adds a Define Regions button to DocumentAdmin that renders an HTML5 canvas page for labelling attribute bounding boxes against a reference image. Also fixes the admin login blur by adding unsafe-eval to CSP (required by Unfold/Alpine.js) and corrects the Unfold logo static path.
… fix validation_expression dark mode
- Add unit tests for Point, BoundingBox, and BoundingBoxField (round-trip,
value_from_object regression, get_prep_value, from_db_value)
- Add four admin view tests for the define_regions button (GET, image upload,
save coords, clear coords)
- Fix validation_expression input invisible in dark mode: switch
DocumentAttributeInline to unfold TabularInline and override
formfield_for_dbfield to replace the widget after RegexField.formfield()
sets its own, ensuring UnfoldAdminTextInputWidget is used
- Add validation_expression to DocumentAttributeAdmin.list_display
- Rename migration 0005→0006 for BoundingBoxField (rebase conflict fix)
- Add demo_data management command and wire it into develop
…ysisJob admin
- Introduce AttributeExtractor protocol and OCRAttributeExtractor in
extractors.py; regions are treated as hints — crop is tried first,
falling back to full-image search if the crop returns empty. This
isolates extraction logic behind a protocol ready for a future
LLM-based extractor without touching task code.
- Update _match_documents to accept AttributeExtractor instead of
Processor directly.
- Add ?sync=true query param to POST /api/analyze/: runs the task
in-process and returns the completed AnalysisJobStatusSerializer
payload with HTTP 200; async path unchanged (202 + job_id).
- Register AnalysisJob with a read-only Unfold ModelAdmin so operators
can inspect job queue and results without Postman.
- Add tests for region extraction (crop used, empty-crop fallback,
no-region fallback) and sync/async mode branching.
- Fix test_handle_debug_true to assert both call_command calls
(upgrade + demo_data) after develop command change.
…e media in dev
- Embed image_src as hidden POST field so the canvas persists after
"Save regions" without a full re-upload
- Override submit_buttons_bottom block to suppress Django's default
Save/Save and continue/Save and add another buttons on the
define_regions action page
- Add "Go back" link button returning to the Document change page
- Serve MEDIA_URL via static() in DEBUG mode so uploaded analysis
job images are accessible from the admin detail view
Both OCRAttributeExtractor and _generic_fallback discarded the Match return value from find_single and returned the raw full-page OCR text as every attribute's extracted_value. The match.text field identifies where the attribute label appears in the OCR output; the fix locates that position and returns the first non-empty line that follows it, returning "" if the label is not found at all.
domdinicola
force-pushed
the
feature/archive-define-regions
branch
from
October 26, 2026 07:15
2a386db to
ffa99c1
Compare
domdinicola
approved these changes
Oct 26, 2026
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
Add
BoundingBox/Pointvalue types andBoundingBoxFieldcustom model fieldAdd
DocumentAttribute.regionfield to store a bounding box per attributeAdd "Define Regions" admin button on
DocumentAdmin— canvas UI lets users draw a bounding box for each attribute on an uploaded document image and save them back to the DBAdd
AttributeExtractorProtocol andOCRAttributeExtractorimplementationWire region-aware extraction into
process_analysis_job; fall back to full-image OCR when no region is setExpose
?sync=trueonPOST /api/analyze/for synchronous extraction (runs in-process, no Celery required)Register
AnalysisJobAdminand adddemo_datamanagement commandFix: canvas image lost after "Save regions" POST (embed
image_srcas hidden field)Rewrite all docs (
about,api,architecture,configuration) to reflect the REST API, async pipeline, and region extractionNotes
BoundingBoxFieldstores coordinates in original image pixel space regardless of how the canvas is scaled in the browserOCRAttributeExtractorcrops with a small padding constant before passing to Tesseract; if the crop is empty it falls back to full-image OCRLegal Boilerplate
Look, I get it.
Contributing to HOPE Payment Gateway, I retain all rights, title and interest in and to my contributions, and by keeping
this boilerplate intact I confirm that HOPE Workspace can use, modify, copy, and redistribute my contributions,
under HOPE's choice of terms.