era-resnet / README.md
Arnab Sinha
Fix short_description length for Hugging Face requirements
36430bb
|
Raw
History Blame Contribute Delete
4.31 kB

A newer version of the Gradio SDK is available: 6.27.0

Upgrade
metadata
title: CIFAR-100 ResNet-18 Classifier
emoji: πŸ–ΌοΈ
colorFrom: blue
colorTo: indigo
sdk: gradio
sdk_version: 4.44.0
app_file: app.py
pinned: false
license: apache-2.0
short_description: ResNet-18 for CIFAR-100 classification (100 categories)
tags:
  - computer-vision
  - image-classification
  - pytorch
  - resnet
  - cifar-100

πŸ–ΌοΈ CIFAR-100 ResNet-18 Image Classifier

This Hugging Face Space demonstrates a ResNet-18 model optimized for CIFAR-100 image classification. The model can classify images into 100 different categories including animals, vehicles, plants, and household objects.

πŸš€ Features

  • Custom ResNet-18 Architecture: Adapted specifically for CIFAR-100's 32Γ—32 input resolution
  • 100 Class Classification: Covers a wide range of categories from the CIFAR-100 dataset
  • Interactive Interface: Easy-to-use Gradio interface for real-time predictions
  • Top-5 Predictions: Shows confidence scores for the most likely classes
  • Technical Details: Comprehensive model information and architecture details

πŸ—οΈ Model Architecture

The model uses a modified ResNet-18 architecture with the following key features:

  • Input: 32Γ—32 RGB images (automatically resized)
  • Residual Blocks: Skip connections for improved gradient flow
  • Batch Normalization: Stable training and inference
  • No Max Pooling: Optimized stem for small input resolution
  • Adaptive Pooling: Global average pooling before classification
  • 100 Output Classes: Full CIFAR-100 category coverage

πŸ“Š Training Features

The training pipeline includes advanced techniques:

  • OneCycle Learning Rate: Cyclical learning rate scheduling
  • Mixed Precision: Automatic mixed precision for efficiency
  • Data Augmentation: Random crops, flips, and color jittering
  • Label Smoothing: Improved generalization
  • Gradient Clipping: Stable training dynamics
  • Grad-CAM Visualization: Built-in attention visualization

🎯 CIFAR-100 Categories

The model classifies images into 100 categories including:

Animals: apple, aquarium_fish, baby, bear, beaver, bee, beetle, butterfly, camel, cattle, chimpanzee, cockroach, crab, crocodile, dinosaur, dolphin, elephant, flatfish, fox, hamster, kangaroo, leopard, lion, lizard, lobster, mouse, otter, porcupine, possum, rabbit, raccoon, ray, seal, shark, shrew, skunk, snail, snake, spider, squirrel, tiger, trout, turtle, whale, wolf, worm

Plants: maple_tree, oak_tree, palm_tree, pine_tree, willow_tree, orchid, poppy, rose, sunflower, tulip, orange, pear, sweet_pepper, mushroom

Vehicles: bicycle, bus, motorcycle, pickup_truck, train, streetcar, tank, tractor, rocket

Household: bed, bottle, bowl, can, chair, clock, couch, cup, house, keyboard, lamp, plate, table, telephone, television, wardrobe

Others: bridge, castle, cloud, forest, mountain, plain, road, sea, skyscraper

πŸ”§ Usage

  1. Upload an image using the interface
  2. The model will automatically resize it to 32Γ—32 pixels
  3. Get top-5 predictions with confidence scores
  4. View detailed model information and technical specifications

πŸ“ Repository Structure

era-resnet/
β”œβ”€β”€ app.py              # Gradio interface
β”œβ”€β”€ model.py            # ResNet-18 architecture
β”œβ”€β”€ train.py            # Training script with advanced features
β”œβ”€β”€ requirements.txt    # Python dependencies
β”œβ”€β”€ train.log          # Training history and metrics
└── README.md          # This file

πŸš€ Local Development

To run this app locally:

pip install -r requirements.txt
python app.py

To train your own model:

python train.py --epochs 100 --batch-size 128 --max-lr 0.1

πŸ“ˆ Training Performance

The model achieves competitive performance on CIFAR-100:

  • Training includes 100 epochs with OneCycle scheduling
  • Mixed precision training for efficiency
  • Grad-CAM visualizations saved during training
  • Comprehensive logging and checkpointing

🀝 Contributing

Feel free to experiment with:

  • Different architectures (modify model.py)
  • Hyperparameter tuning (see train.py arguments)
  • Additional data augmentation techniques
  • Transfer learning from other datasets

πŸ“„ License

This project is licensed under the Apache 2.0 License.