|
|
--- |
|
|
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 |
|
|
|
|
|
[](https://huggingface.co/nailarais1/image-classifier-efficientnet) |
|
|
[](LICENSE) |
|
|
[](https://pytorch.org) |
|
|
[](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 |