RotDet v2: compact four-way document orientation detection
Frozen RotDet v2 candidates. Code implementation: https://github.com/fcrescio/rotdet/tree/11217d2
Two frozen C4Net candidates, separately trained at 256 and 384 pixels. The public release name is RotDet v2; this is the corrected C4Net architecture, not the experimental C4NetV2 class.
| Variant | Weight file | Input | Weight size |
|---|---|---|---|
| 256 | 256/model.safetensors |
Grayscale 256x256 | 1,560,900 bytes |
| 384 | 384/model.safetensors |
Grayscale 384x384 | 1,560,900 bytes |
Each folder contains the exact architecture, preprocessing resolution and
checkpoint SHA-256 in config.json. The default recommendation is 256 for
lower CPU cost. 384 performed better on development validation, not on the
small provisionally annotated independent corpus.
Usage
Install the code from https://github.com/fcrescio/rotdet and use a pinned revision of this model repository:
pip install torch --index-url https://download.pytorch.org/whl/cpu
pip install 'rotdet[hub] @ git+https://github.com/fcrescio/rotdet.git@v2.0.1'
from pathlib import Path
import torch
from rotdet import Detector
torch.set_num_threads(4)
model = Detector.from_pretrained(
256, revision="6662ebee315bb481d2919b30922d42356a8361ab")
result = model.predict(Path("page.png").read_bytes())
print(result["correction_cw_degrees"])
Class k describes k90 degrees counterclockwise from upright. Correct by k90 degrees clockwise. The library verifies checkpoint hashes, runs on CPU, and never modifies input files. Softmax confidence is uncalibrated. No PDF decoder or fine-angle deskewing is included.
Anonymous downloads and installation were verified in a clean CPU environment. Both downloaded candidates matched all 40 frozen fixture views per variant. These parity checks verify artifact identity, not new accuracy measurements.
Evaluation
| Model | Correct / provisionally labeled pages | Accuracy | CPU batch1 median |
|---|---|---|---|
| RotDet v2 256 | 149 / 164 | 90.85% | 29.4 ms |
| RotDet v2 384 | 147 / 164 | 89.63% | 49.0 ms |
| Paddle PP-LCNet_x1_0_doc_ori | 154 / 164 | 93.90% | 74.2 ms |
Independent corpus: 192 pages / 51 documents, 164 numeric vision-LLM labels and 28 uncertain pages; coverage 85.42%; zero human gold labels. Paired uncertainty does not establish superiority or equivalence. Timings use four CPU threads and native declared preprocessing; they are not cross-platform performance guarantees. Framework memory is not weight size.
On document-pure development validation, mean accuracy over three matched seeds was 95.76% at 256 and 96.70% at 384. These are development results, not independent test accuracy. Released candidates both use seed 42, selected before independent evaluation.
See https://github.com/fcrescio/rotdet/blob/main/docs/BENCHMARK.md for protocol, caveats and frozen evaluation identities.
Training provenance
Trained from scratch on 4,439 deduplicated upright source pages from 406 Internet Archive identifiers, with artificial quarter-turn augmentation. RGB -> grayscale -> square BICUBIC resize -> float32 / 255. Training recipe and source links are documented at:
- https://github.com/fcrescio/rotdet/blob/main/docs/DATA_PROVENANCE.md
- https://github.com/fcrescio/rotdet/blob/main/docs/training_sources.json
No explicit license was identified for the source materials. The documents are not redistributed. Citations document provenance, not reuse permission. The maintainer considers training use fair use; this is not a legal determination. Private independent evaluation documents are not included.
Limitations and licenses
Sparse text, blank pages, handwriting, multiple text directions, unusual layouts and domain shifts can produce wrong corrections. Use human review where a wrong rotation has significant consequences.
Code and both frozen v2 checkpoints are offered under GNU GPL version 3
only (GPL-3.0-only) from release v2.0.1. The full license is in LICENSE;
the copyright, scope and warranty notice is in NOTICE.md. Checkpoint bytes
are unchanged. The grant also covers these same checkpoint bytes downloaded
from the earlier frozen revision.
GPL allows use, modification and commercial use subject to its terms and copyleft conditions on covered redistributions. No AGPL network provision or noncommercial restriction is added. Earlier MIT grants for previously published code remain valid; older tags are not rewritten. The v1 weights retain their existing CC-BY-4.0 license.
The license does not apply to original documents or dependencies. This is a model release, not a dataset. See the licensing scope at https://github.com/fcrescio/rotdet/blob/v2.0.1/docs/LICENSING.md.