How sanny26/indic-htr works
Main Components
a. Data Preparation & Datasets:
• The README explains that LMDB files must be created for train/validation/test splits. The datasets directory (with files such as dataset.py, ae_transforms.py, label_transform.py, etc.) shows the preprocessing pipeline, including data transformations (e.g., skew transforms, grid distortions) specific to handling handwriting images.
• The alphabet folder contains language-specific alphabet text files that supply the Unicode symbols needed for prediction.
b. Model Architectures:
c. Training and Evaluation:
• Training scripts are found as base_train.py and lang_train.py. The README describes how to run training and testing modes.
• There are also tools scripts for creating datasets (tools/create_dataset.py) and for scoring predictions (tools/score.py and tools/oov_score.py) to check error rates (WER/CER).
d. Configuration and Utilities:
• Files like config.py and utils.py handle hyperparameters and common functions.
• The pyproject.toml file and the LICENSE file give further project management and legal context.
Relationships and Interactions
• Input -> Data Preparation: Data flows from raw images (arranged per the dataset structure) through the dataset module, where image transforms are applied.
• The preprocessed data and the alphabet text comprise the inputs for training; your training scripts (lang_train.py) call the dataset functions.
• The model components (from the models folder) are dynamically loaded by the training scripts and layered to form the recognition pipeline.
• Once the model processes inputs, outputs are evaluated through scoring tools.
• There is a clear dependency between components—for example, the datasets provide the critical data preparing stage that feeds directly into the training routines, which in turn use the model definitions.
Architectural Patterns and Design Principles
• The project employs a modular design with separation of concerns: (a) data handling in the datasets directory, (b) network modeling with separated files for different model types and submodules in the models directory, and (c) explicit training control via dedicated training scripts.
• Design principles include a pipeline-based approach: Data → Preprocessing → Model Inference → Loss/CTC Evaluation → Scoring.
• It follows extensibility patterns so that components (e.g., adding more language alphabets or new data transforms) can be updated independently.
Technologies and Frameworks
• Deep learning frameworks (likely PyTorch given similar open-source projects mentioned) form the backbone.
• LMDB is used for dataset storage and retrieval.
• External libraries might include image processing libraries (e.g., OpenCV or PIL) in the dataset transforms.
• The training process leverages CUDA if available.