How nnaajjeebb12/hw-recog works
This repository is a small TrOCR-based tool for training a text recognizer on labeled image crops and using it to transcribe new images. The main workflow is: prepare image/label data, train and validate a model, then run prediction to produce a CSV. Training also supports held-out testing and optional image augmentation; prediction supports pattern-constrained retries. The README documents these capabilities, while the source excerpts show their implementation is concentrated in two scripts. Full-page cropping is explicitly outside the product.
Main entry points: train.py Model fine-tuning · predict.py TextReader
Components 15
Training
- Data preparation
train.py - Image cache
train.py - Image augmentation
train.py - Model fine-tuning
train.py - Validation and selection
train.py - Held-out testing
train.py - Saved model
train.py
Inference
- Image discovery
predict.py - TextReader
predict.py - Pattern retry
predict.py - Prediction CSV
predict.py
Model integration
- Hugging Face model
Other components
- User
- Labeled image data
- Input image folder
Connections 18
- User → Labeled image data: provides
README.md - Labeled image data → Data preparation: loads labels
README.md - Data preparation → Image cache: caches images
README.md - Data preparation → Model fine-tuning: supplies splits
README.md - Image augmentation → Model fine-tuning: augments batches
train.py - Image cache → Model fine-tuning: loads cached images
train.py - Model fine-tuning → Validation and selection: scores each epoch
README.md - Validation and selection → Saved model: saves best
README.md - Model fine-tuning → Held-out testing: scores test set
README.md - Hugging Face model → Model fine-tuning: initializes from
README.md - User → Input image folder: provides images
README.md - Input image folder → Image discovery: scans files
predict.py - Saved model → TextReader: loads model
predict.py - Image discovery → TextReader: batches images
predict.py - TextReader → Pattern retry: retries mismatches
predict.py - TextReader → Prediction CSV: writes results
predict.py - Pattern retry → Prediction CSV: updates results
predict.py - Prediction CSV → User: returns readings
README.md