Repository navigation
Conversation
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.
Layout visualization currently allocates a full-page mask for every polygon, stacks all masks, and scans each full page to locate covered pixels. Documents with many layout regions spend substantial CPU time and memory on this work.
This change rasterizes each polygon into its clipped bounding rectangle and blends that region in place. It preserves the existing class colors, sequential overlap blending, labels, and reading-order annotations. The unused full-page mask helper is removed and its OpenCV dependency guard moves to
draw_mask.The change is limited to
paddlex/inference/models/layout_analysis/result.py. It uses the existingLayoutAnalysisResult._to_imgcontract, where the mask canvas has the same dimensions as the image.Validation
CPU comparison against the unmodified
developimplementation, using OpenCV 4.10.0, NumPy 2.3.5, and Pillow 12.3.0:git diff --check.Earlier isolated service measurements
The same patch was measured on PaddleX 3.7.2 with one A800 80 GB, all image outputs enabled, 16 warmup pages, and three repetitions over the same 50 pages. Values below are medians in seconds. Both sides already included the same four earlier pipeline/backend/client optimizations; only local mask rendering was added for this comparison.
These are prior controlled measurements, not a fresh end-to-end benchmark of this branch or an unmodified PaddleX baseline. Rendering concurrency and other performance changes are outside this PR.