A state-of-the-art deep learning project for CIFAR-100 image classification using transfer learning with ResNet-50, achieving 84.35% test accuracy through progressive fine-tuning and advanced training techniques.
This project implements a robust image classification pipeline for the CIFAR-100 dataset, featuring:
- Transfer Learning: Leveraging ResNet-50 pretrained on ImageNet
- Progressive Fine-tuning: Three-stage unfreezing strategy for optimal convergence
- Advanced Augmentation: Comprehensive data augmentation with Mixup/CutMix
- Interactive Web Interface: Streamlit-based application for real-time predictions
- Production-Ready: Complete training pipeline with early stopping and model checkpointing
- ✨ High Accuracy: 84.35% test accuracy on CIFAR-100
- 🎨 Rich Augmentation: ColorJitter, RandomRotation, GaussianBlur, RandomErasing, Mixup/CutMix
- 📊 Interactive UI: Upload images and get instant predictions with confidence scores
- 🔄 Progressive Training: Three-stage fine-tuning strategy
- 📈 Learning Rate Scheduling: OneCycleLR for optimal convergence
- 🛡️ Early Stopping: Prevents overfitting with patience-based monitoring
- 📉 Comprehensive Logging: Track training metrics across all epochs
- Model Architecture
- Training Strategy
- Installation
- Usage
- Results
- Dataset
- Project Structure
- Customization
- Contributing
- License
- Acknowledgments
- References
- Contact
- Architecture: ResNet-50
- Pretrained Weights: ImageNet1K-V2
- Total Parameters: 23,712,932
- Final Layer: Modified FC layer (2048 → 100 classes)
- Only the final fully connected layer is trainable
- Learning Rate: max_lr=0.01
- Warmup: 30% of cycle
- Purpose: Adapt the classifier to CIFAR-100 without disrupting pretrained features
- Unfreeze: Layer 3, Layer 4, and FC
- Differential Learning Rates:
- Layer 3: 0.0005
- Layer 4: 0.001
- FC: 0.005
- Purpose: Fine-tune deeper layers for CIFAR-100 specific features
- All layers trainable
- Layer-wise Learning Rates:
- Layer 1: 0.00005
- Layer 2: 0.0001
- Layer 3: 0.0003
- Layer 4: 0.0008
- FC: 0.002
- Purpose: End-to-end fine-tuning with discriminative learning rates
- Python 3.10
- CUDA-capable GPU (recommended)
- 8GB+ RAM
- Clone the repository
- Create virtual environment
- Install dependencies
- Download CIFAR-100 dataset
Download dataset from release and extract
e.g., download cifar-100-python.tar.gz from releases page and extract to ./data
Run the training notebook to train your own model:
Or convert to script and run:
Training will automatically:
- Split data into train/val/test (90%/10%/test)
- Apply progressive fine-tuning
- Save best model based on validation loss
- Implement early stopping (patience=10)
Launch the interactive web application:
The app will open in your browser at http://localhost:8501
Features:
- Upload images (JPG, JPEG, PNG)
- Real-time predictions
- Confidence scores for all 100 classes
- Probability distribution visualization
| Test Accuracy | 84.35% |
| Test Loss | 0.7622 |
| Best Validation Loss | 0.9729 |
| Training Epochs | 66/100 (Early Stopping) |
| Total Parameters | 23,712,932 |
| Training Time | ~15.5 hours (GPU - NVIDIA GeForce GTX 1650) |
| Stage 1 | 1-10 | ~40% | FC layer training |
| Stage 2 | 11-25 | ~73% | Deep layers fine-tuning |
| Stage 3 | 26-66 | ~79% | Full model fine-tuning |
The model achieved steady convergence with:
- Consistent training loss reduction
- Validation loss stabilization around epoch 56
- Early stopping triggered at epoch 66
- Total Images: 60,000 (32×32 RGB)
- Training Set: 45,000 images (90% split)
- Validation Set: 5,000 images (10% split)
- Test Set: 10,000 images
- Classes: 100 fine-grained categories
- Superclasses: 20 coarse categories
All classes are balanced with 500 training images and 100 test images per class.
Note: You can download model_checkpoint.pth and cifar-100-python.tar.gz from the release page.
Edit train.ipynb to adjust:
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (git checkout -b feature/AmazingFeature)
- Commit your changes (git commit -m 'Add some AmazingFeature')
- Push to the branch (git push origin feature/AmazingFeature)
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- CIFAR-100 Dataset: Learning Multiple Layers of Features from Tiny Images, Alex Krizhevsky, 2009
- ResNet Architecture: Deep Residual Learning for Image Recognition, He et al., 2015
- PyTorch Team: For the excellent deep learning framework
- Streamlit Team: For the intuitive web app framework
- TIMM Library: Ross Wightman for data augmentation utilities
- Krizhevsky, A. (2009). Learning Multiple Layers of Features from Tiny Images.
- He, K., Zhang, X., Ren, S., & Sun, J. (2016). Deep Residual Learning for Image Recognition. CVPR.
- Zhang, H., Cisse, M., Dauphin, Y. N., & Lopez-Paz, D. (2018). mixup: Beyond Empirical Risk Minimization. ICLR.
- Yun, S., Han, D., Oh, S. J., Chun, S., Choe, J., & Yoo, Y. (2019). CutMix: Regularization Strategy to Train Strong Classifiers. ICCV.
- Smith, L. N., & Topin, N. (2019). Super-convergence: Very Fast Training of Neural Networks Using Large Learning Rates.
For questions or feedback, please open an issue on GitHub.
© 2025 Amirali Soltani Rad - GitHub
⭐ If you find this project helpful, please consider giving it a star!
Happy Classifying! 🎨🤖
.png)

