Bundle the trained heatmap/image orientation model and run it after provisional blank-page and split analysis. Confirm candidates with Gemini using low thinking; resolve mixed A3 sheet ordering with the complete statement and medium thinking. Keep A4 scans independent and export paired A3 scans in booklet reading order. Reanalyse uniformly inverted source sheets, validate ordering permutations, and preserve source provenance, corrected rotations and reading slots in manual review. Document the experiments, rejected approaches, calibration and runtime limits. Validation: focused splitting/orientation regression suites pass; bundled model checksum and wheel assets verified. Full Interro07 offline run: 44.26 seconds, eight candidates, mocked upright confirmations, source hashes and geometry intact.
11 KiB
Orientation model trained across several interros — 2026-11-04
Detailed final training record. The orientation decision record also explains the chosen approach, rejected alternatives and integration status.
The reusable model and standalone predictor are in tmp/orientation-final/bundle/; a ZIP is in tmp/orientation-final/orientation-detector.zip. The recommended default is the conservative profile. The experimental full Interro07 splitting run takes 50.92 seconds, including exports/previews and orientation checks, and refers eight upright logical pages (2.3%) for confirmation.
Dataset and frozen design
2,762 full logical pages across the seven original assessments, each supplying an upright and a synthetic 180° example. Alternate Interro03 pilot folders were excluded as duplicates.
- Training: Interro01 (392), Interro02 (423), Interro03 (431), Interro05 (406): 1,652 pages.
- Threshold calibration: Interro06: 390 pages.
- Held-out assessment: Interro04: 373 pages.
- Secondary comparison: Interro07: 347 pages.
Processed PDFs were rendered at 75 dpi after restoring the full MediaBox in memory, retaining stored rotations. Source PDFs were not saved or modified. Interro07 uses the previously saved full logical-page outputs. Existing cached Interro05/06/07 features were reused; 1,619 additional pages were rendered/extracted for Interro01–04. Parallel extraction of the additional features took 19.19 seconds; PDF rendering took 27.85 seconds. These are one-time preparation costs.
The architecture was held fixed from the preceding experiment. A standardized RBF SVM (C=3, gamma=scale) learns the 1,440 spatial features. Those concatenate normalized square-root ink-density grids of 8×12 and 16×24, for (1) the full sheet with threshold 100, (2) a crop around that ink, (3) the full sheet with threshold 140 for fainter strokes. Borders of 15 pixels are excluded from ink extraction.
The pretrained PP-LCNet_x1_0_doc_ori ONNX model supplies sixteen probabilities: all four orientation classes from full and writing-crop views, each in its supplied and reversed orientation. An ExtraTrees classifier with 200 trees, minimum leaf size 5 and seed 514 learns to combine those probabilities with one heatmap SVM score. The fusion learns from leave-one-training-assessment-out heatmap scores, rather than optimistic in-sample SVM scores. This is stronger separation than leaving out individual pages. The final SVM is then fitted on all four training assessments. Learned model fitting took 20.76 seconds in total.
The design was saved before fitting; weights, threshold and hashes were saved in frozen-model.json before predicting Interro04. Neither Interro04 nor Interro07 was used for fitting or numeric threshold calibration. Previous work had used Interro07 to choose the architecture; it is consequently only a secondary comparison. The same cohort appears across assessments, so these are held-out-assessment tests, not unseen-writer tests.
Direct prediction on actually rotated images
The final accuracy check runs the reusable predictor directly on original and 180°-rotated RGB page arrays. It recomputes the writing crop after rotation. This matters: percentile rounding can shift a crop edge by one pixel, so swapping the cached neural outputs is an approximation. An attempted exact equality check on inverted scores exposed that difference. All 720 original-page predictions match the saved feature/reference scores within 1e-7; inverted-page results below are direct fresh predictions, not assumed equivalence.
Timing is measured screening time for the specified number of pages, averaged over one upright and one inverted pass. It includes complete ink extraction, crop creation, four neural views and learned prediction; it excludes file decoding, initial model loading and PDF rendering. File-loading timings and the separate upright/inverted passes are retained in benchmark-timings.json and direct-rotation-results.json.
| Profile | Test assessment | Rotations detected | Upright flags | Detection time for that assessment |
|---|---|---|---|---|
| balanced | Interro04 | 373/373 (100.0%) | 19/373 (5.1%) | 14.91 s |
| balanced | Interro07 | 346/347 (99.7%) | 16/347 (4.6%) | 13.48 s |
| conservative | Interro04 | 372/373 (99.7%) | 11/373 (2.9%) | 14.91 s |
| conservative | Interro07 | 345/347 (99.4%) | 6/347 (1.7%) | 13.48 s |
The originally frozen balanced profile targets 2% upright flags on Interro06; threshold 0.1732301587. Its untouched Interro04 result catches all 373 rotations but flags 19 upright pages (5.1%). That is one page above a strict 5% budget of eighteen.
The conservative fallback targets 1% upright flags on Interro06; threshold 0.3044920635. Its numeric threshold uses only Interro06, but the decision to evaluate this fallback policy followed seeing the balanced holdout referral rate. Therefore its Interro04 result is an exploratory follow-up, not a second untouched validation. It is the recommended default because it stays below the desired referral volume on both measured assessments while retaining high recall. The weights are identical between profiles; only the decision threshold changes. No threshold was fitted directly to Interro04 or Interro07.
Conservative direct-image misses: Interro04 Copie16-p10; Interro07 Copie05-p01 and Copie48-p01. Rotated PNGs are saved with -remaining-rotation.png suffix. The original 64-page Interro07 sample and all 24 sparse-page rotations are detected by the conservative predictor.
A fixed previous model (trained on Interro05, calibrated on Interro06) was also evaluated using the stored feature augmentation: on Interro04 it caught 371/373 with 28 upright flags; the new balanced model caught 373 with nineteen. This comparison used cached rotated crops, not the final direct recropping test, and should not be substituted for the direct metrics above.
Full automatic splitting trial
The experimental wrapper reuses the existing RGB overview and records scores for each retained logical page, without changing splitting or blank-removal behaviour. It also computes an inverted-feature score for auditing, reusing the four neural views. These inverted-feature scores approximate a direct re-render/recrop, as explained above. Timing therefore includes both normal screening and this inexpensive audit.
| Full Interro07 trial | Simulated rotations detected | Upright flags | Total time including splitting, previews, exports and startup |
|---|---|---|---|
| balanced | 346/347 | 22/347 (6.3%) | 50.92 s (same run) |
| conservative | 345/347 | 8/347 (2.3%) | 50.92 s (same run) |
For the conservative profile, the actual splitter previews catch the same 345 rotations, refer eight upright pages, and preserve detection of all 64 prior sample pages and all 24 sparse pages. Differences between six separate-image flags and eight integrated flags come from raster phase and overlapping crop boundaries. The balanced profile produces 22 integrated flags and is above 5% for this run; this reinforces the conservative recommendation.
The complete measured run meets the one-minute budget on this machine (Ryzen 7 PRO 7840U, four copy workers, one neural inference thread per worker). This is a single run, not a guaranteed latency bound. An earlier attempt was interrupted with exit 143 and excluded from timing; the uninterrupted retry is the source of the quoted result. Initial bundled model loading took about 0.81 seconds in a separate standalone run. Training is not repeated during splitting. LLM confirmation time is not included.
All 214 source pages and 47 PDFs were processed, retaining 347 logical pages and removing 73 blank halves. All 420 keep/remove decisions and all output rectangles match the earlier baseline. All 47 original Interro07 hashes still match. No application source or evaluation PDF was changed. verification.json records these checks.
Ground-truth limits and review
Original pages are presumed upright from the existing corrected workflow. A 24-page random sample from each newly added training assessment was visually reviewed. All nineteen balanced-profile Interro04 flags were visually inspected after the model was frozen and appear upright, including substantial clusters from heavily ruled monochrome copies. The prior Interro05/06 samples and Interro07 reviewed examples remain available. Every original page in the complete 2,762-page corpus has not been independently labelled; the full counts retain that limitation. Synthetic 180° rotations also do not cover every real scanner artifact. The model remains a screening stage whose flags should receive LLM confirmation.
More interros improved assessment generalization, but did not uniformly lower every error rate: the higher-recall profile has more referrals on Interro07 than the previous narrower model. The recommended conservative profile instead favours a manageable confirmation queue. The remaining errors are formula-heavy pages with weak or misleading layout cues.
Saved artifacts and use
bundle/model.joblib: final SVM and fusion classifier, trained on four assessments.bundle/doc.onnx: official PaddlePaddle PP-LCNet_x1_0_doc_ori neural model.bundle/predict.py: self-containedDetector; input is a full logical-page RGB uint8 array at 75 dpi. Reuse one detector per worker. Default profile is conservative.bundle/settings.json: profiles, thresholds, data roles, hashes and validation results.bundle/requirements.txt: runtime dependencies; scikit-learn and ONNX Runtime pinned to the versions used.orientation-detector.zip: complete standalone bundle.
Minimal usage: import Detector from predict.py, instantiate Detector(), then call detector.predict(image_rgb). The result contains flag, score, threshold and heatmap_score. Scores are screening signals, not calibrated probabilities. The bundle does not make LLM requests or alter PDFs.
The model files are locally generated joblib artifacts. PP-LCNet_x1_0_doc_ori is Apache-2.0 and comes from https://huggingface.co/PaddlePaddle/PP-LCNet_x1_0_doc_ori_onnx .
Preparation, fitting and validation scripts are in tmp/orientation-final. All data roles and the frozen architecture are in design.json; frozen-model.json records the primary model/threshold before holdout prediction; profiles.json explicitly records the later fallback policy. Training uses leave-one-training-exam-out stacking, not any held-out assessment. all-corpus.json, features.npz, results.json and direct-rotation-results.json retain the complete corpus and score provenance. integration.py reproduces the experimental full splitting run into a new directory; existing-output refusal applies.