prithivMLmods commited on
Commit
eaf06af
·
verified ·
1 Parent(s): 0b3ac5e

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +223 -1
README.md CHANGED
@@ -3,6 +3,9 @@ license: apache-2.0
3
  datasets:
4
  - Bruece/domainnet-126-by-class-painting
5
  ---
 
 
 
6
 
7
  ```py
8
  Classification Report:
@@ -138,4 +141,223 @@ the_Great_Wall_of_China 0.8244 0.8710 0.8471 124
138
  accuracy 0.8533 24032
139
  macro avg 0.7686 0.7273 0.7299 24032
140
  weighted avg 0.8445 0.8533 0.8424 24032
141
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  datasets:
4
  - Bruece/domainnet-126-by-class-painting
5
  ---
6
+ # **Painting-126-DomainNet**
7
+
8
+ > **Painting-126-DomainNet** 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 paintings into 126 domain categories using the **SiglipForImageClassification** architecture.
9
 
10
  ```py
11
  Classification Report:
 
141
  accuracy 0.8533 24032
142
  macro avg 0.7686 0.7273 0.7299 24032
143
  weighted avg 0.8445 0.8533 0.8424 24032
144
+ ```
145
+
146
+
147
+ The model categorizes images into the following 126 classes:
148
+ - **Class 0:** "aircraft_carrier"
149
+ - **Class 1:** "alarm_clock"
150
+ - **Class 2:** "ant"
151
+ - **Class 3:** "anvil"
152
+ - **Class 4:** "asparagus"
153
+ - **Class 5:** "axe"
154
+ - **Class 6:** "banana"
155
+ - **Class 7:** "basket"
156
+ - **Class 8:** "bathtub"
157
+ - **Class 9:** "bear"
158
+ - **Class 10:** "bee"
159
+ - **Class 11:** "bird"
160
+ - **Class 12:** "blackberry"
161
+ - **Class 13:** "blueberry"
162
+ - **Class 14:** "bottlecap"
163
+ - **Class 15:** "broccoli"
164
+ - **Class 16:** "bus"
165
+ - **Class 17:** "butterfly"
166
+ - **Class 18:** "cactus"
167
+ - **Class 19:** "cake"
168
+ - **Class 20:** "calculator"
169
+ - **Class 21:** "camel"
170
+ - **Class 22:** "camera"
171
+ - **Class 23:** "candle"
172
+ - **Class 24:** "cannon"
173
+ - **Class 25:** "canoe"
174
+ - **Class 26:** "carrot"
175
+ - **Class 27:** "castle"
176
+ - **Class 28:** "cat"
177
+ - **Class 29:** "ceiling_fan"
178
+ - **Class 30:** "cell_phone"
179
+ - **Class 31:** "cello"
180
+ - **Class 32:** "chair"
181
+ - **Class 33:** "chandelier"
182
+ - **Class 34:** "coffee_cup"
183
+ - **Class 35:** "compass"
184
+ - **Class 36:** "computer"
185
+ - **Class 37:** "cow"
186
+ - **Class 38:** "crab"
187
+ - **Class 39:** "crocodile"
188
+ - **Class 40:** "cruise_ship"
189
+ - **Class 41:** "dog"
190
+ - **Class 42:** "dolphin"
191
+ - **Class 43:** "dragon"
192
+ - **Class 44:** "drums"
193
+ - **Class 45:** "duck"
194
+ - **Class 46:** "dumbbell"
195
+ - **Class 47:** "elephant"
196
+ - **Class 48:** "eyeglasses"
197
+ - **Class 49:** "feather"
198
+ - **Class 50:** "fence"
199
+ - **Class 51:** "fish"
200
+ - **Class 52:** "flamingo"
201
+ - **Class 53:** "flower"
202
+ - **Class 54:** "foot"
203
+ - **Class 55:** "fork"
204
+ - **Class 56:** "frog"
205
+ - **Class 57:** "giraffe"
206
+ - **Class 58:** "goatee"
207
+ - **Class 59:** "grapes"
208
+ - **Class 60:** "guitar"
209
+ - **Class 61:** "hammer"
210
+ - **Class 62:** "helicopter"
211
+ - **Class 63:** "helmet"
212
+ - **Class 64:** "horse"
213
+ - **Class 65:** "kangaroo"
214
+ - **Class 66:** "lantern"
215
+ - **Class 67:** "laptop"
216
+ - **Class 68:** "leaf"
217
+ - **Class 69:** "lion"
218
+ - **Class 70:** "lipstick"
219
+ - **Class 71:** "lobster"
220
+ - **Class 72:** "microphone"
221
+ - **Class 73:** "monkey"
222
+ - **Class 74:** "mosquito"
223
+ - **Class 75:** "mouse"
224
+ - **Class 76:** "mug"
225
+ - **Class 77:** "mushroom"
226
+ - **Class 78:** "onion"
227
+ - **Class 79:** "panda"
228
+ - **Class 80:** "peanut"
229
+ - **Class 81:** "pear"
230
+ - **Class 82:** "peas"
231
+ - **Class 83:** "pencil"
232
+ - **Class 84:** "penguin"
233
+ - **Class 85:** "pig"
234
+ - **Class 86:** "pillow"
235
+ - **Class 87:** "pineapple"
236
+ - **Class 88:** "potato"
237
+ - **Class 89:** "power_outlet"
238
+ - **Class 90:** "purse"
239
+ - **Class 91:** "rabbit"
240
+ - **Class 92:** "raccoon"
241
+ - **Class 93:** "rhinoceros"
242
+ - **Class 94:** "rifle"
243
+ - **Class 95:** "saxophone"
244
+ - **Class 96:** "screwdriver"
245
+ - **Class 97:** "sea_turtle"
246
+ - **Class 98:** "see_saw"
247
+ - **Class 99:** "sheep"
248
+ - **Class 100:** "shoe"
249
+ - **Class 101:** "skateboard"
250
+ - **Class 102:** "snake"
251
+ - **Class 103:** "speedboat"
252
+ - **Class 104:** "spider"
253
+ - **Class 105:** "squirrel"
254
+ - **Class 106:** "strawberry"
255
+ - **Class 107:** "streetlight"
256
+ - **Class 108:** "string_bean"
257
+ - **Class 109:** "submarine"
258
+ - **Class 110:** "swan"
259
+ - **Class 111:** "table"
260
+ - **Class 112:** "teapot"
261
+ - **Class 113:** "teddy-bear"
262
+ - **Class 114:** "television"
263
+ - **Class 115:** "the_Eiffel_Tower"
264
+ - **Class 116:** "the_Great_Wall_of_China"
265
+ - **Class 117:** "tiger"
266
+ - **Class 118:** "toe"
267
+ - **Class 119:** "train"
268
+ - **Class 120:** "truck"
269
+ - **Class 121:** "umbrella"
270
+ - **Class 122:** "vase"
271
+ - **Class 123:** "watermelon"
272
+ - **Class 124:** "whale"
273
+ - **Class 125:** "zebra"
274
+
275
+ # **Run with Transformers🤗**
276
+
277
+ ```python
278
+ !pip install -q transformers torch pillow gradio
279
+ ```
280
+
281
+ ```python
282
+ import gradio as gr
283
+ from transformers import AutoImageProcessor, SiglipForImageClassification
284
+ from transformers.image_utils import load_image
285
+ from PIL import Image
286
+ import torch
287
+
288
+ # Load model and processor
289
+ model_name = "prithivMLmods/Painting-126-DomainNet"
290
+ model = SiglipForImageClassification.from_pretrained(model_name)
291
+ processor = AutoImageProcessor.from_pretrained(model_name)
292
+
293
+ def painting_classification(image):
294
+ """Predicts the painting category for an input image."""
295
+ # Convert the input numpy array to a PIL image and ensure it is in RGB format
296
+ image = Image.fromarray(image).convert("RGB")
297
+
298
+ # Process the image for the model
299
+ inputs = processor(images=image, return_tensors="pt")
300
+
301
+ # Get predictions from the model without gradient computation
302
+ with torch.no_grad():
303
+ outputs = model(**inputs)
304
+ logits = outputs.logits
305
+ # Convert logits to probabilities using softmax
306
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
307
+
308
+ # Define the label mapping for each class index
309
+ labels = {
310
+ "0": "aircraft_carrier", "1": "alarm_clock", "2": "ant", "3": "anvil", "4": "asparagus",
311
+ "5": "axe", "6": "banana", "7": "basket", "8": "bathtub", "9": "bear",
312
+ "10": "bee", "11": "bird", "12": "blackberry", "13": "blueberry", "14": "bottlecap",
313
+ "15": "broccoli", "16": "bus", "17": "butterfly", "18": "cactus", "19": "cake",
314
+ "20": "calculator", "21": "camel", "22": "camera", "23": "candle", "24": "cannon",
315
+ "25": "canoe", "26": "carrot", "27": "castle", "28": "cat", "29": "ceiling_fan",
316
+ "30": "cell_phone", "31": "cello", "32": "chair", "33": "chandelier", "34": "coffee_cup",
317
+ "35": "compass", "36": "computer", "37": "cow", "38": "crab", "39": "crocodile",
318
+ "40": "cruise_ship", "41": "dog", "42": "dolphin", "43": "dragon", "44": "drums",
319
+ "45": "duck", "46": "dumbbell", "47": "elephant", "48": "eyeglasses", "49": "feather",
320
+ "50": "fence", "51": "fish", "52": "flamingo", "53": "flower", "54": "foot",
321
+ "55": "fork", "56": "frog", "57": "giraffe", "58": "goatee", "59": "grapes",
322
+ "60": "guitar", "61": "hammer", "62": "helicopter", "63": "helmet", "64": "horse",
323
+ "65": "kangaroo", "66": "lantern", "67": "laptop", "68": "leaf", "69": "lion",
324
+ "70": "lipstick", "71": "lobster", "72": "microphone", "73": "monkey", "74": "mosquito",
325
+ "75": "mouse", "76": "mug", "77": "mushroom", "78": "onion", "79": "panda",
326
+ "80": "peanut", "81": "pear", "82": "peas", "83": "pencil", "84": "penguin",
327
+ "85": "pig", "86": "pillow", "87": "pineapple", "88": "potato", "89": "power_outlet",
328
+ "90": "purse", "91": "rabbit", "92": "raccoon", "93": "rhinoceros", "94": "rifle",
329
+ "95": "saxophone", "96": "screwdriver", "97": "sea_turtle", "98": "see_saw", "99": "sheep",
330
+ "100": "shoe", "101": "skateboard", "102": "snake", "103": "speedboat", "104": "spider",
331
+ "105": "squirrel", "106": "strawberry", "107": "streetlight", "108": "string_bean",
332
+ "109": "submarine", "110": "swan", "111": "table", "112": "teapot", "113": "teddy-bear",
333
+ "114": "television", "115": "the_Eiffel_Tower", "116": "the_Great_Wall_of_China",
334
+ "117": "tiger", "118": "toe", "119": "train", "120": "truck", "121": "umbrella",
335
+ "122": "vase", "123": "watermelon", "124": "whale", "125": "zebra"
336
+ }
337
+
338
+ # Map each label to its corresponding probability (rounded)
339
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
340
+ return predictions
341
+
342
+ # Create Gradio interface for the painting classifier
343
+ iface = gr.Interface(
344
+ fn=painting_classification,
345
+ inputs=gr.Image(type="numpy"),
346
+ outputs=gr.Label(label="Prediction Scores"),
347
+ title="Painting-126-DomainNet Classification",
348
+ description="Upload a painting to classify it into one of 126 categories."
349
+ )
350
+
351
+ # Launch the app
352
+ if __name__ == "__main__":
353
+ iface.launch()
354
+ ```
355
+
356
+ # **Intended Use:**
357
+
358
+ The **Painting-126-DomainNet** model is designed for painting image classification. It categorizes paintings into a wide range of domains—from objects like an "aircraft_carrier" or "alarm_clock" to animals, plants, and everyday items. Potential use cases include:
359
+
360
+ - **Art Curation & Analysis:** Assisting galleries and museums in organizing and categorizing artworks.
361
+ - **Creative Search Engines:** Enabling painting-based search for art inspiration and research.
362
+ - **Educational Tools:** Supporting art education by categorizing and retrieving visual resources.
363
+ - **Computer Vision Research:** Providing a benchmark dataset for studies in painting recognition and domain adaptation tasks.