nailarais1's picture
Update README.md
8c563a1 verified
---
library_name: pytorch
tags:
- image-classification
- pytorch
- efficientnet
- flowers
- computer-vision
- oxford-flowers-102
- vision
pipeline_tag: image-classification
datasets:
- dpdl-benchmark/oxford_flowers102
license: mit
metrics:
- accuracy
base_model: efficientnet
language:
- en
---
# 🌸 Flower Classification Model
## πŸ“Š Model Info
[![HF Model](https://img.shields.io/badge/πŸ€—-Model%20Hub-yellow)](https://huggingface.co/nailarais1/image-classifier-efficientnet)
[![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
[![PyTorch](https://img.shields.io/badge/PyTorch-2.0+-red.svg)](https://pytorch.org)
[![Downloads](https://img.shields.io/badge/Downloads-100+-blue)](https://huggingface.co/nailarais1/image-classifier-efficientnet)
Model: nailarais1/image-classifier-efficientnet
Author: Naila Rais
Task: Image Classification Β· 102 Flower Species
## Quick Start
### Installation
```bash
pip install torch torchvision pillow
```
### Basic Usage
```python
import torch
import torchvision.transforms as transforms
from PIL import Image
# Load model
checkpoint = torch.load('best_model.pth', map_location='cpu')
model = ... # Your model architecture
model.load_state_dict(checkpoint['model_state_dict'])
model.eval()
# Predict flower
def predict_flower(image_path):
transform = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406],
std=[0.229, 0.224, 0.225])
])
image = Image.open(image_path).convert('RGB')
image_tensor = transform(image).unsqueeze(0)
with torch.no_grad():
outputs = model(image_tensor)
_, predicted = torch.max(outputs, 1)
return predicted.item()
# Get flower name
flower_id = predict_flower('your_flower.jpg')
flower_name = class_names[flower_id] # Use class_config.json
print(f"Predicted: {flower_name}")
```
### Model Info
- **What it does:** Identifies 102 different flower species
- **Input:** Flower images (224Γ—224 pixels)
- **Output:** Flower name and confidence score
- **Architecture:** EfficientNet
- **Training:** 3 epochs on Oxford Flowers dataset
### Example Results
- 🌹 Input: rose_image.jpg β†’ Output: "rose" (98.2%)
- 🌻 Input: sunflower.jpg β†’ Output: "sunflower" (95.7%)
- 🌷 Input: tulip.jpg β†’ Output: "tulip" (92.3%)
### Files Included
- best_model.pth - Trained model weights
- class_config.json - Flower names mapping
- config.json - Model configuration
- labels.txt - List of all flower names
### Supported Flowers
102 species including:
- 🌹 Rose
- 🌻 Sunflower
- 🌷 Tulip
- 🌼 Daisy
- πŸ’ Lily
- 🏡️ Orchid
- 🌺 Hibiscus
- 🌸 Cherry Blossom
- And 94 more...
## For Developers
```python
# Get top-5 predictions
def top_k_predictions(image_path, k=5):
# ... (implementation)
return [
{"flower": "rose", "confidence": 0.98},
{"flower": "tulip", "confidence": 0.01},
# ...
]
```
### License
MIT License - Free for personal and commercial use βœ…
### Need Help?
- Model not loading? Check PyTorch version
- Wrong predictions? Use clear, centered flower images
- Other issues? Open a discussion on this repo
Download and start classifying flowers today! 🌸
Model by Naila Rais Β· Hosted on Hugging Face