Update app.py
Browse files
app.py
CHANGED
|
@@ -232,7 +232,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 232 |
gr.Markdown("""
|
| 233 |
# π₯ ImageNet ResNet50 Classifier
|
| 234 |
|
| 235 |
-
**Trained from scratch to
|
| 236 |
|
| 237 |
Upload any image and get top-5 predictions with confidence scores.
|
| 238 |
""")
|
|
@@ -258,22 +258,19 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 258 |
- **Training:** From scratch (no pretrained weights)
|
| 259 |
- **Dataset:** ImageNet (1.2M images, 1000 classes)
|
| 260 |
- **Accuracy:** 77.09% Top-1 validation
|
| 261 |
-
- **Training Time:** ~13 hours on 8Γ A100 GPUs
|
| 262 |
|
| 263 |
### π Links:
|
| 264 |
-
- [GitHub Repository](https://github.com/Shwethaamrutha/TSAI-
|
| 265 |
-
- [Training Logs & Details](https://github.com/Shwethaamrutha/TSAI-S8/blob/main/imagenet-training-final/README.md)
|
| 266 |
-
- [YouTube Demo](https://youtube.com/YOUR_VIDEO_ID)
|
| 267 |
""")
|
| 268 |
|
| 269 |
# Example images
|
| 270 |
gr.Markdown("### πΌοΈ Try These Examples:")
|
| 271 |
gr.Examples(
|
| 272 |
examples=[
|
| 273 |
-
["
|
| 274 |
-
["
|
| 275 |
-
["
|
| 276 |
-
["
|
| 277 |
],
|
| 278 |
inputs=image_input,
|
| 279 |
outputs=output,
|
|
@@ -284,46 +281,7 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
| 284 |
# Connect button
|
| 285 |
predict_btn.click(fn=predict, inputs=image_input, outputs=output)
|
| 286 |
|
| 287 |
-
|
| 288 |
-
---
|
| 289 |
-
### π Training Details:
|
| 290 |
-
|
| 291 |
-
**Phase 1: Initial Training (90 epochs)**
|
| 292 |
-
- Optimizer: SGD + Nesterov momentum
|
| 293 |
-
- LR Schedule: OneCycleLR (0.02 β 0.2 β 0.00001)
|
| 294 |
-
- Regularization: Label smoothing, weight decay, dropout
|
| 295 |
-
- Result: 76.75%
|
| 296 |
-
|
| 297 |
-
**Phase 2: Fine-tuning (Multiple LR restarts)**
|
| 298 |
-
- LR=0.001: 76.88% (oscillated)
|
| 299 |
-
- LR=0.0005: **77.09%** β
(best achieved!)
|
| 300 |
-
- LR=0.0003: 77.02% (similar ceiling)
|
| 301 |
-
|
| 302 |
-
**Result:** 77.09% represents the natural ceiling for standard
|
| 303 |
-
from-scratch training. Achieving 78%+ requires advanced augmentation
|
| 304 |
-
techniques (MixUp, CutMix) beyond standard methods.
|
| 305 |
-
|
| 306 |
-
**Key Techniques:**
|
| 307 |
-
- Mixed precision training (torch.amp)
|
| 308 |
-
- Distributed training (8 GPUs, DDP)
|
| 309 |
-
- Robust image loading (handles corrupted files)
|
| 310 |
-
- Advanced augmentation (crop, flip, color jitter, erasing)
|
| 311 |
-
|
| 312 |
-
### π° Cost Analysis:
|
| 313 |
-
- Hardware: AWS p4d.24xlarge (8Γ A100 40GB)
|
| 314 |
-
- Duration: ~13 hours
|
| 315 |
-
- Cost: ~$110 (spot pricing)
|
| 316 |
-
|
| 317 |
-
### π Performance Context:
|
| 318 |
-
- **Industry Baseline:** 70-75% (we beat by 2-7%)
|
| 319 |
-
- **Good Training:** 75-77% (top tier!)
|
| 320 |
-
- **Our Result:** 77.09% (top 10% of from-scratch)
|
| 321 |
-
- **Research-Level:** 78%+ (requires MixUp/CutMix)
|
| 322 |
-
|
| 323 |
-
---
|
| 324 |
-
|
| 325 |
-
**Made with β€οΈ by Shwetha(https://github.com/Shwethaamrutha)**
|
| 326 |
-
""")
|
| 327 |
|
| 328 |
# Launch
|
| 329 |
if __name__ == "__main__":
|
|
|
|
| 232 |
gr.Markdown("""
|
| 233 |
# π₯ ImageNet ResNet50 Classifier
|
| 234 |
|
| 235 |
+
**Trained from scratch to 77%+ Top-1 accuracy on ImageNet!**
|
| 236 |
|
| 237 |
Upload any image and get top-5 predictions with confidence scores.
|
| 238 |
""")
|
|
|
|
| 258 |
- **Training:** From scratch (no pretrained weights)
|
| 259 |
- **Dataset:** ImageNet (1.2M images, 1000 classes)
|
| 260 |
- **Accuracy:** 77.09% Top-1 validation
|
|
|
|
| 261 |
|
| 262 |
### π Links:
|
| 263 |
+
- [GitHub Repository](https://github.com/Shwethaamrutha/TSAI-S9)
|
|
|
|
|
|
|
| 264 |
""")
|
| 265 |
|
| 266 |
# Example images
|
| 267 |
gr.Markdown("### πΌοΈ Try These Examples:")
|
| 268 |
gr.Examples(
|
| 269 |
examples=[
|
| 270 |
+
["GermanShephard.jpg"],
|
| 271 |
+
["Goldfish.jpg"],
|
| 272 |
+
["Tiger.jpg"],
|
| 273 |
+
["Eagle.jpg"],
|
| 274 |
],
|
| 275 |
inputs=image_input,
|
| 276 |
outputs=output,
|
|
|
|
| 281 |
# Connect button
|
| 282 |
predict_btn.click(fn=predict, inputs=image_input, outputs=output)
|
| 283 |
|
| 284 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
|
| 286 |
# Launch
|
| 287 |
if __name__ == "__main__":
|