A Digit Recognition Flask-based Web Application that utilizes a Convolutional Neural Network (CNN) model, trained on the MNIST dataset, to recognize handwritten digits drawn by the user. It showcases the integration of a PyTorch machine learning model with a web frontend, allowing for real-time digit recognition.
- Real-time Digit Recognition: Users can draw a digit on the canvas, and the application predicts which digit it is.
- PyTorch Integration: Utilizes a CNN model built and trained using PyTorch, demonstrating how machine learning models can be integrated into web applications.
- Flask Backend: A lightweight Flask application serves as the backend, handling image processing and model inference.
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Before you begin, ensure you have the following installed:
- Python 3.6 or higher
- pip and venv
-
Clone the repository:
git clone https://github.com/txhno/digit-recognition-app.git
-
Navigate to the project directory:
cd digit-recognition-app
-
Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
Before running the Flask application, you need to train the CNN model using the MNIST dataset. This step creates the mnist_cnn.pth
file, which the Flask app uses to predict digits.
- Ensure you are still in the project's root directory.
- Run the training script:
This script will train the model and save it to the file
python train.py
mnist_cnn.pth
in the project directory.
-
Run the Flask application:
python app.py
-
Open a web browser and navigate to
http://localhost:5000
to access the application. -
Use the canvas to draw a digit (0-9) and click "Submit" to see the model's prediction.
- PyTorch - The machine learning framework used for building the CNN model.
- Flask - The web framework used for the application backend.
- HTML/CSS/JavaScript - Used for the frontend interface.
- Roshan Warrier - Initial work - txhno
This project is licensed under the MIT License - see the LICENSE.md file for details.