Amaan SurtiHealthcare AI & machine learning engineer
ResumeGujarati Math Solver
Photograph an equation handwritten in Gujarati numerals and it reads it and solves it. Built in a 20-hour hackathon where pretrained weights were banned.
- Built
- solo
- When
- May 2026, AI Laboratory hackathon
- Rule
- no pretrained weights, no transfer learning
- Stack
- PyTorch · OpenCV segmentation · self-collected dataset · Flask · React
The problem
૬ × ૪ − ૩ + ૨ = ૨૩. Easy to read, hard for a model with no pretrained weights and a dataset that didn't exist that morning.
What I built
Image in, answer out: grayscale and adaptive threshold, deskew, split into characters by connected components, classify each with a CNN, rebuild the expression and evaluate it safely. A Flask API runs the chain; a React front end takes an upload or a phone photo and switches between all seven trained models live.
Results
| Model | Training data | Test accuracy | Macro F1 |
|---|---|---|---|
| 01 Simple CNN | Raw | 95.54% | 96.27% |
| 02 Regularized CNN | Raw | 95.05% | 95.96% |
| 03 Simple CNN | Augmented | 94.99% | 95.44% |
| 04 Deep CNN | Augmented | 96.33% | 96.80% |
| 05 Residual CNN | Augmented | 96.46% | 96.97% |
| 06 Residual CNN, v2 data | Raw, hand-drawn | 96.59% | 96.80% |
| 07 Residual CNN, v2 data | Augmented, hand-drawn | 99.43% | 99.43% |
The jump from 05 to 07 came from fixing a domain gap: retraining on real hand-drawn characters, with colour jitter instead of geometric augmentation so digit shapes stayed intact.
Debugging
- 4K phone photos turned paper texture into noise: normalised height to 300 px and widened the threshold block.
- Notebook ruling lines were read as minus signs: filtered by aspect ratio and width.
- Ruling lines crossing the margin formed a giant "L" that a cleanup rule treated as a container, deleting every character: dropped hollow frames by pixel density.
- The ÷ sign's three strokes were merged back into one symbol before classification.
Code and records
Code and training scripts on GitHub. The dataset isn't in the repository because of its size.