https://github.com/dhruvbavaliya13/handwritten-digit-predictor
π’ Handwritten Digit Predictor A real-time digit recognition web app using a trained KNN model. Draw a digit on the canvas, and the app predicts it instantly using Flask, OpenCV, and scikit-learn. Perfect for showcasing ML + web integration! π
https://github.com/dhruvbavaliya13/handwritten-digit-predictor
flask html js machine-learning pyhton
Last synced: about 2 months ago
JSON representation
π’ Handwritten Digit Predictor A real-time digit recognition web app using a trained KNN model. Draw a digit on the canvas, and the app predicts it instantly using Flask, OpenCV, and scikit-learn. Perfect for showcasing ML + web integration! π
- Host: GitHub
- URL: https://github.com/dhruvbavaliya13/handwritten-digit-predictor
- Owner: DhruvBavaliya13
- Created: 2025-04-09T04:24:28.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-09T05:02:03.000Z (about 1 year ago)
- Last Synced: 2025-04-09T05:27:40.966Z (about 1 year ago)
- Topics: flask, html, js, machine-learning, pyhton
- Language: Jupyter Notebook
- Homepage:
- Size: 0 Bytes
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ποΈ Handwritten Digit Predictor
Welcome to the **Handwritten Digit Predictor** repository! This project uses a **K-Nearest Neighbors (KNN)** algorithm to recognize digits drawn by the user. It combines **machine learning** with a **Flask-based web interface**, allowing users to interactively test handwritten digit predictions.
## π Project Overview
This project aims to:
- π§ Train a **KNN model** to classify handwritten digits using image data.
- π¨ Provide a **web interface** where users can draw digits.
- π Predict digits in real-time with visual feedback.
## π Dataset
The model is trained on the **Sklearn Digits Dataset**, which contains:
- 8x8 grayscale images of handwritten digits (0β9)
- Corresponding labels for each image
## π οΈ Tech Stack
- **Programming Language**: Python π
- **Libraries Used**:
- `Flask` β to create the web application
- `NumPy` β for numerical operations
- `OpenCV` β for image preprocessing
- `scikit-learn` β for training and saving the KNN model
## π Project Structure
1. π§ͺ **Model Training** (`Model_selection.ipynb`) β Trains and evaluates the KNN model
2. π§ **Model Deployment** β Saved as `knn_model.pkl`
3. π **Web App** (`app.py`) β Flask app to take user input and make predictions
4. πΌοΈ **Frontend** β HTML/JS canvas for drawing digits (`templates/index.html`)
## π How to Run
1. Clone this repository:
```sh
git clone https://github.com/DhruvBavaliya13/handwritten-digit-predictor.git
cd handwritten-digit-predictor
```
2. Install dependencies:
```sh
pip install -r requirements.txt
```
3. Run the Flask app:
```sh
python app.py
```
4. Open your browser and go to:
```
http://127.0.0.1:5000/
```
## βοΈ How It Works
- Use your mouse to draw a digit on the canvas
- Click **Predict**
- The KNN model processes the input and returns the predicted digit
## πΈ Sample Interface

## π€ Contributing
Feel free to **fork** this repository and submit a pull request if you have ideas to improve the model or the UI!
## π¬ Contact
For any queries or collaboration opportunities, reach out via:
π§ Email: [drbavaliya13@gmail.com](mailto:drbavaliya13@gmail.com)
---
β If you find this project useful, donβt forget to **star** this repository! β