A newer version of the Gradio SDK is available:
6.9.0
π― 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:
- Double-click
run_local.bat - Wait for browser to open at
http://localhost:7860 - 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:
- β Check all dependencies are installed
- β Verify model file exists (cifar100_model.pth)
- β Test model loading
- β Offer to run the app
Manual Test
# Install dependencies
pip install -r requirements.txt
# Run the app
python app.py
Then:
- Open
http://localhost:7860in your browser - Upload a test image (any JPG, PNG, etc.)
- Verify you see predictions with probabilities
- Check top predictions and charts work
βοΈ Deploy to Hugging Face Spaces
Step-by-Step Deployment
1. Create a Hugging Face Space
- Go to huggingface.co/new-space
- 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
- Click "Create Space"
2. Upload Files to Your Space
Method 1: Web Interface (Easiest)
- Click "Files" tab in your new space
- Click "Add file" β "Upload files"
- Upload all files from
CIFAR100HFSfolder:- app.py
- model.py
- cifar100_model.pth
- requirements.txt
- README.md
- .gitattributes
- 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
Landing Page:
- Title: "CIFAR-100 Image Classifier"
- Upload button
- Settings sidebar
After Upload:
- Original image displayed
- Predicted class in large text
- Confidence percentage with color coding
- Top-K predictions table
- Interactive probability bar chart
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.pthis in the same folder asapp.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.txtis 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
- Use GPU hardware on Hugging Face (paid)
- Reduce image size if needed
- Batch predictions for multiple images
For Better UX
- Add loading spinners (already included)
- Add progress bars for long operations
- Cache results to avoid re-computation
π Learn More
- Streamlit Docs: docs.streamlit.io
- Hugging Face Spaces: huggingface.co/docs/hub/spaces
- PyTorch: pytorch.org/docs
β¨ What's Next?
After successful deployment:
- Share your space with friends and colleagues
- Collect feedback from users
- Monitor performance in HF analytics
- Iterate and improve based on usage
- 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