How fh2019ustc/docscanner works
Project type and purpose
• From the file tree and README, this is a research‐oriented, PyTorch-based document image rectification tool (“DocScanner”).
• It provides code for training two neural modules (Document Localization and Progressive Rectification), running inference on distorted images, and evaluating results via image metrics (MS-SSIM, LD) and OCR metrics.
• There is no web front‐end in the repo (the online demo is external), so the focus is on data pipelines, model modules, and evaluation scripts.
File structure
• Top-level scripts:
• inference.py – main entry for rectifying images
• update.py – likely orchestrates model updates or training runs
• extractor.py, seg.py – preprocessing/segmentation utilities
• OCR_eval.py – runs OCR evaluation on rectified output
• eval.m, evalUnwarp.m – MATLAB scripts for image quality metrics
• Model definitions: model.py
• Data folders: distorted/ (input examples), rectified/ (inference output)
• Configuration: requirements.txt (Python deps), ocr_img.txt (OCR test set indices)
• No dedicated “src” folder—scripts and modules are all at project root.
Key insights from README
• Two main neural modules:
a. Document Localization Module (trained on Doc3D + DTD)
b. Progressive Rectification Module (trained on background-excluded Doc3D)
• Inference pipeline: load pre-trained weights from model_pretrained/, read from distorted/, write to rectified/
• Evaluation pipelines:
• Image metrics via MATLAB interface (ssim_ld_eval.m)
• OCR metrics via pytesseract in OCR_eval.py
• External dependencies: PyTorch/GPU, MATLAB 2019a+, Tesseract 5.x, Google Drive for data/model storage.