Spaces:
Runtime error
Runtime error
| 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 | |
| ```python | |
| 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: | |
| ```bash | |
| python -m venv venv | |
| source venv/bin/activate # On Windows: venv\Scripts\activate | |
| ``` | |
| 2. Install dependencies: | |
| ```bash | |
| pip install -r requirements.txt | |
| ``` | |
| 3. Run the training pipeline: | |
| ```bash | |
| 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 |