Repository navigation
Conversation
This branch has not been deployed
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.
What
Make the rotated page C-contiguous before OCR in both table-orientation paths in
pipeline_v2.py: whole-page tables and layout-detected tables. Covers 90, 180, and 270 degrees.Why
np.rot90returns a view. Passing that non-contiguous page to the OCR crop loop makes OpenCV convert the full page for each text box. Normalize once after choosing the rotation, before OCR, preserving orientation and pixels.Related to #5178 and complements #5179, which covers the UVDoc producer.
Direction: correct the page-producing boundary before repeated crops; keep table orientation and OCR behavior.
Common practice: follows NumPy's rotated-view contract and contiguous conversion, using the same boundary correction as #5179.
Correction: refactor.
Cut: repeated downstream conversion of the rotated page; no code removed.
Add: one
np.ascontiguousarraycall in each rotated-page path, before OCR.Validation
k=1/2/3: both paths produce contiguous pages with identical page and perspective-crop pixels.Gain: the synthetic reproduction already posted on #5178 measured median crop time from 81.967041 ms to 0.203834 ms, with identical crop pixels (402.1x). It uses a seeded random 5600×4000×3 uint8 page, a 500×40 crop, five warmups, and 30 interleaved samples per layout. The one-time page conversion cost was 82.709770 ms, excluded from crop timing. Only
k=1was timed; this is not an end-to-end OCR speedup claim.Benchmark environment: macOS 27.0 arm64, Python 3.12.13, NumPy 2.3.5, opencv-python-headless 4.10.0.84. The script requests one OpenCV thread; the build reports 18.
Test plan
Reproduction and pixel checks are described above. For model-level validation, run table recognition on a generated turned-table page at 90, 180, and 270 degrees, with and without layout detection, and compare crop pixels and OCR results against the base revision.
Compatibility
No public API, rotation, or model configuration changes. The zero-degree path is unchanged.