Upload README.md
Browse files
README.md
CHANGED
|
@@ -1,28 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# ResNet on CIFAR-100
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
## Target
|
| 6 |
|
| 7 |
-
- Achieve 73% top-1 accuracy on CIFAR-100
|
| 8 |
-
-
|
| 9 |
|
| 10 |
## Project Structure
|
| 11 |
|
| 12 |
-
- `main.py`:
|
| 13 |
-
- `model.py`:
|
| 14 |
-
- `utils.py`:
|
| 15 |
-
- `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
-
##
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: CIFAR-100 ResNet18 Classifier
|
| 3 |
+
emoji: 🚀
|
| 4 |
+
colorFrom: indigo
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: gradio
|
| 7 |
+
app_file: app.py
|
| 8 |
+
pinned: false
|
| 9 |
+
license: apache-2.0
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
# ResNet on CIFAR-100
|
| 13 |
|
| 14 |
+
Train a ResNet18 from scratch on CIFAR-100 and deploy a Gradio demo on Hugging Face Spaces.
|
| 15 |
|
| 16 |
## Target
|
| 17 |
|
| 18 |
+
- Achieve ≥ 73% top-1 accuracy on CIFAR-100
|
| 19 |
+
- Train from scratch (no pretrained weights)
|
| 20 |
|
| 21 |
## Project Structure
|
| 22 |
|
| 23 |
+
- `main.py`: Training entrypoint (OneCycleLR + label smoothing)
|
| 24 |
+
- `model.py`: ResNet18 architecture (with dropout)
|
| 25 |
+
- `utils.py`: CIFAR-100 dataloaders and augmentations (RandAugment + RandomErasing)
|
| 26 |
+
- `app.py`: Gradio Space app (CPU inference, loads `ckpt.pth` if present)
|
| 27 |
+
- `logs.md`: Training logs (epoch-by-epoch)
|
| 28 |
+
- `.gitattributes`: Git LFS rules for weight files (`.pth`, `.pt`)
|
| 29 |
+
- `requirements.txt`: Dependencies
|
| 30 |
+
|
| 31 |
+
## Train
|
| 32 |
+
|
| 33 |
+
1) Install deps
|
| 34 |
+
```bash
|
| 35 |
+
pip install -r requirements.txt
|
| 36 |
+
```
|
| 37 |
|
| 38 |
+
2) Run training
|
| 39 |
+
```bash
|
| 40 |
+
python main.py --lr 0.2 --epoch 70
|
| 41 |
+
```
|
| 42 |
+
- Best checkpoint auto-saves as `ckpt.pth`
|
| 43 |
+
- Logs are written to `logs.md`
|
| 44 |
|
| 45 |
+
Tips:
|
| 46 |
+
- You can stop early once test accuracy ≥ 73% (best weights already saved)
|
| 47 |
+
- For Apple Silicon: code auto-uses `mps` if available
|
| 48 |
|
| 49 |
+
## Export / Weights
|
| 50 |
+
- Keep the best weights at repo root as `ckpt.pth` (tracked via LFS)
|
| 51 |
+
- `app.py` will attempt to load one of: `ckpt.pth`, `checkpoint/resnet18_cifar100.pth`, `resnet18_cifar100.pth`
|
| 52 |
+
- If your checkpoint is a dict with `net` (current default), no change needed
|
| 53 |
|
| 54 |
+
## Deploy to Hugging Face Spaces
|
| 55 |
+
1) Create a new Space (SDK: Gradio)
|
| 56 |
+
2) Push these files at minimum:
|
| 57 |
+
- `app.py`, `model.py`, `utils.py`, `requirements.txt`, `.gitattributes`
|
| 58 |
+
- `ckpt.pth` (LFS)
|
| 59 |
+
3) The app runs CPU-only and resizes inputs to 32×32. It returns top-5 predictions.
|
| 60 |
|
| 61 |
+
## Local Demo
|
| 62 |
+
```bash
|
| 63 |
+
python app.py
|
| 64 |
+
```
|
| 65 |
+
Open the printed local Gradio URL in your browser, upload an image, and view predictions.
|
| 66 |
|
| 67 |
+
## Links
|
| 68 |
+
- Space: [link to be added]
|
| 69 |
+
- GitHub: [link to be added]
|
| 70 |
+
- Logs: `logs.md`
|