Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/himanshkr03/mnist-handwritten-digit-classification
This repository contains a Python implementation of a handwritten digit classification model using a Convolutional Neural Network (CNN) trained on the MNIST dataset. The model achieves high accuracy and can be used for various applications.
https://github.com/himanshkr03/mnist-handwritten-digit-classification
cnn-classification deep-learning image-classification keras machine-learning mnist-handwriting-recognition python tensorflow
Last synced: 9 days ago
JSON representation
This repository contains a Python implementation of a handwritten digit classification model using a Convolutional Neural Network (CNN) trained on the MNIST dataset. The model achieves high accuracy and can be used for various applications.
- Host: GitHub
- URL: https://github.com/himanshkr03/mnist-handwritten-digit-classification
- Owner: himanshkr03
- License: mit
- Created: 2024-12-31T15:58:58.000Z (26 days ago)
- Default Branch: main
- Last Pushed: 2025-01-01T17:45:47.000Z (25 days ago)
- Last Synced: 2025-01-17T00:17:51.063Z (9 days ago)
- Topics: cnn-classification, deep-learning, image-classification, keras, machine-learning, mnist-handwriting-recognition, python, tensorflow
- Language: Jupyter Notebook
- Homepage:
- Size: 71.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Handwritten Digit Classification using Deep Learning
This project showcases the creation and implementation of a Convolutional Neural Network (CNN) to classify handwritten digits (0-9) using the MNIST dataset.
## **Project Overview**
The objective of this project is to build a CNN using TensorFlow and Keras to classify handwritten digit images from the MNIST dataset. The model achieves high accuracy and demonstrates its potential in digit recognition tasks.
## **Dataset**
The MNIST dataset serves as the benchmark dataset for this project. It includes:
- **Training Set:** 60,000 grayscale images of handwritten digits.
- **Testing Set:** 10,000 grayscale images for evaluation.
- **Image Size:** 28x28 pixels.
- **Labels:** Numerical digits from 0 to 9.Each image represents a single digit and is normalized to simplify the processing.
## **Model Architecture**
The CNN model is carefully designed to balance accuracy and computational efficiency. Key layers include:
1. **Convolutional Layers**
- Extract spatial features from images.
- Learn hierarchical feature representations.2. **Activation Functions**
- **ReLU:** Introduces non-linearity, enabling the model to learn complex patterns.3. **Pooling Layers**
- **Max Pooling:** Reduces spatial dimensions to lower computational overhead and avoid overfitting.4. **Fully Connected Layers**
- Map extracted features to digit classifications.5. **Output Layer**
- Consists of 10 neurons (0–9 digits).
- **Softmax Activation:** Produces probability distributions for each class.## **Training**
### **Approach**
- **Optimizer:** Adam optimizer ensures faster convergence.
- **Loss Function:** Sparse categorical cross-entropy measures prediction error.
- **Validation:** A validation split is used to monitor model performance during training.### **Steps**
- Normalize pixel values to range [0, 1].
- Split the data into training and testing sets.
- Train the model over multiple epochs with validation data.## **Evaluation**
The trained model is assessed on the test dataset. Metrics used include:
- **Accuracy:** Measures correct classifications.
- **Loss:** Quantifies the discrepancy between predictions and true labels.## **Usage Instructions**
### **Steps to Classify a New Image**
1. Load the model:
```python
model = keras.models.load_model("model_path.h5")
```
2. Preprocess the input:
Resize image to 28x28 pixels.
Normalize pixel values to [0, 1].
3. Predict the digit:
```python
prediction = model.predict(preprocessed_image)
predicted_digit = np.argmax(prediction)
```
# Results
This section presents a comprehensive analysis of the performance achieved by the Handwritten Digit Classification model.### Performance Metrics
The model's performance is evaluated using key metrics:
* **Accuracy:** The model achieved an impressive accuracy of approximately 98% on the unseen test dataset. This indicates its ability to classify a vast majority of handwritten digits correctly.
* **Loss:** A low loss value on the test set further confirms the model's strong performance. The loss function quantifies the difference between predicted and actual labels, suggesting accurate predictions.### Visualization and Insights
* **Training Accuracy & Loss Plots:** These visualizations illustrate the model's learning progress during training. Accuracy steadily increased while loss decreased over epochs, demonstrating effective learning from the training data.
* **Confusion Matrix:** This detailed breakdown highlights correct and misclassified predictions for each digit class. Ideally, high values along the diagonal represent accurate classifications, while low off-diagonal values indicate minimal misclassifications.### Generalization Capability
The model's high accuracy and low loss on the test dataset signify its excellent generalization ability. It has successfully learned the underlying patterns of handwritten digits, enabling accurate classification of new, unseen instances.
# Future Enhancements
- **Hyperparameter Optimization:** Experiment with different architectures, learning rates, and optimizers.
- **Data Augmentation:** Increase robustness with augmented training samples.
- **Real-world Integration:** Utilize in form digitization, postal code reading, or license plate recognition.
- **Deployment:** Build a web application or REST API for practical usage.## 👋 HellO There! Let's Dive Into the World of Ideas 🚀
Hey, folks! I'm **Himanshu Rajak**, your friendly neighborhood tech enthusiast. When I'm not busy solving DSA problems or training models that make computers *a tad bit smarter*, you’ll find me diving deep into the realms of **Data Science**, **Machine Learning**, and **Artificial Intelligence**.
Here’s the fun part: I’m totally obsessed with exploring **Large Language Models (LLMs)**, **Generative AI** (yes, those mind-blowing AI that can create art, text, and maybe even jokes one day 🤖), and **Quantum Computing** (because who doesn’t love qubits doing magical things?).
But wait, there's more! I’m also super passionate about publishing research papers and sharing my nerdy findings with the world. If you’re a fellow explorer or just someone who loves discussing tech, memes, or AI breakthroughs, let’s connect!
- **LinkedIn**: [Himanshu Rajak](https://www.linkedin.com/in/himanshu-rajak-22b98221b/) (Professional vibes only 😉)
- **Medium**: [Himanshu Rajak](https://himanshusurendrarajak.medium.com/) (Where I pen my thoughts and experiments 🖋️)Let’s team up and create something epic. Whether it’s about **generative algorithms** or **quantum wizardry**, I’m all ears—and ideas!
🎯 Ping me, let’s innovate, and maybe grab some virtual coffee. ☕✨