https://github.com/enesgunumdogdu/cnn.improvements
This project implements a Convolutional Neural Network (CNN) for digit classification with an interactive web interface. Users can draw digits and get real-time predictions from the trained model.
https://github.com/enesgunumdogdu/cnn.improvements
cnn flask keras python
Last synced: 2 months ago
JSON representation
This project implements a Convolutional Neural Network (CNN) for digit classification with an interactive web interface. Users can draw digits and get real-time predictions from the trained model.
- Host: GitHub
- URL: https://github.com/enesgunumdogdu/cnn.improvements
- Owner: enesgunumdogdu
- Created: 2025-05-03T17:40:11.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-04T20:35:18.000Z (about 1 year ago)
- Last Synced: 2025-05-07T00:51:39.237Z (about 1 year ago)
- Topics: cnn, flask, keras, python
- Language: HTML
- Homepage: https://enesgunumdogdu.com.tr/
- Size: 2 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# 🎨 Interactive Digit Classifier with CNN
A web-based digit recognition system powered by deep learning. This project implements a Convolutional Neural Network (CNN) trained on the MNIST dataset, featuring an interactive drawing canvas for real-time digit classification.

## 📋 Table of Contents
- [Overview](#overview)
- [Features](#features)
- [Technology Stack](#technology-stack)
- [Model Architecture](#model-architecture)
- [Installation](#installation)
- [Usage](#usage)
- [Project Structure](#project-structure)
- [License](#license)
## 🎯 Overview
This project demonstrates handwritten digit recognition using deep learning. It uses a CNN model trained on the MNIST dataset with a Flask web interface where users can draw digits and get predictions.
## ✨ Features
- **Interactive Drawing Canvas**: Draw digits with your mouse
- **CNN Model**: Trained on MNIST dataset for digit classification (0-9)
- **Real-time Predictions**: Get instant predictions as you draw
- **Confidence Scores**: Displays confidence percentage for each prediction
- **Error Handling**: Returns a message when the drawing is not clear (confidence < 50%)
- **Clear Button**: Reset the canvas to draw again
## 🛠️ Technology Stack
- **Flask** - Web framework for the application
- **TensorFlow/Keras** - Deep learning framework for model training
- **NumPy** - Numerical operations
- **Pillow** - Image processing
- **HTML5 Canvas** - Drawing interface
- **JavaScript** - Client-side interaction
## 🏗️ Model Architecture
The CNN model consists of the following layers:
```
Input Layer (28x28x1)
↓
Conv2D (32 filters, 3x3, ReLU)
↓
MaxPooling2D (2x2)
↓
Conv2D (64 filters, 3x3, ReLU)
↓
MaxPooling2D (2x2)
↓
Conv2D (64 filters, 3x3, ReLU)
↓
Flatten
↓
Dense (64 units, ReLU)
↓
Dropout (0.5)
↓
Dense (10 units, Softmax)
```
**Training Configuration:**
- Optimizer: Adam (learning_rate=0.001)
- Loss: categorical_crossentropy
- Epochs: 20
- Batch Size: 64
- Validation Split: 0.2
## 📦 Installation
1. Clone the repository:
```bash
git clone https://github.com/your-username/CNN.Improvements.git
cd CNN.Improvements
```
2. Install dependencies:
```bash
pip install -r requirements.txt
```
## 🚀 Usage
1. Train the model:
```bash
python test.py
```
This will train the CNN model and save it as `mnist_model.h5`.
2. Start the Flask application:
```bash
python app.py
```
3. Open your browser and go to `http://localhost:5000`
4. Draw a digit (0-9) on the canvas and see the prediction with confidence score. Click "Clear" to reset.
## 📁 Project Structure
```
CNN.Improvements/
│
├── app.py # Flask web application
├── test.py # Model training script
├── requirements.txt # Python dependencies
├── mnist_model.h5 # Trained model file (generated after running test.py)
├── Readme.md # Documentation
│
└── templates/
└── index.html # Web interface with drawing canvas
```