An open API service indexing awesome lists of open source software.

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.

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.

![image](https://github.com/user-attachments/assets/3db0ee60-03d2-4b06-ab22-72a1e940685a)

## 📋 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
```