Views
No views yet

Clipart-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 clipart images into 126 domain categories using the SiglipForImageClassification architecture.

1Classification Report:
2 precision recall f1-score support
3
4 aircraft_carrier 0.8667 0.4643 0.6047 56
5 alarm_clock 0.9706 0.8919 0.9296 74
6 ant 0.8889 0.8615 0.8750 65
7 anvil 0.5984 0.6083 0.6033 120
8 asparagus 0.8158 0.6078 0.6966 51
9 axe 0.7544 0.5309 0.6232 81
10 banana 0.7111 0.5517 0.6214 58
11 basket 0.8571 0.8182 0.8372 66
12 bathtub 0.7531 0.7821 0.7673 78
13 bear 0.9118 0.6458 0.7561 48
14 bee 0.9636 0.9636 0.9636 165
15 bird 0.8967 0.9529 0.9240 255
16 blackberry 0.8082 0.8429 0.8252 70
17 blueberry 0.8661 0.8981 0.8818 108
18 bottlecap 0.7821 0.8299 0.8053 147
19 broccoli 0.8947 0.8947 0.8947 95
20 bus 0.9663 0.9348 0.9503 92
21 butterfly 0.9333 0.9545 0.9438 132
22 cactus 0.9677 0.9091 0.9375 99
23 cake 0.8750 0.8099 0.8412 121
24 calculator 0.9583 0.5897 0.7302 39
25 camel 0.9391 0.9310 0.9351 116
26 camera 0.8846 0.8679 0.8762 53
27 candle 0.8298 0.8478 0.8387 92
28 cannon 0.8551 0.8551 0.8551 69
29 canoe 0.8462 0.7432 0.7914 74
30 carrot 0.8800 0.7719 0.8224 57
31 castle 1.0000 0.8511 0.9195 47
32 cat 0.8167 0.7903 0.8033 62
33 ceiling_fan 1.0000 0.2000 0.3333 30
34 cell_phone 0.7400 0.6491 0.6916 57
35 cello 0.8372 0.9114 0.8727 79
36 chair 0.8986 0.8378 0.8671 74
37 chandelier 0.9617 0.9263 0.9437 190
38 coffee_cup 0.8811 0.9389 0.9091 229
39 compass 0.9799 0.9012 0.9389 162
40 computer 0.7124 0.9045 0.7970 178
41 cow 0.9517 0.9718 0.9617 142
42 crab 0.8738 0.9000 0.8867 100
43 crocodile 0.9778 0.9167 0.9462 144
44 cruise_ship 0.8544 0.9072 0.8800 194
45 dog 0.8125 0.7761 0.7939 67
46 dolphin 0.7680 0.7500 0.7589 128
47 dragon 0.9512 0.9176 0.9341 85
48 drums 0.8919 0.9635 0.9263 137
49 duck 0.8774 0.8447 0.8608 161
50 dumbbell 0.9048 0.9500 0.9268 280
51 elephant 0.9038 0.8952 0.8995 105
52 eyeglasses 0.8636 0.8488 0.8562 291
53 feather 0.8564 0.9227 0.8883 181
54 fence 0.9211 0.8400 0.8787 125
55 fish 0.8963 0.8768 0.8864 138
56 flamingo 0.9636 0.9381 0.9507 226
57 flower 0.9146 0.9454 0.9298 238
58 foot 0.8780 0.8889 0.8834 81
59 fork 0.9032 0.9091 0.9061 154
60 frog 0.9420 0.9489 0.9455 137
61 giraffe 0.9643 0.9153 0.9391 118
62 goatee 0.8763 0.9422 0.9081 173
63 grapes 0.9114 0.8571 0.8834 84
64 guitar 0.9595 0.8554 0.9045 83
65 hammer 0.6111 0.7719 0.6822 114
66 helicopter 0.9444 0.9533 0.9488 107
67 helmet 0.7368 0.8550 0.7915 131
68 horse 0.9588 0.9819 0.9702 166
69 kangaroo 0.9125 0.8488 0.8795 86
70 lantern 0.8254 0.7536 0.7879 69
71 laptop 0.8108 0.5000 0.6186 60
72 leaf 0.7143 0.3333 0.4545 30
73 lion 0.9744 0.8085 0.8837 47
74 lipstick 0.7875 0.6632 0.7200 95
75 lobster 0.8963 0.9130 0.9046 161
76 microphone 0.7925 0.9231 0.8528 91
77 monkey 0.9623 0.9027 0.9315 113
78 mosquito 0.8636 0.8444 0.8539 45
79 mouse 0.9167 0.8333 0.8730 66
80 mug 0.8989 0.8163 0.8556 98
81 mushroom 0.9429 0.9429 0.9429 105
82 onion 0.9365 0.8429 0.8872 140
83 panda 1.0000 0.9726 0.9861 73
84 peanut 0.5900 0.7195 0.6484 82
85 pear 0.7692 0.7246 0.7463 69
86 peas 0.8000 0.7429 0.7704 70
87 pencil 0.6667 0.0909 0.1600 44
88 penguin 0.9717 0.9279 0.9493 111
89 pig 0.9551 0.8252 0.8854 103
90 pillow 0.6290 0.5571 0.5909 70
91 pineapple 0.9846 0.8889 0.9343 72
92 potato 0.6038 0.6531 0.6275 98
93 power_outlet 0.8636 0.4043 0.5507 47
94 purse 0.0000 0.0000 0.0000 27
95 rabbit 0.9341 0.8586 0.8947 99
96 raccoon 0.8836 0.9021 0.8927 143
97 rhinoceros 0.8750 0.9459 0.9091 74
98 rifle 0.7595 0.7500 0.7547 80
99 saxophone 0.9454 0.9886 0.9665 175
100 screwdriver 0.7521 0.6929 0.7213 127
101 sea_turtle 0.9677 0.9626 0.9651 187
102 see_saw 0.6679 0.8698 0.7556 215
103 sheep 0.9355 0.9158 0.9255 95
104 shoe 0.8969 0.8700 0.8832 100
105 skateboard 0.8632 0.8673 0.8652 211
106 snake 0.9302 0.9160 0.9231 131
107 speedboat 0.8187 0.8976 0.8563 166
108 spider 0.9043 0.9286 0.9163 112
109 squirrel 0.7945 0.8855 0.8375 131
110 strawberry 0.8687 0.9923 0.9264 260
111 streetlight 0.8178 0.9293 0.8700 198
112 string_bean 0.8525 0.8000 0.8254 65
113 submarine 0.8022 0.8902 0.8439 164
114 swan 0.8397 0.9003 0.8690 291
115 table 0.8564 0.9200 0.8871 175
116 teapot 0.8763 0.9189 0.8971 185
117 teddy-bear 0.9006 0.8953 0.8980 172
118 television 0.8509 0.8220 0.8362 118
119 the_Eiffel_Tower 0.9468 0.9082 0.9271 98
120the_Great_Wall_of_China 0.9462 0.9462 0.9462 93
121 tiger 0.9417 0.9826 0.9617 230
122 toe 0.8250 0.6600 0.7333 50
123 train 0.9362 0.9778 0.9565 90
124 truck 0.9367 0.8916 0.9136 83
125 umbrella 0.9633 0.9545 0.9589 110
126 vase 0.7642 0.8393 0.8000 112
127 watermelon 0.9527 0.9527 0.9527 148
128 whale 0.7453 0.8144 0.7783 194
129 zebra 0.9275 0.9676 0.9471 185
130
131 accuracy 0.8691 14818
132 macro avg 0.8613 0.8251 0.8351 14818
133 weighted avg 0.8705 0.8691 0.8661 14818!pip install -q transformers torch pillow gradio1import gradio as gr
2from transformers import AutoImageProcessor, SiglipForImageClassification
3from transformers.image_utils import load_image
4from PIL import Image
5import torch
6
7# Load model and processor
8model_name = "prithivMLmods/Clipart-126-DomainNet"
9model = SiglipForImageClassification.from_pretrained(model_name)
10processor = AutoImageProcessor.from_pretrained(model_name)
11
12def clipart_classification(image):
13 """Predicts the clipart category for an input image."""
14 # Convert the input numpy array to a PIL Image and ensure it's in RGB format
15 image = Image.fromarray(image).convert("RGB")
16
17 # Process the image and prepare it for the model
18 inputs = processor(images=image, return_tensors="pt")
19
20 # Perform inference without gradient computation
21 with torch.no_grad():
22 outputs = model(**inputs)
23 logits = outputs.logits
24 # Apply softmax to obtain probabilities for each class
25 probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
26
27 # Mapping from indices to clipart category labels
28 labels = {
29 "0": "aircraft_carrier", "1": "alarm_clock", "2": "ant", "3": "anvil", "4": "asparagus",
30 "5": "axe", "6": "banana", "7": "basket", "8": "bathtub", "9": "bear",
31 "10": "bee", "11": "bird", "12": "blackberry", "13": "blueberry", "14": "bottlecap",
32 "15": "broccoli", "16": "bus", "17": "butterfly", "18": "cactus", "19": "cake",
33 "20": "calculator", "21": "camel", "22": "camera", "23": "candle", "24": "cannon",
34 "25": "canoe", "26": "carrot", "27": "castle", "28": "cat", "29": "ceiling_fan",
35 "30": "cell_phone", "31": "cello", "32": "chair", "33": "chandelier", "34": "coffee_cup",
36 "35": "compass", "36": "computer", "37": "cow", "38": "crab", "39": "crocodile",
37 "40": "cruise_ship", "41": "dog", "42": "dolphin", "43": "dragon", "44": "drums",
38 "45": "duck", "46": "dumbbell", "47": "elephant", "48": "eyeglasses", "49": "feather",
39 "50": "fence", "51": "fish", "52": "flamingo", "53": "flower", "54": "foot",
40 "55": "fork", "56": "frog", "57": "giraffe", "58": "goatee", "59": "grapes",
41 "60": "guitar", "61": "hammer", "62": "helicopter", "63": "helmet", "64": "horse",
42 "65": "kangaroo", "66": "lantern", "67": "laptop", "68": "leaf", "69": "lion",
43 "70": "lipstick", "71": "lobster", "72": "microphone", "73": "monkey", "74": "mosquito",
44 "75": "mouse", "76": "mug", "77": "mushroom", "78": "onion", "79": "panda",
45 "80": "peanut", "81": "pear", "82": "peas", "83": "pencil", "84": "penguin",
46 "85": "pig", "86": "pillow", "87": "pineapple", "88": "potato", "89": "power_outlet",
47 "90": "purse", "91": "rabbit", "92": "raccoon", "93": "rhinoceros", "94": "rifle",
48 "95": "saxophone", "96": "screwdriver", "97": "sea_turtle", "98": "see_saw", "99": "sheep",
49 "100": "shoe", "101": "skateboard", "102": "snake", "103": "speedboat", "104": "spider",
50 "105": "squirrel", "106": "strawberry", "107": "streetlight", "108": "string_bean",
51 "109": "submarine", "110": "swan", "111": "table", "112": "teapot", "113": "teddy-bear",
52 "114": "television", "115": "the_Eiffel_Tower", "116": "the_Great_Wall_of_China",
53 "117": "tiger", "118": "toe", "119": "train", "120": "truck", "121": "umbrella",
54 "122": "vase", "123": "watermelon", "124": "whale", "125": "zebra"
55 }
56
57 # Create a dictionary mapping each label to its corresponding probability (rounded)
58 predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
59 return predictions
60
61# Create Gradio interface
62iface = gr.Interface(
63 fn=clipart_classification,
64 inputs=gr.Image(type="numpy"),
65 outputs=gr.Label(label="Prediction Scores"),
66 title="Clipart-126-DomainNet Classification",
67 description="Upload a clipart image to classify it into one of 126 domain categories."
68)
69
70# Launch the app
71if __name__ == "__main__":
72 iface.launch()