This is a PaddlePaddle implementation of DocTr++. The original paper is DocTr++: Deep Unrestricted Document Image Rectification. The original code is here.
You need to install the latest version of PaddlePaddle, which is done through this link.
- Data Preparation
To prepare datasets, refer to doc3D.
- Training
sh train.sh
or
export OPENCV_IO_ENABLE_OPENEXR=1
export CUDA_VISIBLE_DEVICES=0
python train.py --img-size 288 \
--name "DocTr++" \
--batch-size 12 \
--lr 2.5e-5 \
--exist-ok \
--use-vdl
- Load Trained Model and Continue Training
export OPENCV_IO_ENABLE_OPENEXR=1
export CUDA_VISIBLE_DEVICES=0
python train.py --img-size 288 \
--name "DocTr++" \
--batch-size 12 \
--lr 2.5e-5 \
--resume "runs/train/DocTr++/weights/last.ckpt" \
--exist-ok \
--use-vdl
Test the dewarp result on a single image:
python predict.py -i "crop/12_2 copy.png" -m runs/train/DocTr++/weights/best.ckpt -o 12.2.png
pip install paddle2onnx
python export.py -m ./best.ckpt --format onnx
The trained model can be downloaded from here.