File size: 10,483 Bytes
6008e8b 1909e3a 6008e8b 1909e3a 5982404 ab76632 6008e8b 1909e3a ab76632 1909e3a ab76632 1909e3a ab76632 614e9db 1909e3a | 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 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | ---
license: apache-2.0
language:
- en
base_model:
- google/siglip2-base-patch16-224
pipeline_tag: image-classification
library_name: transformers
tags:
- dog
- classify
---

# **Dog-Breed-120**
> **Dog-Breed-120** is an image classification vision-language encoder model fine-tuned from **google/siglip2-base-patch16-224** for a single-label classification task. It is designed to classify dog images into specific breed categories using the **SiglipForImageClassification** architecture.
> [!Note]
> Accuracy : 86.81
```py
{'eval_loss': 0.49717578291893005,
'eval_model_preparation_time': 0.0042,
'eval_accuracy': 0.8681275679906085,
'eval_runtime': 146.2493,
'eval_samples_per_second': 69.894,
'eval_steps_per_second': 8.739,
'epoch': 7.0}
```
The model categorizes images into the following 121 classes (0-120):
- **Class 0:** "affenpinscher"
- **Class 1:** "afghan_hound"
- **Class 2:** "african_hunting_dog"
- **Class 3:** "airedale"
- **Class 4:** "american_staffordshire_terrier"
- **Class 5:** "appenzeller"
- **Class 6:** "australian_terrier"
- **Class 7:** "basenji"
- **Class 8:** "basset"
- **Class 9:** "beagle"
- **Class 10:** "bedlington_terrier"
- **Class 11:** "bernese_mountain_dog"
- **Class 12:** "black-and-tan_coonhound"
- **Class 13:** "blenheim_spaniel"
- **Class 14:** "bloodhound"
- **Class 15:** "bluetick"
- **Class 16:** "border_collie"
- **Class 17:** "border_terrier"
- **Class 18:** "borzoi"
- **Class 19:** "boston_bull"
- **Class 20:** "bouvier_des_flandres"
- **Class 21:** "boxer"
- **Class 22:** "brabancon_griffon"
- **Class 23:** "briard"
- **Class 24:** "brittany_spaniel"
- **Class 25:** "bull_mastiff"
- **Class 26:** "cairn"
- **Class 27:** "cardigan"
- **Class 28:** "chesapeake_bay_retriever"
- **Class 29:** "chihuahua"
- **Class 30:** "chow"
- **Class 31:** "clumber"
- **Class 32:** "cocker_spaniel"
- **Class 33:** "collie"
- **Class 34:** "curly-coated_retriever"
- **Class 35:** "dandie_dinmont"
- **Class 36:** "dhole"
- **Class 37:** "dingo"
- **Class 38:** "doberman"
- **Class 39:** "english_foxhound"
- **Class 40:** "english_setter"
- **Class 41:** "english_springer"
- **Class 42:** "entlebucher"
- **Class 43:** "eskimo_dog"
- **Class 44:** "flat-coated_retriever"
- **Class 45:** "french_bulldog"
- **Class 46:** "german_shepherd"
- **Class 47:** "german_short-haired_pointer"
- **Class 48:** "giant_schnauzer"
- **Class 49:** "golden_retriever"
- **Class 50:** "gordon_setter"
- **Class 51:** "great_dane"
- **Class 52:** "great_pyrenees"
- **Class 53:** "greater_swiss_mountain_dog"
- **Class 54:** "groenendael"
- **Class 55:** "ibizan_hound"
- **Class 56:** "irish_setter"
- **Class 57:** "irish_terrier"
- **Class 58:** "irish_water_spaniel"
- **Class 59:** "irish_wolfhound"
- **Class 60:** "italian_greyhound"
- **Class 61:** "japanese_spaniel"
- **Class 62:** "keeshond"
- **Class 63:** "kelpie"
- **Class 64:** "kerry_blue_terrier"
- **Class 65:** "komondor"
- **Class 66:** "kuvasz"
- **Class 67:** "labrador_retriever"
- **Class 68:** "lakeland_terrier"
- **Class 69:** "leonberg"
- **Class 70:** "lhasa"
- **Class 71:** "malamute"
- **Class 72:** "malinois"
- **Class 73:** "maltese_dog"
- **Class 74:** "mexican_hairless"
- **Class 75:** "miniature_pinscher"
- **Class 76:** "miniature_poodle"
- **Class 77:** "miniature_schnauzer"
- **Class 78:** "newfoundland"
- **Class 79:** "norfolk_terrier"
- **Class 80:** "norwegian_elkhound"
- **Class 81:** "norwich_terrier"
- **Class 82:** "old_english_sheepdog"
- **Class 83:** "otterhound"
- **Class 84:** "papillon"
- **Class 85:** "pekinese"
- **Class 86:** "pembroke"
- **Class 87:** "pomeranian"
- **Class 88:** "pug"
- **Class 89:** "redbone"
- **Class 90:** "rhodesian_ridgeback"
- **Class 91:** "rottweiler"
- **Class 92:** "saint_bernard"
- **Class 93:** "saluki"
- **Class 94:** "samoyed"
- **Class 95:** "schipperke"
- **Class 96:** "scotch_terrier"
- **Class 97:** "scottish_deerhound"
- **Class 98:** "sealyham_terrier"
- **Class 99:** "shetland_sheepdog"
- **Class 100:** "shih-tzu"
- **Class 101:** "siberian_husky"
- **Class 102:** "silky_terrier"
- **Class 103:** "soft-coated_wheaten_terrier"
- **Class 104:** "staffordshire_bullterrier"
- **Class 105:** "standard_poodle"
- **Class 106:** "standard_schnauzer"
- **Class 107:** "sussex_spaniel"
- **Class 108:** "test"
- **Class 109:** "tibetan_mastiff"
- **Class 110:** "tibetan_terrier"
- **Class 111:** "toy_poodle"
- **Class 112:** "toy_terrier"
- **Class 113:** "vizsla"
- **Class 114:** "walker_hound"
- **Class 115:** "weimaraner"
- **Class 116:** "welsh_springer_spaniel"
- **Class 117:** "west_highland_white_terrier"
- **Class 118:** "whippet"
- **Class 119:** "wire-haired_fox_terrier"
- **Class 120:** "yorkshire_terrier"
# **Run with Transformers🤗**
```python
!pip install -q transformers torch pillow gradio
```
```python
import gradio as gr
from transformers import AutoImageProcessor, SiglipForImageClassification
from PIL import Image
import torch
# Load model and processor
model_name = "prithivMLmods/Dog-Breed-120"
model = SiglipForImageClassification.from_pretrained(model_name)
processor = AutoImageProcessor.from_pretrained(model_name)
def dog_breed_classification(image):
"""Predicts the dog breed for an image."""
image = Image.fromarray(image).convert("RGB")
inputs = processor(images=image, return_tensors="pt")
with torch.no_grad():
outputs = model(**inputs)
logits = outputs.logits
probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
labels = {
"0": "affenpinscher",
"1": "afghan_hound",
"2": "african_hunting_dog",
"3": "airedale",
"4": "american_staffordshire_terrier",
"5": "appenzeller",
"6": "australian_terrier",
"7": "basenji",
"8": "basset",
"9": "beagle",
"10": "bedlington_terrier",
"11": "bernese_mountain_dog",
"12": "black-and-tan_coonhound",
"13": "blenheim_spaniel",
"14": "bloodhound",
"15": "bluetick",
"16": "border_collie",
"17": "border_terrier",
"18": "borzoi",
"19": "boston_bull",
"20": "bouvier_des_flandres",
"21": "boxer",
"22": "brabancon_griffon",
"23": "briard",
"24": "brittany_spaniel",
"25": "bull_mastiff",
"26": "cairn",
"27": "cardigan",
"28": "chesapeake_bay_retriever",
"29": "chihuahua",
"30": "chow",
"31": "clumber",
"32": "cocker_spaniel",
"33": "collie",
"34": "curly-coated_retriever",
"35": "dandie_dinmont",
"36": "dhole",
"37": "dingo",
"38": "doberman",
"39": "english_foxhound",
"40": "english_setter",
"41": "english_springer",
"42": "entlebucher",
"43": "eskimo_dog",
"44": "flat-coated_retriever",
"45": "french_bulldog",
"46": "german_shepherd",
"47": "german_short-haired_pointer",
"48": "giant_schnauzer",
"49": "golden_retriever",
"50": "gordon_setter",
"51": "great_dane",
"52": "great_pyrenees",
"53": "greater_swiss_mountain_dog",
"54": "groenendael",
"55": "ibizan_hound",
"56": "irish_setter",
"57": "irish_terrier",
"58": "irish_water_spaniel",
"59": "irish_wolfhound",
"60": "italian_greyhound",
"61": "japanese_spaniel",
"62": "keeshond",
"63": "kelpie",
"64": "kerry_blue_terrier",
"65": "komondor",
"66": "kuvasz",
"67": "labrador_retriever",
"68": "lakeland_terrier",
"69": "leonberg",
"70": "lhasa",
"71": "malamute",
"72": "malinois",
"73": "maltese_dog",
"74": "mexican_hairless",
"75": "miniature_pinscher",
"76": "miniature_poodle",
"77": "miniature_schnauzer",
"78": "newfoundland",
"79": "norfolk_terrier",
"80": "norwegian_elkhound",
"81": "norwich_terrier",
"82": "old_english_sheepdog",
"83": "otterhound",
"84": "papillon",
"85": "pekinese",
"86": "pembroke",
"87": "pomeranian",
"88": "pug",
"89": "redbone",
"90": "rhodesian_ridgeback",
"91": "rottweiler",
"92": "saint_bernard",
"93": "saluki",
"94": "samoyed",
"95": "schipperke",
"96": "scotch_terrier",
"97": "scottish_deerhound",
"98": "sealyham_terrier",
"99": "shetland_sheepdog",
"100": "shih-tzu",
"101": "siberian_husky",
"102": "silky_terrier",
"103": "soft-coated_wheaten_terrier",
"104": "staffordshire_bullterrier",
"105": "standard_poodle",
"106": "standard_schnauzer",
"107": "sussex_spaniel",
"108": "test",
"109": "tibetan_mastiff",
"110": "tibetan_terrier",
"111": "toy_poodle",
"112": "toy_terrier",
"113": "vizsla",
"114": "walker_hound",
"115": "weimaraner",
"116": "welsh_springer_spaniel",
"117": "west_highland_white_terrier",
"118": "whippet",
"119": "wire-haired_fox_terrier",
"120": "yorkshire_terrier"
}
predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
return predictions
# Create Gradio interface
iface = gr.Interface(
fn=dog_breed_classification,
inputs=gr.Image(type="numpy"),
outputs=gr.Label(label="Prediction Scores"),
title="Dog Breed Classification",
description="Upload an image to classify it into one of the 121 dog breed categories."
)
# Launch the app
if __name__ == "__main__":
iface.launch()
```
# **Intended Use:**
The **Dog-Breed-120** model is designed for dog breed image classification. It helps categorize dog images into 121 specific breed categories. Potential use cases include:
- **Pet Identification:** Assisting pet owners and veterinarians in identifying dog breeds.
- **Animal Research:** Supporting research in canine genetics and behavior studies.
- **E-commerce Applications:** Enhancing pet-related product recommendations and searches.
- **Educational Purposes:** Aiding in learning and teaching about various dog breeds. |