Text recognition for seven segment display using keras-ocr.
OCR for seven segment display using tensorflow lite.
The trained keras model is converted to tensorflow lite model model_float16.tflite
- Clone the repo locally
git clone https://github.com/renjithsasidharan/seven-segment-ocr
- Install dependencies
pip install requirements.txt
Training data is present in data/ocr_training_data
data/ocr_training_data
├── 00498afd-2925-45ef-bfb3-8c55204ace42.png
├── 011fd0b2-837c-424c-a71b-a2a92305a532.png
├── 04976571-ac6b-425f-9474-3b95a4fb9613.png
├── 068e4ff1-acf0-43e7-b052-7a59a9c3f87b.png
Ground truth file is data/ocr_training_data/gt.txt
You can create more training data by first creating annotations and then creating training data from annotations
- Add images to
data/annotations
folder. - Install annotation tool
PPOCRLabel
from https://github.com/PaddlePaddle/PaddleOCR/tree/release/2.4/PPOCRLabel - Open
PPOCRLabel
and start annotating new images.
From seven-segment-ocr
directory run the command
python create_ocr_training_data_from_annotations.py
This will append the training data to data/ocr_training_data
Train the model using jupyter notebook keras_ocr_7_seg.ipynb
- Upload the notebook
keras_ocr_7_seg.ipynb
to google Colab - Create archive of folder
data/ocr_training_data
. - Upload
ocr_training_data.zip
to google Colab - Run the training
- Once the training is over, your trained model
meeter_rec_float16.tflite
will be automatically downloaded to your machine from Colab
To run prediction on an image using tensorflow lite
python predict.py --image test/1.png --model model_float16.tflite
To run predictions on all images in directory
python eval_tflite.py --eval_dir /data/ocr_training_data
Here are some results of ocr extraction:
Confusion matrix