Spaces:
Sleeping
Sleeping
File size: 4,413 Bytes
f83e2e3 a89cc74 f83e2e3 a89cc74 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | ---
title: ResNet-18 CIFAR-100 Classifier
emoji: 🖼️
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.49.1
app_file: app.py
pinned: false
---
# ResNet-18 CIFAR-100 Image Classifier 🎯
A high-performance image classifier trained on CIFAR-100 dataset, achieving **77.18% test accuracy**.
## Model Details
- **Architecture:** ResNet-18 (Custom CIFAR-100 variant)
- **Parameters:** ~11 million
- **Test Accuracy:** 77.18%
- **Train Accuracy:** 98.25%
- **Training Time:** ~70 minutes on RTX 4070 Laptop GPU
- **Dataset:** CIFAR-100 (60,000 32×32 color images in 100 classes)
## Training Configuration
### Advanced Techniques Used
1. **OneCycle Learning Rate Policy** - Gradual warmup + extended annealing
2. **Cutout Augmentation** - Randomly masks 8×8 patches
3. **Label Smoothing** (0.1) - Prevents overconfident predictions
4. **Gradient Clipping** - Stabilizes training during high-LR phase
5. **Data Augmentation** - Random crops, horizontal flips, normalization
### Hyperparameters
- Epochs: 100
- Batch Size: 128
- Max Learning Rate: 0.1
- Weight Decay: 5e-4
- Optimizer: SGD with momentum (0.9)
## 100 Classes
The model can classify images into these categories:
**Animals (42 classes):**
- Mammals: bear, beaver, camel, cattle, chimpanzee, dolphin, elephant, fox, hamster, kangaroo, leopard, lion, mouse, otter, porcupine, possum, rabbit, raccoon, seal, shrew, skunk, squirrel, tiger, whale, wolf
- Aquatic: aquarium_fish, crab, crocodile, flatfish, lobster, ray, shark, trout
- Insects/Small creatures: bee, beetle, butterfly, caterpillar, cockroach, snail, snake, spider, turtle, worm
- Reptiles: dinosaur, lizard
**Vehicles (5 classes):**
bicycle, bus, motorcycle, pickup_truck, streetcar, tank, tractor, train, rocket
**Household Items (11 classes):**
bed, chair, clock, couch, cup, keyboard, lamp, plate, table, telephone, television, wardrobe
**Food (5 classes):**
apple, mushroom, orange, pear, sweet_pepper
**Nature (13 classes):**
- Trees: maple_tree, oak_tree, palm_tree, pine_tree, willow_tree
- Flowers: orchid, poppy, rose, sunflower, tulip
- Landscapes: cloud, forest, mountain, plain, road, sea
**People (3 classes):**
baby, boy, girl, man, woman
**Structures (5 classes):**
bridge, castle, house, road, skyscraper
**Other (16 classes):**
aquarium_fish, bottle, bowl, bridge, can, castle, house, lawn_mower, rocket, sea, tank
## Usage
### On Hugging Face Spaces
Simply upload an image and get instant predictions with confidence scores!
### Local Usage
```python
import torch
from PIL import Image
from torchvision import transforms
# Load model
checkpoint = torch.load('checkpoints/resnet18_best.pth')
model = ResNet(BasicBlock, [2, 2, 2, 2], num_classes=100)
model.load_state_dict(checkpoint['model_state_dict'])
model.eval()
# Preprocess image
transform = transforms.Compose([
transforms.Resize((32, 32)),
transforms.ToTensor(),
transforms.Normalize((0.5071, 0.4867, 0.4408),
(0.2675, 0.2565, 0.2761))
])
image = Image.open('your_image.jpg')
img_tensor = transform(image).unsqueeze(0)
# Predict
with torch.no_grad():
output = model(img_tensor)
pred = output.argmax(dim=1)
```
## Performance Notes
- **Best for:** Small objects, centered subjects, simple backgrounds
- **Optimized for:** 32×32 images (will be automatically resized)
- **Categories:** Works best with the 100 CIFAR-100 classes listed above
## Training Curves
The model showed steady improvement throughout training:
- Epochs 1-30: Warmup phase (13.89% → 59.38%)
- Epochs 31-60: Peak learning (59.38% → 63.88%)
- Epochs 61-100: Fine-tuning (63.88% → 77.18%)
## Key Achievements
✅ Exceeded 73% target accuracy by **4.18%**
✅ Stable training with no divergence
✅ Effective use of OneCycleLR scheduler
✅ Combined regularization techniques
✅ Fast training (~70 minutes for 100 epochs)
## Repository
Full training code, logs, and checkpoints available at: [GitHub Repository](https://github.com/yourusername/resnet-cifar100)
## Citation
If you use this model, please cite:
```bibtex
@misc{resnet18-cifar100,
author = {Your Name},
title = {ResNet-18 CIFAR-100 Image Classifier},
year = {2024},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/spaces/yourusername/resnet18-cifar100}}
}
```
## License
MIT License - Feel free to use for research and educational purposes!
|