prithivMLmods commited on
Commit
efdf2f9
·
verified ·
1 Parent(s): 8073d38

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +193 -1
README.md CHANGED
@@ -2,8 +2,25 @@
2
  license: apache-2.0
3
  datasets:
4
  - Elriggs/imagenet-50-subset
 
 
 
 
 
 
 
 
 
 
5
  ---
6
 
 
 
 
 
 
 
 
7
  ```py
8
  Classification Report:
9
  precision recall f1-score support
@@ -62,4 +79,179 @@ european fire salamander 0.9330 0.9278 0.9304 900
62
  accuracy 0.9181 45000
63
  macro avg 0.9186 0.9181 0.9181 45000
64
  weighted avg 0.9186 0.9181 0.9181 45000
65
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: apache-2.0
3
  datasets:
4
  - Elriggs/imagenet-50-subset
5
+ language:
6
+ - en
7
+ base_model:
8
+ - google/siglip2-base-patch16-224
9
+ pipeline_tag: image-classification
10
+ library_name: transformers
11
+ tags:
12
+ - image-net
13
+ - 50-class
14
+ - photo
15
  ---
16
 
17
+ ![ax.png](https://cdn-uploads.huggingface.co/production/uploads/65bb837dbfb878f46c77de4c/lggdyeOAr204uVfMlyrEX.png)
18
+
19
+ # **imagenet-50-subset**
20
+
21
+ > **imagenet-50-subset** is a vision-language encoder model fine-tuned from **google/siglip2-base-patch16-224** for **multi-class image classification**. It is trained to classify images into a subset of 50 categories derived from the **ImageNet** dataset using the **SiglipForImageClassification** architecture.
22
+
23
+
24
  ```py
25
  Classification Report:
26
  precision recall f1-score support
 
79
  accuracy 0.9181 45000
80
  macro avg 0.9186 0.9181 0.9181 45000
81
  weighted avg 0.9186 0.9181 0.9181 45000
82
+ ```
83
+
84
+ ---
85
+
86
+ ## **Label Space: 50 Classes**
87
+
88
+ The model classifies each image into one of the following categories:
89
+
90
+ ```
91
+ 0: tench
92
+ 1: goldfish
93
+ 2: great white shark
94
+ 3: tiger shark
95
+ 4: hammerhead
96
+ 5: electric ray
97
+ 6: stingray
98
+ 7: cock
99
+ 8: hen
100
+ 9: ostrich
101
+ 10: brambling
102
+ 11: goldfinch
103
+ 12: house finch
104
+ 13: junco
105
+ 14: indigo bunting
106
+ 15: robin
107
+ 16: bulbul
108
+ 17: jay
109
+ 18: magpie
110
+ 19: chickadee
111
+ 20: water ouzel
112
+ 21: kite
113
+ 22: bald eagle
114
+ 23: vulture
115
+ 24: great grey owl
116
+ 25: european fire salamander
117
+ 26: common newt
118
+ 27: eft
119
+ 28: spotted salamander
120
+ 29: axolotl
121
+ 30: bullfrog
122
+ 31: tree frog
123
+ 32: tailed frog
124
+ 33: loggerhead
125
+ 34: leatherback turtle
126
+ 35: mud turtle
127
+ 36: terrapin
128
+ 37: box turtle
129
+ 38: banded gecko
130
+ 39: common iguana
131
+ 40: american chameleon
132
+ 41: whiptail
133
+ 42: agama
134
+ 43: frilled lizard
135
+ 44: alligator lizard
136
+ 45: gila monster
137
+ 46: green lizard
138
+ 47: african chameleon
139
+ 48: komodo dragon
140
+ 49: african crocodile
141
+ ```
142
+
143
+ ---
144
+
145
+ ## **Install Dependencies**
146
+
147
+ ```bash
148
+ pip install -q transformers torch pillow gradio
149
+ ```
150
+
151
+ ---
152
+
153
+ ## **Inference Code**
154
+
155
+ ```python
156
+ import gradio as gr
157
+ from transformers import AutoImageProcessor, SiglipForImageClassification
158
+ from PIL import Image
159
+ import torch
160
+
161
+ # Load model and processor
162
+ model_name = "prithivMLmods/imagenet-50-subset" # Replace if different
163
+ model = SiglipForImageClassification.from_pretrained(model_name)
164
+ processor = AutoImageProcessor.from_pretrained(model_name)
165
+
166
+ # Label mapping
167
+ id2label = {
168
+ "0": "tench",
169
+ "1": "goldfish",
170
+ "2": "great white shark",
171
+ "3": "tiger shark",
172
+ "4": "hammerhead",
173
+ "5": "electric ray",
174
+ "6": "stingray",
175
+ "7": "cock",
176
+ "8": "hen",
177
+ "9": "ostrich",
178
+ "10": "brambling",
179
+ "11": "goldfinch",
180
+ "12": "house finch",
181
+ "13": "junco",
182
+ "14": "indigo bunting",
183
+ "15": "robin",
184
+ "16": "bulbul",
185
+ "17": "jay",
186
+ "18": "magpie",
187
+ "19": "chickadee",
188
+ "20": "water ouzel",
189
+ "21": "kite",
190
+ "22": "bald eagle",
191
+ "23": "vulture",
192
+ "24": "great grey owl",
193
+ "25": "european fire salamander",
194
+ "26": "common newt",
195
+ "27": "eft",
196
+ "28": "spotted salamander",
197
+ "29": "axolotl",
198
+ "30": "bullfrog",
199
+ "31": "tree frog",
200
+ "32": "tailed frog",
201
+ "33": "loggerhead",
202
+ "34": "leatherback turtle",
203
+ "35": "mud turtle",
204
+ "36": "terrapin",
205
+ "37": "box turtle",
206
+ "38": "banded gecko",
207
+ "39": "common iguana",
208
+ "40": "american chameleon",
209
+ "41": "whiptail",
210
+ "42": "agama",
211
+ "43": "frilled lizard",
212
+ "44": "alligator lizard",
213
+ "45": "gila monster",
214
+ "46": "green lizard",
215
+ "47": "african chameleon",
216
+ "48": "komodo dragon",
217
+ "49": "african crocodile"
218
+ }
219
+
220
+ def classify_imagenet_50(image):
221
+ image = Image.fromarray(image).convert("RGB")
222
+ inputs = processor(images=image, return_tensors="pt")
223
+
224
+ with torch.no_grad():
225
+ outputs = model(**inputs)
226
+ logits = outputs.logits
227
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
228
+
229
+ prediction = {
230
+ id2label[str(i)]: round(probs[i], 3) for i in range(len(probs))
231
+ }
232
+
233
+ return prediction
234
+
235
+ # Gradio Interface
236
+ iface = gr.Interface(
237
+ fn=classify_imagenet_50,
238
+ inputs=gr.Image(type="numpy"),
239
+ outputs=gr.Label(num_top_classes=5, label="ImageNet-50 Classification"),
240
+ title="imagenet-50-subset",
241
+ description="Upload an image to classify it into one of 50 selected ImageNet categories."
242
+ )
243
+
244
+ if __name__ == "__main__":
245
+ iface.launch()
246
+ ```
247
+
248
+ ---
249
+
250
+ ## **Intended Use**
251
+
252
+ **imagenet-50-subset** can be used for:
253
+
254
+ * **Benchmarking Lightweight Vision Models** – Quick testing on a meaningful subset of ImageNet classes.
255
+ * **Educational Demos** – Teaching about classification tasks with a simpler label space.
256
+ * **Prototype Deployment** – Use in applications where full ImageNet coverage is unnecessary.
257
+ * **Dataset Analysis** – Classification-based filtering of visual content into known object classes.