Skip to content

About

Diigits Recognition is AI powered system which detect the human written digits and show prediction

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

ย 

History

9 Commits

Folders and files

Repository files navigation

๐Ÿ”ข Handwritten Digit Recognition โ€” MLOps Project

Python Streamlit Scikit-Learn Docker NumPy Pandas Pillow Matplotlib Git MLOps

๐Ÿ“Œ Project Overview

This project is a Handwritten Digit Recognition System built using Machine Learning and deployed as an interactive Streamlit web application.

The model is trained using the Scikit-learn Digits Dataset and uses a Support Vector Classifier (SVC) to classify handwritten digits from 0 to 9.

The project also demonstrates fundamental MLOps practices, including:

  • Machine Learning model training
  • Image preprocessing
  • Model serialization
  • Streamlit application
  • Logging
  • Docker containerization
  • Git/GitHub version control
  • Model evaluation
  • Hyperparameter configuration

๐Ÿš€ Features

  • โœ๏ธ Upload a handwritten digit image
  • ๐Ÿ–ผ๏ธ Image preprocessing and normalization
  • ๐Ÿ”ข Predict digits from 0 to 9
  • ๐Ÿค– SVC-based classification
  • ๐Ÿ“Š Classification report
  • โš™๏ธ Hyperparameter configuration
  • ๐Ÿ“ Application logging
  • ๐Ÿณ Dockerized application
  • ๐ŸŒ Interactive Streamlit UI
  • ๐Ÿ“ฆ Saved trained model using Pickle

๐Ÿง  Machine Learning Model

Algorithm

Support Vector Classifier (SVC)

SVC is a supervised machine learning algorithm that finds an optimal decision boundary between different classes.

For this project, the classifier is trained to recognize:

0  1  2  3  4  5  6  7  8  9

Dataset

The project uses the built-in:

Scikit-learn Digits Dataset

Dataset characteristics:

  • Number of classes: 10
  • Image size: 8 ร— 8
  • Total features: 64
  • Pixel values: approximately 0โ€“16
  • Classes: digits 0โ€“9

๐Ÿ”„ Machine Learning Pipeline

              Digits Dataset
                    โ”‚
                    โ–ผ
             Data Preparation
                    โ”‚
                    โ–ผ
             Train / Test Split
                    โ”‚
                    โ–ผ
             Feature Processing
                    โ”‚
                    โ–ผ
             SVC Model Training
                    โ”‚
                    โ–ผ
            Hyperparameter Tuning
                    โ”‚
                    โ–ผ
              Model Evaluation
                    โ”‚
                    โ–ผ
               model.pkl
                    โ”‚
                    โ–ผ
             Streamlit Application
                    โ”‚
                    โ–ผ
             Docker Container

๐Ÿ–ผ๏ธ Image Preprocessing

For uploaded real-world digit images, the application performs preprocessing before sending the image to the model.

The preprocessing pipeline includes:

Input Image
    โ†“
Grayscale Conversion
    โ†“
Image Inversion
    โ†“
Resize to 8 ร— 8
    โ†“
Pixel Normalization
    โ†“
Scale to 0โ€“16
    โ†“
Flatten to 64 Features
    โ†“
SVC Prediction

This preprocessing is important because the original Scikit-learn Digits Dataset contains small 8 ร— 8 images with pixel values in a similar range.


๐Ÿ“Š Model Evaluation

The trained SVC model is evaluated using classification metrics such as:

  • Accuracy
  • Precision
  • Recall
  • F1-score
  • Support

Classification Report

The generated classification report is available in the public directory.

![Classification Report](public/classification report.png)


โš™๏ธ Hyperparameters

The SVC model was trained and evaluated using selected hyperparameters.

The hyperparameter results/configuration are available below:

Hyperparameters

The hyperparameters can be modified and evaluated to find a better-performing model.


๐Ÿ› ๏ธ Tech Stack

Technology Purpose
Python Programming language
NumPy Numerical operations
Pandas Data manipulation
Scikit-learn Machine Learning
SVC Classification algorithm
Pillow Image processing
Matplotlib Visualization
Streamlit Web application
Pickle Model serialization
Docker Containerization
Git Version control
GitHub Source code management

๐Ÿ“ Project Structure

Digits/
โ”‚
โ”œโ”€โ”€ .dockerignore
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ requirements.txt
โ”‚
โ”œโ”€โ”€ main.py
โ”œโ”€โ”€ config.py
โ”œโ”€โ”€ model.pkl
โ”‚
โ”œโ”€โ”€ core/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ digits.py
โ”‚   โ””โ”€โ”€ logger.py
โ”‚
โ”œโ”€โ”€ public/
โ”‚   โ”œโ”€โ”€ classification_report.png
โ”‚   โ””โ”€โ”€ hyperparameters.png
โ”‚
โ””โ”€โ”€ logs/
    โ””โ”€โ”€ app.log

๐Ÿ’ป Local Installation

1. Clone the Repository

git clone <YOUR_GITHUB_REPOSITORY_URL>

Move into the project directory:

cd Digits

2. Create Virtual Environment

python3 -m venv venv

Activate the environment on Linux/macOS:

source venv/bin/activate

For Windows:

venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Run the Streamlit Application

streamlit run main.py

The application will be available at:

http://localhost:8501

๐Ÿณ Run with Docker

This project is containerized using Docker.

Build Docker Image

docker build -t digits-app .

Run Docker Container

docker run -p 8501:8501 digits-app

Then open:

http://localhost:8501

Docker Architecture

Dockerfile
     โ”‚
     โ–ผ
Docker Image
     โ”‚
     โ–ผ
Docker Container
     โ”‚
     โ–ผ
Streamlit Application
     โ”‚
     โ–ผ
Port 8501

๐Ÿ“ Logging

The application includes logging functionality for tracking application events.

Logs can contain information such as:

  • Model loading
  • Image preprocessing
  • Prediction status
  • Prediction result
  • Errors and exceptions

Example:

2026-09-15 16:00:00 - INFO - Digits model loaded
2026-09-15 16:00:05 - INFO - Starting image preprocessing
2026-09-15 16:00:05 - INFO - Image preprocessing completed
2026-09-15 16:00:06 - INFO - Prediction result: 7

Application logs are stored in:

logs/app.log

๐Ÿ”ฎ Future MLOps Improvements

The project can be extended into a complete production-oriented MLOps pipeline.

Planned improvements include:

  • GitHub Actions CI/CD
  • Automated unit testing
  • MLflow experiment tracking
  • DVC for dataset/model versioning
  • Model Registry
  • Automated Docker image publishing
  • Cloud deployment
  • Model monitoring
  • Data drift detection
  • Model performance monitoring
  • Automated model retraining

๐Ÿ“ˆ MLOps Roadmap

Machine Learning
       โ”‚
       โ–ผ
Model Serialization
       โ”‚
       โ–ผ
Streamlit Application
       โ”‚
       โ–ผ
Logging
       โ”‚
       โ–ผ
Docker
       โ”‚
       โ–ผ
Git / GitHub
       โ”‚
       โ–ผ
CI/CD โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
       โ”‚              โ”‚
       โ–ผ              โ–ผ
   MLflow             DVC
       โ”‚              โ”‚
       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
              โ–ผ
        Model Registry
              โ”‚
              โ–ผ
          Deployment
              โ”‚
              โ–ผ
         Monitoring
              โ”‚
              โ–ผ
         Retraining

๐Ÿ‘จโ€๐Ÿ’ป Author

Muhammad Haseeb Raza

Machine Learning Engineer

๐Ÿ“ง Email: hasiraza511@gmail.com

Areas of Interest

  • Machine Learning
  • Deep Learning
  • Computer Vision
  • MLOps
  • Model Deployment
  • Python
  • Data Science

โญ Project

If you find this project useful, feel free to โญ star the repository and explore the code.


๐Ÿ“„ License

This project is created for educational and portfolio purposes.

About

Diigits Recognition is AI powered system which detect the human written digits and show prediction

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages