Fine-tuning Tesseract OCR for Ghana ECG postpaid electricity meter reading extraction — includes preprocessing, annotation, augmentation, training, evaluation, and a Flask inference API.
# ECG Postpaid Meter Readings — Tesseract OCR Fine-Tuning Pipeline
A robust, end-to-end pipeline for training/retraining a Tesseract OCR model
specifically optimised for Ghana ECG (Electricity Company of Ghana) postpaid
meter reading images.
---
## Table of Contents
1. Project Structure
2. Quick Start
3. Makefile Reference
4. Pipeline Phases
5. Configuration
6. Scripts Reference
7. Notebooks
8. Evaluation
9. Troubleshooting
10. System Overview
---
## Project Structure
```
ecg-ocr-project/
├── Makefile # Convenient shortcuts for all pipeline operations (make help)
├── raw_images/ # Original meter reading photos
├── preprocessed/ # Cleaned/deskewed images ready for OCR
├── ground_truth/ # .gt.txt label files (paired with .tif)
├── augmented/ # Synthetically augmented images
├── eval_data/ # Holdout test set (auto-populated by 04_prepare_training_data.py)
├── corrections/ # Human-corrected samples for iterative retraining
├── results/ # Inference outputs, CSV reports, test_set.txt
├── models/
│ └── ecg_meter/
│ └── tessdata/ # Final .traineddata model installed here
├── tesstrain/ # git submodule — owns all training internals
│ └── data/
│ └── ecg_meter-ground-truth/ # ← 04_prepare_training_data.py writes here
├── ecg-meter-api/ # Production REST API
│ ├── app.py # Flask application
│ ├── ocr.py # OCR engine wrapper
│ └── model/ # Trained model (.traineddata)
├── scripts/ # All pipeline scripts
├── config/ # YAML configs
├── logs/ # Training logs, CER curves
├── notebooks/
│ └── ecg_ocr_analysis.ipynb # Interactive dataset analysis & preprocessing visualisation
├── tests/ # Unit tests
└── docs/ # Additional documentation
```
---
## Quick Start
```bash
# 1. Clone the repo with the tesstrain submodule
git clone --recurse-submodules
cd ecg-ocr-proj …