Quick Start Guide

Installation

UNAGI requires Python 3.5+.

The current development version is available on Gitlab. Use git and python setup.py to install it:

Getting UNAGI is super easy, just clone it from gitlab and install the latest stable version by doing:

git clone https://gitlab.com/vkolagotla/UNAGI
cd UNAGI
python setup.py install

Features

  • Create training dataset.
  • Train a U-net model.
  • Binarize an image with the saved model.

Example Usage

Following code block shows how to use some of unagi package modules

# import unagi package
import unagi

# create the input train data for the model
# dataset method takes "input_dir" as input and saves the images and
# their respective binary masks into "output_dir"
unagi.dataset(input="input_dir", output="output_dir")

# uses the images in "train_img_dir" to train the network and saves the weights
# in "weights" folder in the current directory
# "vis_img_dir" folder is used to observe the training process with some sample images
# where the model is tested for each best saved model weights
unagi.train(input="train_img_dir", vis="vis_img_dir")

# converts all the images in "input_img_dir" to binary images with the model
# available in weights folder and saves the binary images into "output_dir_to_save_imgs"
unagi.binarize(input="input_img_dir", output="output_dir_to_save_imgs")

Tips

Tip

Use Focal loss as a loss funciton if you are planning on training the model.

Tip

Handwritten text can be suppressed from typewritten documents with proper training data.

Tip

Make sure that the input image and ground truth image are aligned on character level without any shifts.

Notes

Note

Pretrained model weights are taken from Robin.

Warnings

Warning

The pretrained model is trained on both handwritten and printed text. This could result in washing out of text after binarization for some type of documents such as old typewritten documents.