File size: 2,348 Bytes
a9e745b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

---

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}}

}

```