Loading repository data…
Loading repository data…
Pranshu936 / repository
A Flask web application that predicts handwritten digits. Users can either draw digits on a canvas or upload an image. The app uses a pre-trained machine learning model (e.g., MNIST) to make predictions. This project combines Flask, machine learning, and interactive web features for real-time digit recognition.
This web application, built with Flask, predicts handwritten digits either drawn on a canvas or uploaded as an image. It uses a machine learning model to recognize the digit and display the prediction.
handwritten-digit-prediction/
├── app.py # Main Flask application file
├── model.py # File to load and predict using the ML model
├── digit_model.h5 # Pre-trained model for digit prediction
├── static/
│ └── js/
│ └── script.js # JavaScript for canvas functionality and form actions
└── templates/
└── index.html # HTML file containing the frontend
app.pyThe main Flask application file. It contains routes for:
index.html page.model.pyThis file contains the logic to load the pre-trained model (digit_model.h5) and predict the digits.
digit_model.h5A pre-trained model, for example, a neural network trained on the MNIST dataset, used for digit prediction.
static/js/script.jsJavaScript file for handling:
templates/index.htmlThe HTML structure for the frontend. It includes:
Clone the repository to your local machine:
git clone <repository_url>
cd handwritten-digit-prediction
It's recommended to create a virtual environment to manage the dependencies:
python -m venv venv
source venv/bin/activate # On Windows, use venv\Scripts\activate
Install the necessary packages using pip:
pip install Flask tensorflow numpy
Run the Flask application:
python app.py
The app will be available at http://127.0.0.1:5000/ in your browser.
Choose the Mode:
Clear: Click the "Clear" button to reset the canvas if you're using the drawing mode.
Predict: After drawing a digit or uploading an image, click the "Predict" button to predict the digit.
Result: The predicted digit will be shown below the buttons.
Drawing Mode: When a user draws a digit, the JavaScript captures the canvas data. This data is sent to the Flask backend, which uses the machine learning model to predict the digit.
Image Mode: When a user uploads an image, it is sent to the backend, where the image is processed and passed through the prediction model to identify the digit.