A Pytorch implementation of Two-Stage Generative Adversarial Networks for Document Image Binarization described in the paper:
- Two-stage Generative Adversarial Networks for Document Image Binarization : arxiv version
- Two-stage generative adversarial networks for binarization of color document images : published version
Abstract
Document image enhancement and binarization methods are often used to improve the accuracy and efficiency of document image analysis tasks such as text recognition. Traditional non-machine-learning methods are constructed on low-level features in an unsupervised manner but have difficulty with binarization on documents with severely degraded backgrounds. Convolutional neural network (CNN)––based methods focus only on grayscale images and on local textual features. In this paper, we propose a two-stage color document image enhancement and binarization method using generative adversarial neural networks. In the first stage, four color-independent adversarial networks are trained to extract color foreground information from an input image for document image enhancement. In the second stage, two independent adversarial networks with global and local features are trained for image binarization of documents of variable size. For the adversarial neural networks, we formulate loss functions between a discriminator and generators having an encoder--decoder structure. Experimental results show that the proposed method achieves better performance than many classical and state-of-the-art algorithms over the Document Image Binarization Contest (DIBCO) datasets, the LRDE Document Binarization Dataset (LRDE DBD), and our shipping label image dataset.
The performance of each model
H-DIBCO 2016 | FM | p-FM | PSNR | DRD | |
Otsu | 86.59 | 89.92 | 17.79 | 5.58 | |
Niblack | 72.57 | 73.51 | 13.26 | 24.65 | |
Sauvola | 84.27 | 89.10 | 17.15 | 6.09 | |
Vo | 90.01 | 93.44 | 18.74 | 3.91 | |
He | 91.19 | 95.74 | 19.51 | 3.02 | |
Zhao | 89.77 | 94.85 | 18.80 | 3.85 | |
Ours | 92.24 | 95.95 | 19.93 | 2.77 |
Evaluation of binarization | OCR accuracy in Levenshetin distance | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
- Linux (Ubuntu)
- Python >= 3.6
- NVIDIA GPU + CUDA CuDNN
- Install PyTorch
- Install segmentation_models
- Install pytesseract
- download tesseract data
- For Conda users, you can create a new Conda environment using
conda env create -f environment.yml
- For Conda users, you can create a new Conda environment using
(In the case of dibco)
python3 ./Common/make_ground_truth_dibco.py
python3 ./Common/make_ground_truth_512_dibco.py
- Train a model per datasets
(In the case of Label)
1) sh ./Label/train_5_fold_step1.sh
2) sh ./Label/predict_for_step2_5_fold.sh
3) sh ./Label/train_5_fold_step2.sh
4) sh ./Label/train_5_fold_resize.sh
- Evaluate the model per datasets
(In the case of Label)
sh ./Label/predict_step2_5_fold.sh
- Trained weights
- You can download trained weights from Dropbox. The link of the files as follows.
- Link