nivashuggingface's picture
Upload README.md with huggingface_hub
1fc1197 verified

A newer version of the Gradio SDK is available: 5.25.2

Upgrade
metadata
title: Digit Recognition with CNN
emoji: πŸ”’
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: 4.19.2
app_file: app.py
pinned: false

Digit Recognition Model

This model is trained to recognize handwritten digits from the MNIST dataset.

Model Description

  • Model Type: CNN with Attention
  • Task: Image Classification
  • Input: 28x28 grayscale images
  • Output: Digit classification (0-9)

Training

The model was trained on the MNIST dataset using a CNN architecture with attention mechanisms.

Usage

import tensorflow as tf
import numpy as np

# Load the model
model = tf.saved_model.load('https://huggingface.co/nivashuggingface/digit-recognition/resolve/main/saved_model')

# Prepare input
image = tf.keras.preprocessing.image.load_img("digit.png", target_size=(28, 28))
image = tf.keras.preprocessing.image.img_to_array(image)
image = image.astype('float32') / 255.0
image = np.expand_dims(image, axis=0)

# Make prediction
predictions = model(image)
predicted_digit = tf.argmax(predictions, axis=1).numpy()[0]

AI Model Training Project

This project demonstrates a complete machine learning workflow from data preparation to model deployment, using the MNIST dataset with an innovative approach to digit recognition.

Project Structure

.
β”œβ”€β”€ data/                  # Dataset storage
β”œβ”€β”€ models/               # Saved model files
β”œβ”€β”€ src/                  # Source code
β”‚   β”œβ”€β”€ data_preparation.py
β”‚   β”œβ”€β”€ model.py
β”‚   β”œβ”€β”€ training.py
β”‚   β”œβ”€β”€ evaluation.py
β”‚   └── deployment.py
β”œβ”€β”€ notebooks/           # Jupyter notebooks for exploration
β”œβ”€β”€ requirements.txt     # Project dependencies
└── README.md           # Project documentation

Setup Instructions

  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Run the training pipeline:
python src/training.py

Project Features

  • Custom CNN architecture for robust digit recognition
  • Data augmentation techniques
  • Model evaluation and hyperparameter tuning
  • Model deployment pipeline
  • Performance monitoring

Learning Concepts Covered

  1. Data Preprocessing

    • Data loading and cleaning
    • Feature engineering
    • Data augmentation
  2. Model Architecture

    • Custom CNN design
    • Layer configuration
    • Activation functions
  3. Training Process

    • Loss functions
    • Optimizers
    • Learning rate scheduling
    • Early stopping
  4. Evaluation

    • Metrics calculation
    • Cross-validation
    • Model comparison
  5. Deployment

    • Model saving
    • Inference pipeline
    • Performance monitoring