Skip to content

6. Predictions using our Trained models

nimishasri edited this page Jan 16, 2021 · 6 revisions

Predictions on test images

Install tensorflow-model-serving

sudo apt-get update

sudo apt-get install tensorflow-model-server

sudo apt install libgirepository1.0-dev

If you dont't have access to sudo, try this command for installing tensorflow-model-server:

wget 'http://storage.googleapis.com/tensorflow-serving-apt/pool/tensorflow-model-server/t/tensorflow-model-server/tensorflow-model-server_2.1.0_all.deb' dpkg -i tensorflow-model-server_2.1.0_all.deb

Make sure you have the samples directory with sample images in the 'get_predictions' folder. Also, please ensure that your images are entire lines or entire pages in the directory

cd get_predictions

conda create --name predictions python=3.6

conda activate predictions

pip install -r requirements.txt

mkdir samples

We are doing line segmentation on page using Tesseract. You need to download traineddata file for Devanagari script from here : Devanagari Tessdata

or, you can do :

wget https://github.com/tesseract-ocr/tessdata_best/blob/master/script/Devanagari.traineddata

mkdir -p /usr/share/tesseract-ocr/4.00/tessdata

export TESSDATA_PREFIX=/usr/share/tesseract-ocr/4.00/tessdata

mv Devanagari.traineddata /usr/share/tesseract-ocr/4.00/tessdata

Place your images in get_predictions/samples directory.

The exported models can be found here:

Pretrained on Synthetic data Attention LSTM

Extract the models that you want to use in the get_predictions directory.

bash predictions.sh line <model-type>

for line images.

bash predictions.sh page <model-type>

for page images.

Replace the model-type with the exported model directory you want to use for predictions(Exported models can be obtained using above links).

bash predictions.sh line c3_attention

The output text files will be obtained in get_predictions/sample_outputs folder.