mobilenetv3-seg-doc
Document-boundary segmenter: given a photo of a page, predicts the region the document occupies. Trained on SmartDoc 2015 Challenge 1 with synthetic background recompositing.
Architecture
- MobileNetV3-Large encoder (ImageNet-pretrained) + U-Net decoder
- Input 384x384, letterboxed; output one logit per pixel
- Loss: BCE + 0.5 x soft Dice
- Checkpoint from epoch 6
Evaluation
Measured on held-out documents, not held-out frames: SmartDoc is video, and consecutive frames of one capture are near-duplicates, so a frame-level split would report a number that means nothing.
- Quad IoU (median): 0.991
- Frames scored correct (IoU >= 0.95): 98.5%
- Error quadrants:
{'positive': 197, 'ignore': 3}
The model emits a mask; the boundary the pipeline consumes is the 4-point quadrilateral fitted to it. Evaluate on the quad, not on pixel IoU — a mask no quad can be fitted to is a failure at the level that matters.
Training data
- Records:
data/segmenter/records - 19834 training frames across 24 documents
- Backgrounds:
{'paper_match': 5051, 'light_desk': 3183, 'wood_desk': 2376, 'denim': 2367, 'background01': 1521, 'background02': 1440, 'background03': 1435, 'background04': 1016, 'tile_floor': 812, 'background05': 633}
Backgrounds beyond SmartDoc's own five are synthetic recompositions — the page is warped out of its frame and placed on a generated surface. The largest share is deliberately matched to each page's own paper tone, which is the case a global brightness threshold cannot solve and the reason to train a model at all.
No production or beneficiary imagery was used. Provenance is recorded in the checkpoint and checked before upload.
Usage
from huggingface_hub import hf_hub_download
from imgquality.smartdoc_pipeline.segmenter import load_segmenter, predict_mask
from imgquality.verifier_model import pick_device
import cv2
path = hf_hub_download("ejahdil/mobilenetv3-seg-doc", "segmenter.pt")
device = pick_device()
model = load_segmenter(path, device)
mask = predict_mask(model, cv2.imread("page.jpg"), device) # uint8, 0/255
For the fitted quadrilateral rather than the raw mask, pass the mask to
imgquality.metrics.detect_document_region.
Licence and attribution
Released CC BY 4.0, matching the dataset it was trained on. SmartDoc 2015 Challenge 1 requires attribution:
Jean-Christophe Burie, Joseph Chazalon, Mickael Coustaty, Sebastien Eskenazi, Muhammad Muzzamil Luqman, Maroua Mehri, Nibal Nayef, Jean-Marc Ogier, Sophea Prum and Marcal Rusinol. "ICDAR2015 Competition on Smartphone Document Capture and OCR (SmartDoc)". 13th International Conference on Document Analysis and Recognition (ICDAR), 2015.