cifar100-classifier / START_HERE.md
Krishnakanth1993's picture
Deploying CIFAR 100 best model
b9a3037

A newer version of the Gradio SDK is available: 6.9.0

Upgrade

🎯 START HERE - CIFAR-100 Classifier Deployment

πŸ“¦ What You Have

Your CIFAR-100 Image Classifier is ready for deployment! This is a complete Gradio web application that:

βœ… Classifies images into 100 categories βœ… Shows confidence scores and probabilities βœ… Has a beautiful, interactive UI βœ… Works on CPU or GPU βœ… Ready for Hugging Face Spaces


🚦 Two Options: Choose Your Path

Option A: 🏠 Test Locally First (RECOMMENDED)

Windows Users:

  1. Double-click run_local.bat
  2. Wait for browser to open at http://localhost:7860
  3. Upload an image and test the classifier!

Alternative (any OS):

python app.py

Option B: ☁️ Deploy Directly to Hugging Face

Skip to the "Deploy to Hugging Face" section below.


πŸ§ͺ Testing Your App Locally

Quick Test (Automated)

python test_app_locally.py

This script will:

  1. βœ… Check all dependencies are installed
  2. βœ… Verify model file exists (cifar100_model.pth)
  3. βœ… Test model loading
  4. βœ… Offer to run the app

Manual Test

# Install dependencies
pip install -r requirements.txt

# Run the app
python app.py

Then:

  1. Open http://localhost:7860 in your browser
  2. Upload a test image (any JPG, PNG, etc.)
  3. Verify you see predictions with probabilities
  4. Check top predictions and charts work

☁️ Deploy to Hugging Face Spaces

Step-by-Step Deployment

1. Create a Hugging Face Space

  1. Go to huggingface.co/new-space
  2. Fill in:
    • Owner: Your username
    • Space name: cifar100-classifier (or any name you like)
    • License: MIT
    • Select SDK: Gradio
    • SDK version: 4.0.0
    • Hardware: CPU (Basic - Free) or upgrade for GPU
  3. Click "Create Space"

2. Upload Files to Your Space

Method 1: Web Interface (Easiest)

  1. Click "Files" tab in your new space
  2. Click "Add file" β†’ "Upload files"
  3. Upload all files from CIFAR100HFS folder:
    • app.py
    • model.py
    • cifar100_model.pth
    • requirements.txt
    • README.md
    • .gitattributes
  4. Click "Commit changes to main"

Method 2: Git CLI (Recommended for large models)

# Clone your space
git clone https://huggingface.co/spaces/YOUR_USERNAME/cifar100-classifier
cd cifar100-classifier

# Copy files
# (Copy all files from CIFAR100HFS to this directory)

# Setup Git LFS for large files
git lfs install
git lfs track "*.pth"

# Add and commit
git add .
git commit -m "Deploy CIFAR-100 classifier"

# Push to Hugging Face
git push

3. Wait for Build

  • Your space will automatically build (2-5 minutes)
  • Check the "Logs" tab if there are issues
  • Once built, your app will be live!

4. Access Your App

Your app will be available at:

https://huggingface.co/spaces/YOUR_USERNAME/cifar100-classifier

πŸ“Š What Your Users Will See

  1. Landing Page:

    • Title: "CIFAR-100 Image Classifier"
    • Upload button
    • Settings sidebar
  2. After Upload:

    • Original image displayed
    • Predicted class in large text
    • Confidence percentage with color coding
    • Top-K predictions table
    • Interactive probability bar chart
  3. Advanced Options:

    • Adjust number of top predictions (slider)
    • View all 100 class probabilities (checkbox)
    • Download results as text file

🎨 Customization (Optional)

Change App Title

Edit app.py line 34:

page_title="Your Custom Title"

Change Color Theme

Edit README.md lines 3-4:

colorFrom: blue  # Change to: red, green, yellow, etc.
colorTo: purple  # Change to: pink, indigo, teal, etc.

Add Your Logo

Add to sidebar in app.py:

st.sidebar.image("your_logo.png")

πŸ› Troubleshooting

Local Testing Issues

"ModuleNotFoundError"

pip install -r requirements.txt

"Model file not found"

  • Ensure cifar100_model.pth is in the same folder as app.py

"Port already in use"

streamlit run app.py --server.port 8502

Hugging Face Deployment Issues

"Build failed"

  • Check Logs tab in your space
  • Verify requirements.txt is correct
  • Ensure all files uploaded successfully

"Model too large"

  • Model file is 92MB - should work fine
  • Git LFS is tracking it (check .gitattributes)

"App crashes on inference"

  • Check if model architecture matches checkpoint
  • Verify CIFAR-100 classes list is correct

πŸ“ˆ Performance Optimization

For Faster Inference

  1. Use GPU hardware on Hugging Face (paid)
  2. Reduce image size if needed
  3. Batch predictions for multiple images

For Better UX

  1. Add loading spinners (already included)
  2. Add progress bars for long operations
  3. Cache results to avoid re-computation

πŸŽ“ Learn More


✨ What's Next?

After successful deployment:

  1. Share your space with friends and colleagues
  2. Collect feedback from users
  3. Monitor performance in HF analytics
  4. Iterate and improve based on usage
  5. Add to your portfolio or resume!

πŸ“ Quick Command Reference

# Test locally
python test_app_locally.py

# Run app locally
streamlit run app.py

# Deploy to HF (from your space directory)
git add .
git commit -m "Update app"
git push

# Check model file size
# Windows PowerShell:
(Get-Item cifar100_model.pth).length / 1MB

πŸŽ‰ You're Ready!

Everything is set up and ready to go. Your next step:

β†’ Run python test_app_locally.py to test

β†’ Or jump straight to deployment following steps above!

Good luck! πŸš€


Created: October 10, 2025
Author: Krishnakanth