|
|
|
|
|
---
|
|
|
license: mit
|
|
|
tags:
|
|
|
- image-classification
|
|
|
- pytorch
|
|
|
- convnext
|
|
|
- dog-breeds
|
|
|
datasets:
|
|
|
- custom
|
|
|
language:
|
|
|
- en
|
|
|
metrics:
|
|
|
- accuracy
|
|
|
library_name: timm
|
|
|
---
|
|
|
|
|
|
# Dog Breed Classifier - ConvNeXt Base
|
|
|
|
|
|
This model is a fine-tuned ConvNeXt-Base model for classifying dog breeds among 7 different classes.
|
|
|
|
|
|
## Model Details
|
|
|
|
|
|
- **Model Architecture:** ConvNeXt-Base
|
|
|
- **Framework:** PyTorch + timm
|
|
|
- **Task:** Image Classification
|
|
|
- **Classes:** 7 dog breeds
|
|
|
- **Input Size:** 224x224 RGB images
|
|
|
|
|
|
## Classes
|
|
|
|
|
|
The model can classify the following dog breeds:
|
|
|
- Beagle
|
|
|
- Bulldog
|
|
|
- Dalmatian
|
|
|
- German Shepherd
|
|
|
- Husky
|
|
|
- Poodle
|
|
|
- Rottweiler
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
```python
|
|
|
import torch
|
|
|
import timm
|
|
|
from torchvision import transforms
|
|
|
from PIL import Image
|
|
|
|
|
|
# Load model
|
|
|
model = timm.create_model('convnext_base', pretrained=False)
|
|
|
model.head = torch.nn.Sequential(
|
|
|
torch.nn.AdaptiveAvgPool2d(1),
|
|
|
torch.nn.Flatten(),
|
|
|
torch.nn.Linear(model.head.in_features, 7)
|
|
|
)
|
|
|
|
|
|
# Load weights
|
|
|
model.load_state_dict(torch.load('model.pth', map_location='cpu'))
|
|
|
model.eval()
|
|
|
|
|
|
# Preprocessing
|
|
|
transform = transforms.Compose([
|
|
|
transforms.Resize((224, 224)),
|
|
|
transforms.ToTensor(),
|
|
|
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
|
|
|
])
|
|
|
|
|
|
# Inference
|
|
|
image = Image.open('dog_image.jpg')
|
|
|
input_tensor = transform(image).unsqueeze(0)
|
|
|
|
|
|
with torch.no_grad():
|
|
|
outputs = model(input_tensor)
|
|
|
probabilities = torch.nn.functional.softmax(outputs[0], dim=0)
|
|
|
```
|
|
|
|
|
|
## Model Performance
|
|
|
|
|
|
- Training accuracy: [Add your metrics]
|
|
|
- Validation accuracy: [Add your metrics]
|
|
|
|
|
|
## Training Details
|
|
|
|
|
|
- Base model: ConvNeXt-Base (pretrained on ImageNet)
|
|
|
- Fine-tuning approach: [Add details]
|
|
|
- Dataset: Custom dog breed dataset
|
|
|
- Epochs: [Add number]
|
|
|
- Optimizer: [Add optimizer details]
|
|
|
|
|
|
## Limitations
|
|
|
|
|
|
- The model is trained on a specific set of 7 dog breeds
|
|
|
- Performance may vary on images outside the training distribution
|
|
|
- Best results with clear, well-lit images of single dogs
|
|
|
|
|
|
## Citation
|
|
|
|
|
|
If you use this model, please cite:
|
|
|
```
|
|
|
@misc{dog-breed-convnext-2024,
|
|
|
title={Dog Breed Classification with ConvNeXt},
|
|
|
author={Alamgirapi},
|
|
|
year={2024},
|
|
|
howpublished={\url{https://huggingface.co/Alamgirapi/dog-breed-convnext-classifier}}
|
|
|
}
|
|
|
```
|
|
|
|