| # π― 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):** | |
| ```bash | |
| 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) | |
| ```bash | |
| 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 | |
| ```bash | |
| # 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](https://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)** | |
| ```bash | |
| # 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: | |
| ```python | |
| page_title="Your Custom Title" | |
| ``` | |
| ### Change Color Theme | |
| Edit `README.md` lines 3-4: | |
| ```yaml | |
| 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`: | |
| ```python | |
| st.sidebar.image("your_logo.png") | |
| ``` | |
| --- | |
| ## π Troubleshooting | |
| ### Local Testing Issues | |
| **"ModuleNotFoundError"** | |
| ```bash | |
| 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"** | |
| ```bash | |
| 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 | |
| - **Streamlit Docs**: [docs.streamlit.io](https://docs.streamlit.io) | |
| - **Hugging Face Spaces**: [huggingface.co/docs/hub/spaces](https://huggingface.co/docs/hub/spaces) | |
| - **PyTorch**: [pytorch.org/docs](https://pytorch.org/docs) | |
| --- | |
| ## β¨ 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 | |
| ```bash | |
| # 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* | |