Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
---
|
| 3 |
+
license: mit
|
| 4 |
+
tags:
|
| 5 |
+
- image-classification
|
| 6 |
+
- pytorch
|
| 7 |
+
- convnext
|
| 8 |
+
- dog-breeds
|
| 9 |
+
datasets:
|
| 10 |
+
- custom
|
| 11 |
+
language:
|
| 12 |
+
- en
|
| 13 |
+
metrics:
|
| 14 |
+
- accuracy
|
| 15 |
+
library_name: timm
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# Dog Breed Classifier - ConvNeXt Base
|
| 19 |
+
|
| 20 |
+
This model is a fine-tuned ConvNeXt-Base model for classifying dog breeds among 7 different classes.
|
| 21 |
+
|
| 22 |
+
## Model Details
|
| 23 |
+
|
| 24 |
+
- **Model Architecture:** ConvNeXt-Base
|
| 25 |
+
- **Framework:** PyTorch + timm
|
| 26 |
+
- **Task:** Image Classification
|
| 27 |
+
- **Classes:** 7 dog breeds
|
| 28 |
+
- **Input Size:** 224x224 RGB images
|
| 29 |
+
|
| 30 |
+
## Classes
|
| 31 |
+
|
| 32 |
+
The model can classify the following dog breeds:
|
| 33 |
+
- Beagle
|
| 34 |
+
- Bulldog
|
| 35 |
+
- Dalmatian
|
| 36 |
+
- German Shepherd
|
| 37 |
+
- Husky
|
| 38 |
+
- Poodle
|
| 39 |
+
- Rottweiler
|
| 40 |
+
|
| 41 |
+
## Usage
|
| 42 |
+
|
| 43 |
+
```python
|
| 44 |
+
import torch
|
| 45 |
+
import timm
|
| 46 |
+
from torchvision import transforms
|
| 47 |
+
from PIL import Image
|
| 48 |
+
|
| 49 |
+
# Load model
|
| 50 |
+
model = timm.create_model('convnext_base', pretrained=False)
|
| 51 |
+
model.head = torch.nn.Sequential(
|
| 52 |
+
torch.nn.AdaptiveAvgPool2d(1),
|
| 53 |
+
torch.nn.Flatten(),
|
| 54 |
+
torch.nn.Linear(model.head.in_features, 7)
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
# Load weights
|
| 58 |
+
model.load_state_dict(torch.load('model.pth', map_location='cpu'))
|
| 59 |
+
model.eval()
|
| 60 |
+
|
| 61 |
+
# Preprocessing
|
| 62 |
+
transform = transforms.Compose([
|
| 63 |
+
transforms.Resize((224, 224)),
|
| 64 |
+
transforms.ToTensor(),
|
| 65 |
+
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
|
| 66 |
+
])
|
| 67 |
+
|
| 68 |
+
# Inference
|
| 69 |
+
image = Image.open('dog_image.jpg')
|
| 70 |
+
input_tensor = transform(image).unsqueeze(0)
|
| 71 |
+
|
| 72 |
+
with torch.no_grad():
|
| 73 |
+
outputs = model(input_tensor)
|
| 74 |
+
probabilities = torch.nn.functional.softmax(outputs[0], dim=0)
|
| 75 |
+
```
|
| 76 |
+
|
| 77 |
+
## Model Performance
|
| 78 |
+
|
| 79 |
+
- Training accuracy: [Add your metrics]
|
| 80 |
+
- Validation accuracy: [Add your metrics]
|
| 81 |
+
|
| 82 |
+
## Training Details
|
| 83 |
+
|
| 84 |
+
- Base model: ConvNeXt-Base (pretrained on ImageNet)
|
| 85 |
+
- Fine-tuning approach: [Add details]
|
| 86 |
+
- Dataset: Custom dog breed dataset
|
| 87 |
+
- Epochs: [Add number]
|
| 88 |
+
- Optimizer: [Add optimizer details]
|
| 89 |
+
|
| 90 |
+
## Limitations
|
| 91 |
+
|
| 92 |
+
- The model is trained on a specific set of 7 dog breeds
|
| 93 |
+
- Performance may vary on images outside the training distribution
|
| 94 |
+
- Best results with clear, well-lit images of single dogs
|
| 95 |
+
|
| 96 |
+
## Citation
|
| 97 |
+
|
| 98 |
+
If you use this model, please cite:
|
| 99 |
+
```
|
| 100 |
+
@misc{dog-breed-convnext-2024,
|
| 101 |
+
title={Dog Breed Classification with ConvNeXt},
|
| 102 |
+
author={Alamgirapi},
|
| 103 |
+
year={2024},
|
| 104 |
+
howpublished={\url{https://huggingface.co/Alamgirapi/dog-breed-convnext-classifier}}
|
| 105 |
+
}
|
| 106 |
+
```
|