CoolFace
Apppublic

Sijuade/imagenet-resnet50-inference

sourceHugging Facemitupdated 11mo agoView on Hugging Face
0likes
App README

ImageNet Vision AI ๐Ÿ–ผ๏ธ

A beautiful, production-ready Streamlit application for ImageNet image classification using a custom-trained ResNet50 model achieving 76.21% top-1 accuracy.

โœจ Live Demo

Try it now: ImageNet Vision AI on Hugging Face Spaces

๐Ÿš€ Features

๐ŸŽจ Beautiful User Interface

  • โ€”Modern Design: Purple gradient theme with smooth animations
  • โ€”Drag & Drop: Intuitive interface for image uploads
  • โ€”Multiple Images: Upload and process multiple images simultaneously
  • โ€”Prediction Cards: Stunning card-based design with medals (๐Ÿฅ‡๐Ÿฅˆ๐Ÿฅ‰) for top predictions
  • โ€”Color-Coded Confidence: Visual indicators (green/orange/gray) based on confidence levels
  • โ€”Sample Gallery: 4 pre-loaded ImageNet sample images for quick testing

๐Ÿ”ฅ Core Functionality

  • โ€”Top-K Predictions: View 1-10 top predictions per image
  • โ€”Confidence Filtering: Filter predictions by confidence threshold
  • โ€”Inference Metrics: Display inference time for each image
  • โ€”Batch Processing: Process multiple images in one session
  • โ€”Batch Export: Download all predictions as JSON

๐ŸŽฏ Model Details

  • โ€”Architecture: ResNet50 (PyTorch)
  • โ€”Training: Custom training on full ImageNet-1K dataset
  • โ€”Accuracy: 76.21% top-1 accuracy
  • โ€”Classes: 1000 ImageNet categories
  • โ€”Framework: PyTorch Lightning with mixed precision (FP16)
  • โ€”Optimizer: LAMB with cosine learning rate schedule
  • โ€”Augmentation: RandAugment, Mixup (0.2), CutMix (1.0), Random Erasing (0.25)
  • โ€”Training Details: 300 epochs, 8 GPUs (DDP), batch size 256

๐Ÿ“ฆ Model Repository

๐ŸŽจ How to Use

  1. 1.Upload Images: Drag and drop images or click to browse (JPG, JPEG, PNG, WebP)
  2. 2.Try Samples: Click on any of the 4 sample images to see instant predictions
  3. 3.Adjust Settings: Use sidebar to configure:
  4. 4.Top-K predictions (1-10)
  5. 5.Confidence threshold (0-100%)
  6. 6.Show/hide inference time
  7. 7.Show/hide model info
  8. 8.View Results: See beautiful prediction cards with:
  9. 9.Class names
  10. 10.Confidence scores
  11. 11.Visual progress bars
  12. 12.Medal indicators for top 3
  13. 13.Export: Download all predictions as JSON

๐Ÿ› ๏ธ Technology Stack

  • โ€”Frontend: Streamlit with custom CSS
  • โ€”Backend: PyTorch + torchvision
  • โ€”Model: ResNet50 (PyTorch Lightning checkpoint)
  • โ€”Deployment: Docker on Hugging Face Spaces
  • โ€”Sample Images: From imagenet-sample-images

๐Ÿณ Docker Deployment

This app is deployed using Docker on Hugging Face Spaces. Key features:

  • โ€”Automatic Model Download: Downloads 391MB checkpoint from Hugging Face Hub during build
  • โ€”Sample Images: Downloads 10 sample images from GitHub during build (limited to 4 in UI)
  • โ€”User Permissions: Runs as user ID 1000 (HF Spaces requirement)
  • โ€”Port: Exposes port 7860 (HF Spaces default)

Dockerfile Highlights

dockerfile
# Download model from HF Hub
RUN python -c "from huggingface_hub import hf_hub_download; \
    hf_hub_download(repo_id='Sijuade/resnett50-imagenet', \
                    filename='acc1=76.2100.ckpt', \
                    local_dir='/app/models')"

# Download sample images from GitHub
RUN python -c "import os, requests; \
    samples = ['n01440764_tench.JPEG', 'n01443537_goldfish.JPEG', ...]; \
    [open(os.path.join('/app/images', f), 'wb').write(requests.get(base_url + f).content) for f in samples]"

๐Ÿ“Š Example Predictions

The model can classify:

  • โ€”๐Ÿ• Animals: Dogs, cats, birds, fish, reptiles, insects
  • โ€”๐Ÿš— Vehicles: Cars, planes, boats, trains, bicycles
  • โ€”๐Ÿช‘ Objects: Furniture, electronics, tools, instruments
  • โ€”๐ŸŽ Food: Fruits, vegetables, dishes, beverages
  • โ€”๐ŸŒธ Nature: Flowers, plants, landscapes, natural formations

๐Ÿ”ง Local Development

Using Docker

bash
# Clone the repository
git clone https://github.com/cydal/imagenet-streamlit.git
cd imagenet-streamlit

# Build and run
docker build -t imagenet-vision-ai .
docker run -p 7860:7860 imagenet-vision-ai

Using Python

bash
# Install dependencies
pip install -r requirements.txt

# Run the app
streamlit run app.py

๐Ÿ“ Training Your Own Model

Want to train your own ImageNet model? Check out the training repository:

[ImageNet-Full-training](https://github.com/cydal/ImageNet-Full-training)

Features:

  • โ€”Full ImageNet-1K training pipeline
  • โ€”PyTorch Lightning implementation
  • โ€”Multi-GPU (DDP) support
  • โ€”Mixed precision (FP16) training
  • โ€”Advanced augmentation techniques
  • โ€”Cosine learning rate scheduling
  • โ€”LAMB optimizer
  • โ€”Model compilation with torch.compile()

๐Ÿ”— Links

๐Ÿ“„ License

MIT License - See LICENSE file for details

๐Ÿ™ Acknowledgments


Built with โค๏ธ using Streamlit & PyTorch | 76.21% Top-1 Accuracy on ImageNet-1K