A modern web application for classifying handwritten digits using a Convolutional Neural Network (CNN). This project provides both a user-friendly web interface and a REST API for digit classification.
-
Modern Web Interface
- Responsive design with Bootstrap 5
- Drag and drop image upload
- Real-time image preview
- Animated results display
- Mobile-friendly interface
-
Advanced Model
- CNN architecture with Batch Normalization
- Data augmentation for better generalization
- Early stopping and learning rate reduction
- High accuracy on MNIST dataset
-
API Support
- RESTful API endpoint for predictions
- JSON response format
- Error handling and status codes
- Python 3.8+
- TensorFlow 2.x
- Flask
- NumPy
- Pillow
- scikit-learn
- joblib
- Clone the repository:
git clone https://github.com/yourusername/handwritten-digit-classifier.git
cd handwritten-digit-classifier- Create a virtual environment and activate it:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install the required packages:
pip install -r requirements.txt- Train the model:
python Model2.0.py- Start the web application:
python app.py- Open your browser and navigate to
http://localhost:5000
The application provides a REST API endpoint for predictions:
curl -X POST -F "image=@path/to/image.png" http://localhost:5000/api/predictExample response:
{
"prediction": 7,
"confidence": 0.987654321
}handwritten-digit-classifier/
├── app.py # Flask application
├── Model2.0.py # Model training script
├── model.pkl # Trained model
├── static/
│ ├── style.css # Custom styles
│ ├── script.js # Client-side JavaScript
│ └── uploads/ # Uploaded images
├── templates/
│ └── index.html # Web interface template
└── README.md # Project documentation
The CNN model consists of:
- Two convolutional layers with Batch Normalization
- Max pooling layers
- Dropout for regularization
- Dense layers with ReLU activation
- Softmax output layer
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- MNIST dataset
- TensorFlow and Keras
- Flask web framework
- Bootstrap 5