Skip to content

iot-lab-kiit/handwritten-math-solver

Repository files navigation

✍️ Handwritten Math Solver

A Flask application that uses OCR + CNN to recognize handwritten digits and math operators from an image, reconstruct the expression, and safely evaluate it (no insecure eval()).


📸 Example

image-1

➡️ The app predicts 2+3*4 and computes the result: = 14.


🔧 Features

  • 🖼️ Image preprocessing with OpenCV
  • 🔤 CNN model (Keras/TensorFlow) for digit/operator recognition
  • 🧮 Safe arithmetic evaluator (no arbitrary code execution)
  • 🌐 Flask API endpoint /predict for uploads
  • ✅ Unit tests and GitHub Actions CI

⚡ Quick Start

Option 1: Using Docker (Recommended)

Prerequisites

  • Docker installed on your system

Steps

  1. Clone the repository

    git clone https://github.com/iot-lab-kiit/handwritten-math-solver.git
    cd handwritten-math-solver
  2. Add model files
    Place your trained model files in the model/ folder:

    • model/model.json
    • model/model_weights.h5
  3. Build the Docker image

    docker build -t handwritten-math-solver .
  4. Run the container

    docker run -p 5000:5000 handwritten-math-solver
  5. Access the app
    Visit http://localhost:5000


Option 2: Local Setup

1. Clone & install

git clone https://github.com/iot-lab-kiit/handwritten-math-solver.git
cd handwritten-math-solver
python -m venv venv
source venv/bin/activate   # or venv\Scripts\activate on Windows
pip install -r requirements.txt

2. Add model files

Place your trained model files in the model/ folder:

  • model/model.json
  • model/model_weights.h5

3. Run the server

python app.py

Visit http://127.0.0.1:5000.


🤝 Contributing

We welcome contributions!
Check issues labeled “good first issue” or “help wanted” if you’re new.

Ways to help:

  • Improve preprocessing or recognition
  • Add more operators or equation solving
  • Write more tests
  • Improve docs or CI/CD pipeline

See contributing.md for details.


📚 Tech Stack

  • Python 3.9+
  • Flask
  • TensorFlow / Keras
  • OpenCV
  • NumPy / Pillow
  • Pytest
  • GitHub Actions

📄 License

MIT License — see LICENSE

About

A Flask app that uses OCR to recognize handwritten math and evaluate it.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors