prithivMLmods commited on
Commit
22ba041
·
verified ·
1 Parent(s): e1a07f6

Upload 20 files

Browse files
age_classification.py ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor
3
+ from transformers import SiglipForImageClassification
4
+ from transformers.image_utils import load_image
5
+ from PIL import Image
6
+ import torch
7
+
8
+ # Load model and processor
9
+ model_name = "prithivMLmods/Age-Classification-SigLIP2"
10
+ model = SiglipForImageClassification.from_pretrained(model_name)
11
+ processor = AutoImageProcessor.from_pretrained(model_name)
12
+
13
+ def age_classification(image):
14
+ """Predicts the age group of a person from an image."""
15
+ image = Image.fromarray(image).convert("RGB")
16
+ inputs = processor(images=image, return_tensors="pt")
17
+
18
+ with torch.no_grad():
19
+ outputs = model(**inputs)
20
+ logits = outputs.logits
21
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
22
+
23
+ labels = {
24
+ "0": "Child 0-12",
25
+ "1": "Teenager 13-20",
26
+ "2": "Adult 21-44",
27
+ "3": "Middle Age 45-64",
28
+ "4": "Aged 65+"
29
+ }
30
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
31
+
32
+ return predictions
33
+
34
+ # Create Gradio interface
35
+ iface = gr.Interface(
36
+ fn=age_classification,
37
+ inputs=gr.Image(type="numpy"),
38
+ outputs=gr.Label(label="Prediction Scores"),
39
+ title="Age Group Classification",
40
+ description="Upload an image to predict the person's age group."
41
+ )
42
+
43
+ # Launch the app
44
+ if __name__ == "__main__":
45
+ iface.launch()
alphabet_sign_language_detection.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor
3
+ from transformers import SiglipForImageClassification
4
+ from transformers.image_utils import load_image
5
+ from PIL import Image
6
+ import torch
7
+
8
+ # Load model and processor
9
+ model_name = "prithivMLmods/Alphabet-Sign-Language-Detection"
10
+ model = SiglipForImageClassification.from_pretrained(model_name)
11
+ processor = AutoImageProcessor.from_pretrained(model_name)
12
+
13
+ def sign_language_classification(image):
14
+ """Predicts sign language alphabet category for an image."""
15
+ image = Image.fromarray(image).convert("RGB")
16
+ inputs = processor(images=image, return_tensors="pt")
17
+
18
+ with torch.no_grad():
19
+ outputs = model(**inputs)
20
+ logits = outputs.logits
21
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
22
+
23
+ labels = {
24
+ "0": "A", "1": "B", "2": "C", "3": "D", "4": "E", "5": "F", "6": "G", "7": "H", "8": "I", "9": "J",
25
+ "10": "K", "11": "L", "12": "M", "13": "N", "14": "O", "15": "P", "16": "Q", "17": "R", "18": "S", "19": "T",
26
+ "20": "U", "21": "V", "22": "W", "23": "X", "24": "Y", "25": "Z"
27
+ }
28
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
29
+
30
+ return predictions
31
+
32
+ # Create Gradio interface
33
+ iface = gr.Interface(
34
+ fn=sign_language_classification,
35
+ inputs=gr.Image(type="numpy"),
36
+ outputs=gr.Label(label="Prediction Scores"),
37
+ title="Alphabet Sign Language Detection",
38
+ description="Upload an image to classify it into one of the 26 sign language alphabet categories."
39
+ )
40
+
41
+ # Launch the app
42
+ if __name__ == "__main__":
43
+ iface.launch()
app.py ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from transformers import AutoModel, AutoProcessor
4
+
5
+ from gender_classification import gender_classification
6
+ from emotion_classification import emotion_classification
7
+ from dog_breed import dog_breed_classification
8
+ from deepfake_quality import deepfake_classification
9
+ from gym_workout_classification import workout_classification
10
+ from augmented_waste_classifier import waste_classification
11
+ from age_classification import age_classification
12
+ from mnist_digits import classify_digit
13
+ from fashion_mnist_cloth import fashion_mnist_classification
14
+ from indian_western_food_classify import food_classification
15
+ from bird_species import bird_classification
16
+ from alphabet_sign_language_detection import sign_language_classification
17
+ from rice_leaf_disease import classify_leaf_disease
18
+ from traffic_density import traffic_density_classification
19
+ from clip_art import clipart_classification
20
+ from multisource_121 import multisource_classification
21
+ from painting_126 import painting_classification
22
+ from sketch_126 import sketch_classification # New import
23
+
24
+ # Main classification function for multi-model classification.
25
+ def classify(image, model_name):
26
+ if model_name == "gender":
27
+ return gender_classification(image)
28
+ elif model_name == "emotion":
29
+ return emotion_classification(image)
30
+ elif model_name == "dog breed":
31
+ return dog_breed_classification(image)
32
+ elif model_name == "deepfake":
33
+ return deepfake_classification(image)
34
+ elif model_name == "gym workout":
35
+ return workout_classification(image)
36
+ elif model_name == "waste":
37
+ return waste_classification(image)
38
+ elif model_name == "age":
39
+ return age_classification(image)
40
+ elif model_name == "mnist":
41
+ return classify_digit(image)
42
+ elif model_name == "fashion_mnist":
43
+ return fashion_mnist_classification(image)
44
+ elif model_name == "food":
45
+ return food_classification(image)
46
+ elif model_name == "bird":
47
+ return bird_classification(image)
48
+ elif model_name == "leaf disease":
49
+ return classify_leaf_disease(image)
50
+ elif model_name == "sign language":
51
+ return sign_language_classification(image)
52
+ elif model_name == "traffic density":
53
+ return traffic_density_classification(image)
54
+ elif model_name == "clip art":
55
+ return clipart_classification(image)
56
+ elif model_name == "multisource":
57
+ return multisource_classification(image)
58
+ elif model_name == "painting":
59
+ return painting_classification(image)
60
+ elif model_name == "sketch": # New option
61
+ return sketch_classification(image)
62
+ else:
63
+ return {"Error": "No model selected"}
64
+
65
+ # Function to update the selected model and button styles.
66
+ def select_model(model_name):
67
+ model_variants = {
68
+ "gender": "secondary", "emotion": "secondary", "dog breed": "secondary", "deepfake": "secondary",
69
+ "gym workout": "secondary", "waste": "secondary", "age": "secondary", "mnist": "secondary",
70
+ "fashion_mnist": "secondary", "food": "secondary", "bird": "secondary", "leaf disease": "secondary",
71
+ "sign language": "secondary", "traffic density": "secondary", "clip art": "secondary",
72
+ "multisource": "secondary", "painting": "secondary", "sketch": "secondary" # New model variant
73
+ }
74
+ model_variants[model_name] = "primary"
75
+ return (model_name, *(gr.update(variant=model_variants[key]) for key in model_variants))
76
+
77
+ # Zero-Shot Classification Setup (SigLIP models)
78
+ sg1_ckpt = "google/siglip-so400m-patch14-384"
79
+ siglip1_model = AutoModel.from_pretrained(sg1_ckpt, device_map="cpu").eval()
80
+ siglip1_processor = AutoProcessor.from_pretrained(sg1_ckpt)
81
+
82
+ sg2_ckpt = "google/siglip2-so400m-patch14-384"
83
+ siglip2_model = AutoModel.from_pretrained(sg2_ckpt, device_map="cpu").eval()
84
+ siglip2_processor = AutoProcessor.from_pretrained(sg2_ckpt)
85
+
86
+ def postprocess_siglip(sg1_probs, sg2_probs, labels):
87
+ sg1_output = {labels[i]: sg1_probs[0][i].item() for i in range(len(labels))}
88
+ sg2_output = {labels[i]: sg2_probs[0][i].item() for i in range(len(labels))}
89
+ return sg1_output, sg2_output
90
+
91
+ def siglip_detector(image, texts):
92
+ sg1_inputs = siglip1_processor(
93
+ text=texts, images=image, return_tensors="pt", padding="max_length", max_length=64
94
+ ).to("cpu")
95
+ sg2_inputs = siglip2_processor(
96
+ text=texts, images=image, return_tensors="pt", padding="max_length", max_length=64
97
+ ).to("cpu")
98
+ with torch.no_grad():
99
+ sg1_outputs = siglip1_model(**sg1_inputs)
100
+ sg2_outputs = siglip2_model(**sg2_inputs)
101
+ sg1_logits_per_image = sg1_outputs.logits_per_image
102
+ sg2_logits_per_image = sg2_outputs.logits_per_image
103
+ sg1_probs = torch.sigmoid(sg1_logits_per_image)
104
+ sg2_probs = torch.sigmoid(sg2_logits_per_image)
105
+ return sg1_probs, sg2_probs
106
+
107
+ def infer(image, candidate_labels):
108
+ candidate_labels = [label.lstrip(" ") for label in candidate_labels.split(",")]
109
+ sg1_probs, sg2_probs = siglip_detector(image, candidate_labels)
110
+ return postprocess_siglip(sg1_probs, sg2_probs, labels=candidate_labels)
111
+
112
+ # Build the Gradio Interface with two tabs.
113
+ with gr.Blocks(theme="YTheme/Minecraft") as demo:
114
+ gr.Markdown("# Multi-Domain & Zero-Shot Image Classification")
115
+
116
+ with gr.Tabs():
117
+ # Tab 1: Multi-Model Classification
118
+ with gr.Tab("Multi-Domain Classification"):
119
+ with gr.Sidebar():
120
+ gr.Markdown("# Choose Domain")
121
+ with gr.Row():
122
+ age_btn = gr.Button("Age Classification", variant="primary")
123
+ gender_btn = gr.Button("Gender Classification", variant="secondary")
124
+ emotion_btn = gr.Button("Emotion Classification", variant="secondary")
125
+ gym_workout_btn = gr.Button("Gym Workout Classification", variant="secondary")
126
+ dog_breed_btn = gr.Button("Dog Breed Classification", variant="secondary")
127
+ bird_btn = gr.Button("Bird Species Classification", variant="secondary")
128
+ waste_btn = gr.Button("Waste Classification", variant="secondary")
129
+ deepfake_btn = gr.Button("Deepfake Quality Test", variant="secondary")
130
+ traffic_density_btn = gr.Button("Traffic Density", variant="secondary")
131
+ sign_language_btn = gr.Button("Alphabet Sign Language", variant="secondary")
132
+ clip_art_btn = gr.Button("Clip Art 126", variant="secondary")
133
+ mnist_btn = gr.Button("Digit Classify (0-9)", variant="secondary")
134
+ fashion_mnist_btn = gr.Button("Fashion MNIST (only cloth)", variant="secondary")
135
+ food_btn = gr.Button("Indian/Western Food Type", variant="secondary")
136
+ leaf_disease_btn = gr.Button("Rice Leaf Disease", variant="secondary")
137
+ multisource_btn = gr.Button("Multi Source 121", variant="secondary")
138
+ painting_btn = gr.Button("Painting 126", variant="secondary")
139
+ sketch_btn = gr.Button("Sketch 126", variant="secondary")
140
+
141
+ selected_model = gr.State("age")
142
+ gr.Markdown("### Current Model:")
143
+ model_display = gr.Textbox(value="age", interactive=False)
144
+ selected_model.change(lambda m: m, selected_model, model_display)
145
+
146
+ buttons = [
147
+ gender_btn, emotion_btn, dog_breed_btn, deepfake_btn, gym_workout_btn, waste_btn,
148
+ age_btn, mnist_btn, fashion_mnist_btn, food_btn, bird_btn, leaf_disease_btn,
149
+ sign_language_btn, traffic_density_btn, clip_art_btn, multisource_btn, painting_btn, sketch_btn # Include new button
150
+ ]
151
+ model_names = [
152
+ "gender", "emotion", "dog breed", "deepfake", "gym workout", "waste",
153
+ "age", "mnist", "fashion_mnist", "food", "bird", "leaf disease",
154
+ "sign language", "traffic density", "clip art", "multisource", "painting", "sketch" # New model name
155
+ ]
156
+
157
+ for btn, name in zip(buttons, model_names):
158
+ btn.click(fn=lambda n=name: select_model(n), inputs=[], outputs=[selected_model] + buttons)
159
+
160
+ with gr.Row():
161
+ with gr.Column():
162
+ image_input = gr.Image(type="numpy", label="Upload Image")
163
+ analyze_btn = gr.Button("Classify / Predict")
164
+ output_label = gr.Label(label="Prediction Scores")
165
+ analyze_btn.click(fn=classify, inputs=[image_input, selected_model], outputs=output_label)
166
+
167
+ # Tab 2: Zero-Shot Classification (SigLIP)
168
+ with gr.Tab("Zero-Shot Classification"):
169
+ gr.Markdown("## Compare SigLIP 1 and SigLIP 2 on Zero-Shot Classification")
170
+ with gr.Row():
171
+ with gr.Column():
172
+ zs_image_input = gr.Image(type="pil", label="Upload Image")
173
+ zs_text_input = gr.Textbox(label="Input a list of labels (comma separated)")
174
+ zs_run_button = gr.Button("Run")
175
+ with gr.Column():
176
+ siglip1_output = gr.Label(label="SigLIP 1 Output", num_top_classes=3)
177
+ siglip2_output = gr.Label(label="SigLIP 2 Output", num_top_classes=3)
178
+ zs_run_button.click(fn=infer, inputs=[zs_image_input, zs_text_input], outputs=[siglip1_output, siglip2_output])
179
+
180
+ demo.launch()
augmented_waste_classifier.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor
3
+ from transformers import SiglipForImageClassification
4
+ from transformers.image_utils import load_image
5
+ from PIL import Image
6
+ import torch
7
+
8
+ # Load model and processor
9
+ model_name = "prithivMLmods/Augmented-Waste-Classifier-SigLIP2"
10
+ model = SiglipForImageClassification.from_pretrained(model_name)
11
+ processor = AutoImageProcessor.from_pretrained(model_name)
12
+
13
+ def waste_classification(image):
14
+ """Predicts waste classification for an image."""
15
+ image = Image.fromarray(image).convert("RGB")
16
+ inputs = processor(images=image, return_tensors="pt")
17
+
18
+ with torch.no_grad():
19
+ outputs = model(**inputs)
20
+ logits = outputs.logits
21
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
22
+
23
+ labels = {
24
+ "0": "Battery", "1": "Biological", "2": "Cardboard", "3": "Clothes",
25
+ "4": "Glass", "5": "Metal", "6": "Paper", "7": "Plastic",
26
+ "8": "Shoes", "9": "Trash"
27
+ }
28
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
29
+
30
+ return predictions
31
+
32
+ # Create Gradio interface
33
+ iface = gr.Interface(
34
+ fn=waste_classification,
35
+ inputs=gr.Image(type="numpy"),
36
+ outputs=gr.Label(label="Prediction Scores"),
37
+ title="Augmented Waste Classification",
38
+ description="Upload an image to classify the type of waste."
39
+ )
40
+
41
+ # Launch the app
42
+ if __name__ == "__main__":
43
+ iface.launch()
bird_species.py ADDED
@@ -0,0 +1,564 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor
3
+ from transformers import SiglipForImageClassification
4
+ from PIL import Image
5
+ import torch
6
+
7
+ # Load model and processor with the new bird classifier name
8
+ model_name = "prithivMLmods/Bird-Species-Classifier-526"
9
+ model = SiglipForImageClassification.from_pretrained(model_name)
10
+ processor = AutoImageProcessor.from_pretrained(model_name)
11
+
12
+ def bird_classification(image):
13
+ """Predicts bird species classification for an image."""
14
+ image = Image.fromarray(image).convert("RGB")
15
+ inputs = processor(images=image, return_tensors="pt")
16
+
17
+ with torch.no_grad():
18
+ outputs = model(**inputs)
19
+ logits = outputs.logits
20
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
21
+
22
+ labels = {
23
+ "0": "ABBOTTS BABBLER",
24
+ "1": "ABBOTTS BOOBY",
25
+ "2": "ABYSSINIAN GROUND HORNBILL",
26
+ "3": "AFRICAN CROWNED CRANE",
27
+ "4": "AFRICAN EMERALD CUCKOO",
28
+ "5": "AFRICAN FIREFINCH",
29
+ "6": "AFRICAN OYSTER CATCHER",
30
+ "7": "AFRICAN PIED HORNBILL",
31
+ "8": "AFRICAN PYGMY GOOSE",
32
+ "9": "ALBATROSS",
33
+ "10": "ALBERTS TOWHEE",
34
+ "11": "ALEXANDRINE PARAKEET",
35
+ "12": "ALPINE CHOUGH",
36
+ "13": "ALTAMIRA YELLOWTHROAT",
37
+ "14": "AMERICAN AVOCET",
38
+ "15": "AMERICAN BITTERN",
39
+ "16": "AMERICAN COOT",
40
+ "17": "AMERICAN DIPPER",
41
+ "18": "AMERICAN FLAMINGO",
42
+ "19": "AMERICAN GOLDFINCH",
43
+ "20": "AMERICAN KESTREL",
44
+ "21": "AMERICAN PIPIT",
45
+ "22": "AMERICAN REDSTART",
46
+ "23": "AMERICAN ROBIN",
47
+ "24": "AMERICAN WIGEON",
48
+ "25": "AMETHYST WOODSTAR",
49
+ "26": "ANDEAN GOOSE",
50
+ "27": "ANDEAN LAPWING",
51
+ "28": "ANDEAN SISKIN",
52
+ "29": "ANHINGA",
53
+ "30": "ANIANIAU",
54
+ "31": "ANNAS HUMMINGBIRD",
55
+ "32": "ANTBIRD",
56
+ "33": "ANTILLEAN EUPHONIA",
57
+ "34": "APAPANE",
58
+ "35": "APOSTLEBIRD",
59
+ "36": "ARARIPE MANAKIN",
60
+ "37": "ASHY STORM PETREL",
61
+ "38": "ASHY THRUSHBIRD",
62
+ "39": "ASIAN CRESTED IBIS",
63
+ "40": "ASIAN DOLLARD BIRD",
64
+ "41": "ASIAN GREEN BEE EATER",
65
+ "42": "ASIAN OPENBILL STORK",
66
+ "43": "AUCKLAND SHAQ",
67
+ "44": "AUSTRAL CANASTERO",
68
+ "45": "AUSTRALASIAN FIGBIRD",
69
+ "46": "AVADAVAT",
70
+ "47": "AZARAS SPINETAIL",
71
+ "48": "AZURE BREASTED PITTA",
72
+ "49": "AZURE JAY",
73
+ "50": "AZURE TANAGER",
74
+ "51": "AZURE TIT",
75
+ "52": "BAIKAL TEAL",
76
+ "53": "BALD EAGLE",
77
+ "54": "BALD IBIS",
78
+ "55": "BALI STARLING",
79
+ "56": "BALTIMORE ORIOLE",
80
+ "57": "BANANAQUIT",
81
+ "58": "BAND TAILED GUAN",
82
+ "59": "BANDED BROADBILL",
83
+ "60": "BANDED PITA",
84
+ "61": "BANDED STILT",
85
+ "62": "BAR-TAILED GODWIT",
86
+ "63": "BARN OWL",
87
+ "64": "BARN SWALLOW",
88
+ "65": "BARRED PUFFBIRD",
89
+ "66": "BARROWS GOLDENEYE",
90
+ "67": "BAY-BREASTED WARBLER",
91
+ "68": "BEARDED BARBET",
92
+ "69": "BEARDED BELLBIRD",
93
+ "70": "BEARDED REEDLING",
94
+ "71": "BELTED KINGFISHER",
95
+ "72": "BIRD OF PARADISE",
96
+ "73": "BLACK AND YELLOW BROADBILL",
97
+ "74": "BLACK BAZA",
98
+ "75": "BLACK BREASTED PUFFBIRD",
99
+ "76": "BLACK COCKATO",
100
+ "77": "BLACK FACED SPOONBILL",
101
+ "78": "BLACK FRANCOLIN",
102
+ "79": "BLACK HEADED CAIQUE",
103
+ "80": "BLACK NECKED STILT",
104
+ "81": "BLACK SKIMMER",
105
+ "82": "BLACK SWAN",
106
+ "83": "BLACK TAIL CRAKE",
107
+ "84": "BLACK THROATED BUSHTIT",
108
+ "85": "BLACK THROATED HUET",
109
+ "86": "BLACK THROATED WARBLER",
110
+ "87": "BLACK VENTED SHEARWATER",
111
+ "88": "BLACK VULTURE",
112
+ "89": "BLACK-CAPPED CHICKADEE",
113
+ "90": "BLACK-NECKED GREBE",
114
+ "91": "BLACK-THROATED SPARROW",
115
+ "92": "BLACKBURNIAM WARBLER",
116
+ "93": "BLONDE CRESTED WOODPECKER",
117
+ "94": "BLOOD PHEASANT",
118
+ "95": "BLUE COAU",
119
+ "96": "BLUE DACNIS",
120
+ "97": "BLUE GRAY GNATCATCHER",
121
+ "98": "BLUE GROSBEAK",
122
+ "99": "BLUE GROUSE",
123
+ "100": "BLUE HERON",
124
+ "101": "BLUE MALKOHA",
125
+ "102": "BLUE THROATED PIPING GUAN",
126
+ "103": "BLUE THROATED TOUCANET",
127
+ "104": "BOBOLINK",
128
+ "105": "BORNEAN BRISTLEHEAD",
129
+ "106": "BORNEAN LEAFBIRD",
130
+ "107": "BORNEAN PHEASANT",
131
+ "108": "BRANDT CORMARANT",
132
+ "109": "BREWERS BLACKBIRD",
133
+ "110": "BROWN CREPPER",
134
+ "111": "BROWN HEADED COWBIRD",
135
+ "112": "BROWN NOODY",
136
+ "113": "BROWN THRASHER",
137
+ "114": "BUFFLEHEAD",
138
+ "115": "BULWERS PHEASANT",
139
+ "116": "BURCHELLS COURSER",
140
+ "117": "BUSH TURKEY",
141
+ "118": "CAATINGA CACHOLOTE",
142
+ "119": "CABOTS TRAGOPAN",
143
+ "120": "CACTUS WREN",
144
+ "121": "CALIFORNIA CONDOR",
145
+ "122": "CALIFORNIA GULL",
146
+ "123": "CALIFORNIA QUAIL",
147
+ "124": "CAMPO FLICKER",
148
+ "125": "CANARY",
149
+ "126": "CANVASBACK",
150
+ "127": "CAPE GLOSSY STARLING",
151
+ "128": "CAPE LONGCLAW",
152
+ "129": "CAPE MAY WARBLER",
153
+ "130": "CAPE ROCK THRUSH",
154
+ "131": "CAPPED HERON",
155
+ "132": "CAPUCHINBIRD",
156
+ "133": "CARMINE BEE-EATER",
157
+ "134": "CASPIAN TERN",
158
+ "135": "CASSOWARY",
159
+ "136": "CEDAR WAXWING",
160
+ "137": "CERULEAN WARBLER",
161
+ "138": "CHARA DE COLLAR",
162
+ "139": "CHATTERING LORY",
163
+ "140": "CHESTNET BELLIED EUPHONIA",
164
+ "141": "CHESTNUT WINGED CUCKOO",
165
+ "142": "CHINESE BAMBOO PARTRIDGE",
166
+ "143": "CHINESE POND HERON",
167
+ "144": "CHIPPING SPARROW",
168
+ "145": "CHUCAO TAPACULO",
169
+ "146": "CHUKAR PARTRIDGE",
170
+ "147": "CINNAMON ATTILA",
171
+ "148": "CINNAMON FLYCATCHER",
172
+ "149": "CINNAMON TEAL",
173
+ "150": "CLARKS GREBE",
174
+ "151": "CLARKS NUTCRACKER",
175
+ "152": "COCK OF THE ROCK",
176
+ "153": "COCKATOO",
177
+ "154": "COLLARED ARACARI",
178
+ "155": "COLLARED CRESCENTCHEST",
179
+ "156": "COMMON FIRECREST",
180
+ "157": "COMMON GRACKLE",
181
+ "158": "COMMON HOUSE MARTIN",
182
+ "159": "COMMON IORA",
183
+ "160": "COMMON LOON",
184
+ "161": "COMMON POORWILL",
185
+ "162": "COMMON STARLING",
186
+ "163": "COPPERSMITH BARBET",
187
+ "164": "COPPERY TAILED COUCAL",
188
+ "165": "CRAB PLOVER",
189
+ "166": "CRANE HAWK",
190
+ "167": "CREAM COLORED WOODPECKER",
191
+ "168": "CRESTED AUKLET",
192
+ "169": "CRESTED CARACARA",
193
+ "170": "CRESTED COUA",
194
+ "171": "CRESTED FIREBACK",
195
+ "172": "CRESTED KINGFISHER",
196
+ "173": "CRESTED NUTHATCH",
197
+ "174": "CRESTED OROPENDOLA",
198
+ "175": "CRESTED SERPENT EAGLE",
199
+ "176": "CRESTED SHRIKETIT",
200
+ "177": "CRESTED WOOD PARTRIDGE",
201
+ "178": "CRIMSON CHAT",
202
+ "179": "CRIMSON SUNBIRD",
203
+ "180": "CROW",
204
+ "181": "CUBAN TODY",
205
+ "182": "CUBAN TROGON",
206
+ "183": "CURL CRESTED ARACURI",
207
+ "184": "D-ARNAUDS BARBET",
208
+ "185": "DALMATIAN PELICAN",
209
+ "186": "DARJEELING WOODPECKER",
210
+ "187": "DARK EYED JUNCO",
211
+ "188": "DAURIAN REDSTART",
212
+ "189": "DEMOISELLE CRANE",
213
+ "190": "DOUBLE BARRED FINCH",
214
+ "191": "DOUBLE BRESTED CORMARANT",
215
+ "192": "DOUBLE EYED FIG PARROT",
216
+ "193": "DOWNY WOODPECKER",
217
+ "194": "DUNLIN",
218
+ "195": "DUSKY LORY",
219
+ "196": "DUSKY ROBIN",
220
+ "197": "EARED PITA",
221
+ "198": "EASTERN BLUEBIRD",
222
+ "199": "EASTERN BLUEBONNET",
223
+ "200": "EASTERN GOLDEN WEAVER",
224
+ "201": "EASTERN MEADOWLARK",
225
+ "202": "EASTERN ROSELLA",
226
+ "203": "EASTERN TOWEE",
227
+ "204": "EASTERN WIP POOR WILL",
228
+ "205": "EASTERN YELLOW ROBIN",
229
+ "206": "ECUADORIAN HILLSTAR",
230
+ "207": "EGYPTIAN GOOSE",
231
+ "208": "ELEGANT TROGON",
232
+ "209": "ELLIOTS PHEASANT",
233
+ "210": "EMERALD TANAGER",
234
+ "211": "EMPEROR PENGUIN",
235
+ "212": "EMU",
236
+ "213": "ENGGANO MYNA",
237
+ "214": "EURASIAN BULLFINCH",
238
+ "215": "EURASIAN GOLDEN ORIOLE",
239
+ "216": "EURASIAN MAGPIE",
240
+ "217": "EUROPEAN GOLDFINCH",
241
+ "218": "EUROPEAN TURTLE DOVE",
242
+ "219": "EVENING GROSBEAK",
243
+ "220": "FAIRY BLUEBIRD",
244
+ "221": "FAIRY PENGUIN",
245
+ "222": "FAIRY TERN",
246
+ "223": "FAN TAILED WIDOW",
247
+ "224": "FASCIATED WREN",
248
+ "225": "FIERY MINIVET",
249
+ "226": "FIORDLAND PENGUIN",
250
+ "227": "FIRE TAILLED MYZORNIS",
251
+ "228": "FLAME BOWERBIRD",
252
+ "229": "FLAME TANAGER",
253
+ "230": "FOREST WAGTAIL",
254
+ "231": "FRIGATE",
255
+ "232": "FRILL BACK PIGEON",
256
+ "233": "GAMBELS QUAIL",
257
+ "234": "GANG GANG COCKATOO",
258
+ "235": "GILA WOODPECKER",
259
+ "236": "GILDED FLICKER",
260
+ "237": "GLOSSY IBIS",
261
+ "238": "GO AWAY BIRD",
262
+ "239": "GOLD WING WARBLER",
263
+ "240": "GOLDEN BOWER BIRD",
264
+ "241": "GOLDEN CHEEKED WARBLER",
265
+ "242": "GOLDEN CHLOROPHONIA",
266
+ "243": "GOLDEN EAGLE",
267
+ "244": "GOLDEN PARAKEET",
268
+ "245": "GOLDEN PHEASANT",
269
+ "246": "GOLDEN PIPIT",
270
+ "247": "GOULDIAN FINCH",
271
+ "248": "GRANDALA",
272
+ "249": "GRAY CATBIRD",
273
+ "250": "GRAY KINGBIRD",
274
+ "251": "GRAY PARTRIDGE",
275
+ "252": "GREAT ARGUS",
276
+ "253": "GREAT GRAY OWL",
277
+ "254": "GREAT JACAMAR",
278
+ "255": "GREAT KISKADEE",
279
+ "256": "GREAT POTOO",
280
+ "257": "GREAT TINAMOU",
281
+ "258": "GREAT XENOPS",
282
+ "259": "GREATER PEWEE",
283
+ "260": "GREATER PRAIRIE CHICKEN",
284
+ "261": "GREATOR SAGE GROUSE",
285
+ "262": "GREEN BROADBILL",
286
+ "263": "GREEN JAY",
287
+ "264": "GREEN MAGPIE",
288
+ "265": "GREEN WINGED DOVE",
289
+ "266": "GREY CUCKOOSHRIKE",
290
+ "267": "GREY HEADED CHACHALACA",
291
+ "268": "GREY HEADED FISH EAGLE",
292
+ "269": "GREY PLOVER",
293
+ "270": "GROVED BILLED ANI",
294
+ "271": "GUINEA TURACO",
295
+ "272": "GUINEAFOWL",
296
+ "273": "GURNEYS PITTA",
297
+ "274": "GYRFALCON",
298
+ "275": "HAMERKOP",
299
+ "276": "HARLEQUIN DUCK",
300
+ "277": "HARLEQUIN QUAIL",
301
+ "278": "HARPY EAGLE",
302
+ "279": "HAWAIIAN GOOSE",
303
+ "280": "HAWFINCH",
304
+ "281": "HELMET VANGA",
305
+ "282": "HEPATIC TANAGER",
306
+ "283": "HIMALAYAN BLUETAIL",
307
+ "284": "HIMALAYAN MONAL",
308
+ "285": "HOATZIN",
309
+ "286": "HOODED MERGANSER",
310
+ "287": "HOOPOES",
311
+ "288": "HORNED GUAN",
312
+ "289": "HORNED LARK",
313
+ "290": "HORNED SUNGEM",
314
+ "291": "HOUSE FINCH",
315
+ "292": "HOUSE SPARROW",
316
+ "293": "HYACINTH MACAW",
317
+ "294": "IBERIAN MAGPIE",
318
+ "295": "IBISBILL",
319
+ "296": "IMPERIAL SHAQ",
320
+ "297": "INCA TERN",
321
+ "298": "INDIAN BUSTARD",
322
+ "299": "INDIAN PITTA",
323
+ "300": "INDIAN ROLLER",
324
+ "301": "INDIAN VULTURE",
325
+ "302": "INDIGO BUNTING",
326
+ "303": "INDIGO FLYCATCHER",
327
+ "304": "INLAND DOTTEREL",
328
+ "305": "IVORY BILLED ARACARI",
329
+ "306": "IVORY GULL",
330
+ "307": "IWI",
331
+ "308": "JABIRU",
332
+ "309": "JACK SNIPE",
333
+ "310": "JACOBIN PIGEON",
334
+ "311": "JANDAYA PARAKEET",
335
+ "312": "JAPANESE ROBIN",
336
+ "313": "JAVA SPARROW",
337
+ "314": "JOCOTOCO ANTPITTA",
338
+ "315": "KAGU",
339
+ "316": "KAKAPO",
340
+ "317": "KILLDEAR",
341
+ "318": "KING EIDER",
342
+ "319": "KING VULTURE",
343
+ "320": "KIWI",
344
+ "321": "KNOB BILLED DUCK",
345
+ "322": "KOOKABURRA",
346
+ "323": "LARK BUNTING",
347
+ "324": "LAUGHING GULL",
348
+ "325": "LAZULI BUNTING",
349
+ "326": "LESSER ADJUTANT",
350
+ "327": "LILAC ROLLER",
351
+ "328": "LIMPKIN",
352
+ "329": "LITTLE AUK",
353
+ "330": "LOGGERHEAD SHRIKE",
354
+ "331": "LONG-EARED OWL",
355
+ "332": "LOONEY BIRDS",
356
+ "333": "LUCIFER HUMMINGBIRD",
357
+ "334": "MAGPIE GOOSE",
358
+ "335": "MALABAR HORNBILL",
359
+ "336": "MALACHITE KINGFISHER",
360
+ "337": "MALAGASY WHITE EYE",
361
+ "338": "MALEO",
362
+ "339": "MALLARD DUCK",
363
+ "340": "MANDRIN DUCK",
364
+ "341": "MANGROVE CUCKOO",
365
+ "342": "MARABOU STORK",
366
+ "343": "MASKED BOBWHITE",
367
+ "344": "MASKED BOOBY",
368
+ "345": "MASKED LAPWING",
369
+ "346": "MCKAYS BUNTING",
370
+ "347": "MERLIN",
371
+ "348": "MIKADO PHEASANT",
372
+ "349": "MILITARY MACAW",
373
+ "350": "MOURNING DOVE",
374
+ "351": "MYNA",
375
+ "352": "NICOBAR PIGEON",
376
+ "353": "NOISY FRIARBIRD",
377
+ "354": "NORTHERN BEARDLESS TYRANNULET",
378
+ "355": "NORTHERN CARDINAL",
379
+ "356": "NORTHERN FLICKER",
380
+ "357": "NORTHERN FULMAR",
381
+ "358": "NORTHERN GANNET",
382
+ "359": "NORTHERN GOSHAWK",
383
+ "360": "NORTHERN JACANA",
384
+ "361": "NORTHERN MOCKINGBIRD",
385
+ "362": "NORTHERN PARULA",
386
+ "363": "NORTHERN RED BISHOP",
387
+ "364": "NORTHERN SHOVELER",
388
+ "365": "OCELLATED TURKEY",
389
+ "366": "OILBIRD",
390
+ "367": "OKINAWA RAIL",
391
+ "368": "ORANGE BREASTED TROGON",
392
+ "369": "ORANGE BRESTED BUNTING",
393
+ "370": "ORIENTAL BAY OWL",
394
+ "371": "ORNATE HAWK EAGLE",
395
+ "372": "OSPREY",
396
+ "373": "OSTRICH",
397
+ "374": "OVENBIRD",
398
+ "375": "OYSTER CATCHER",
399
+ "376": "PAINTED BUNTING",
400
+ "377": "PALILA",
401
+ "378": "PALM NUT VULTURE",
402
+ "379": "PARADISE TANAGER",
403
+ "380": "PARAKETT AUKLET",
404
+ "381": "PARAKETT AUKLET",
405
+ "382": "PARUS MAJOR",
406
+ "383": "PATAGONIAN SIERRA FINCH",
407
+ "384": "PEACOCK",
408
+ "385": "PEREGRINE FALCON",
409
+ "386": "PHAINOPEPLA",
410
+ "387": "PHILIPPINE EAGLE",
411
+ "388": "PINK ROBIN",
412
+ "389": "PLUSH CRESTED JAY",
413
+ "390": "POMARINE JAEGER",
414
+ "391": "PUFFIN",
415
+ "392": "PUNA TEAL",
416
+ "393": "PURPLE FINCH",
417
+ "394": "PURPLE GALLINULE",
418
+ "395": "PURPLE MARTIN",
419
+ "396": "PURPLE SWAMPHEN",
420
+ "397": "PYGMY KINGFISHER",
421
+ "398": "PYRRHULOXIA",
422
+ "399": "QUETZAL",
423
+ "400": "RAINBOW LORIKEET",
424
+ "401": "RAZORBILL",
425
+ "402": "RED BEARDED BEE EATER",
426
+ "403": "RED BELLIED PITTA",
427
+ "404": "RED BILLED TROPICBIRD",
428
+ "405": "RED BROWED FINCH",
429
+ "406": "RED CROSSBILL",
430
+ "407": "RED FACED CORMORANT",
431
+ "408": "RED FACED WARBLER",
432
+ "409": "RED FODY",
433
+ "410": "RED HEADED DUCK",
434
+ "411": "RED HEADED WOODPECKER",
435
+ "412": "RED KNOT",
436
+ "413": "RED LEGGED HONEYCREEPER",
437
+ "414": "RED NAPED TROGON",
438
+ "415": "RED SHOULDERED HAWK",
439
+ "416": "RED TAILED HAWK",
440
+ "417": "RED TAILED THRUSH",
441
+ "418": "RED WINGED BLACKBIRD",
442
+ "419": "RED WISKERED BULBUL",
443
+ "420": "REGENT BOWERBIRD",
444
+ "421": "RING-NECKED PHEASANT",
445
+ "422": "ROADRUNNER",
446
+ "423": "ROCK DOVE",
447
+ "424": "ROSE BREASTED COCKATOO",
448
+ "425": "ROSE BREASTED GROSBEAK",
449
+ "426": "ROSEATE SPOONBILL",
450
+ "427": "ROSY FACED LOVEBIRD",
451
+ "428": "ROUGH LEG BUZZARD",
452
+ "429": "ROYAL FLYCATCHER",
453
+ "430": "RUBY CROWNED KINGLET",
454
+ "431": "RUBY THROATED HUMMINGBIRD",
455
+ "432": "RUDDY SHELDUCK",
456
+ "433": "RUDY KINGFISHER",
457
+ "434": "RUFOUS KINGFISHER",
458
+ "435": "RUFOUS TREPE",
459
+ "436": "RUFUOS MOTMOT",
460
+ "437": "SAMATRAN THRUSH",
461
+ "438": "SAND MARTIN",
462
+ "439": "SANDHILL CRANE",
463
+ "440": "SATYR TRAGOPAN",
464
+ "441": "SAYS PHOEBE",
465
+ "442": "SCARLET CROWNED FRUIT DOVE",
466
+ "443": "SCARLET FACED LIOCICHLA",
467
+ "444": "SCARLET IBIS",
468
+ "445": "SCARLET MACAW",
469
+ "446": "SCARLET TANAGER",
470
+ "447": "SHOEBILL",
471
+ "448": "SHORT BILLED DOWITCHER",
472
+ "449": "SMITHS LONGSPUR",
473
+ "450": "SNOW GOOSE",
474
+ "451": "SNOW PARTRIDGE",
475
+ "452": "SNOWY EGRET",
476
+ "453": "SNOWY OWL",
477
+ "454": "SNOWY PLOVER",
478
+ "455": "SNOWY SHEATHBILL",
479
+ "456": "SORA",
480
+ "457": "SPANGLED COTINGA",
481
+ "458": "SPLENDID WREN",
482
+ "459": "SPOON BILED SANDPIPER",
483
+ "460": "SPOTTED CATBIRD",
484
+ "461": "SPOTTED WHISTLING DUCK",
485
+ "462": "SQUACCO HERON",
486
+ "463": "SRI LANKA BLUE MAGPIE",
487
+ "464": "STEAMER DUCK",
488
+ "465": "STORK BILLED KINGFISHER",
489
+ "466": "STRIATED CARACARA",
490
+ "467": "STRIPED OWL",
491
+ "468": "STRIPPED MANAKIN",
492
+ "469": "STRIPPED SWALLOW",
493
+ "470": "SUNBITTERN",
494
+ "471": "SUPERB STARLING",
495
+ "472": "SURF SCOTER",
496
+ "473": "SWINHOES PHEASANT",
497
+ "474": "TAILORBIRD",
498
+ "475": "TAIWAN MAGPIE",
499
+ "476": "TAKAHE",
500
+ "477": "TASMANIAN HEN",
501
+ "478": "TAWNY FROGMOUTH",
502
+ "479": "TEAL DUCK",
503
+ "480": "TIT MOUSE",
504
+ "481": "TOUCHAN",
505
+ "482": "TOWNSENDS WARBLER",
506
+ "483": "TREE SWALLOW",
507
+ "484": "TRICOLORED BLACKBIRD",
508
+ "485": "TROPICAL KINGBIRD",
509
+ "486": "TRUMPTER SWAN",
510
+ "487": "TURKEY VULTURE",
511
+ "488": "TURQUOISE MOTMOT",
512
+ "489": "UMBRELLA BIRD",
513
+ "490": "VARIED THRUSH",
514
+ "491": "VEERY",
515
+ "492": "VENEZUELIAN TROUPIAL",
516
+ "493": "VERDIN",
517
+ "494": "VERMILION FLYCATHER",
518
+ "495": "VICTORIA CROWNED PIGEON",
519
+ "496": "VIOLET BACKED STARLING",
520
+ "497": "VIOLET CUCKOO",
521
+ "498": "VIOLET GREEN SWALLOW",
522
+ "499": "VIOLET TURACO",
523
+ "500": "VISAYAN HORNBILL",
524
+ "501": "VULTURINE GUINEAFOWL",
525
+ "502": "WALL CREAPER",
526
+ "503": "WATTLED CURASSOW",
527
+ "504": "WATTLED LAPWING",
528
+ "505": "WHIMBREL",
529
+ "506": "WHITE BREASTED WATERHEN",
530
+ "507": "WHITE BROWED CRAKE",
531
+ "508": "WHITE CHEEKED TURACO",
532
+ "509": "WHITE CRESTED HORNBILL",
533
+ "510": "WHITE EARED HUMMINGBIRD",
534
+ "511": "WHITE NECKED RAVEN",
535
+ "512": "WHITE TAILED TROPIC",
536
+ "513": "WHITE THROATED BEE EATER",
537
+ "514": "WILD TURKEY",
538
+ "515": "WILLOW PTARMIGAN",
539
+ "516": "WILSONS BIRD OF PARADISE",
540
+ "517": "WOOD DUCK",
541
+ "518": "WOOD THRUSH",
542
+ "519": "WOODLAND KINGFISHER",
543
+ "520": "WRENTIT",
544
+ "521": "YELLOW BELLIED FLOWERPECKER",
545
+ "522": "YELLOW BREASTED CHAT",
546
+ "523": "YELLOW CACIQUE",
547
+ "524": "YELLOW HEADED BLACKBIRD",
548
+ "525": "ZEBRA DOVE"
549
+ }
550
+
551
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
552
+ return predictions
553
+
554
+ # Create Gradio interface for the bird species classifier
555
+ iface = gr.Interface(
556
+ fn=bird_classification,
557
+ inputs=gr.Image(type="numpy"),
558
+ outputs=gr.Label(label="Prediction Scores"),
559
+ title="Bird Species Classifier",
560
+ description="Upload an image to classify the bird species."
561
+ )
562
+
563
+ if __name__ == "__main__":
564
+ iface.launch()
clip_art.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor, SiglipForImageClassification
3
+ from transformers.image_utils import load_image
4
+ from PIL import Image
5
+ import torch
6
+
7
+ # Load model and processor
8
+ model_name = "prithivMLmods/Clipart-126-DomainNet"
9
+ model = SiglipForImageClassification.from_pretrained(model_name)
10
+ processor = AutoImageProcessor.from_pretrained(model_name)
11
+
12
+ def 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
62
+ iface = 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
71
+ if __name__ == "__main__":
72
+ iface.launch()
deepfake_quality.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor
3
+ from transformers import SiglipForImageClassification
4
+ from transformers.image_utils import load_image
5
+ from PIL import Image
6
+ import torch
7
+
8
+ # Load model and processor
9
+ model_name = "prithivMLmods/Deepfake-Quality-Classifier2-SigLIP2"
10
+ model = SiglipForImageClassification.from_pretrained(model_name)
11
+ processor = AutoImageProcessor.from_pretrained(model_name)
12
+
13
+ def deepfake_classification(image):
14
+ """Predicts whether an image is a Deepfake or Real."""
15
+ image = Image.fromarray(image).convert("RGB")
16
+ inputs = processor(images=image, return_tensors="pt")
17
+
18
+ with torch.no_grad():
19
+ outputs = model(**inputs)
20
+ logits = outputs.logits
21
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
22
+
23
+ labels = {
24
+ "0": "Issue In Deepfake", "1": "High Quality Deepfake"
25
+ }
26
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
27
+
28
+ return predictions
29
+
30
+ # Create Gradio interface
31
+ iface = gr.Interface(
32
+ fn=deepfake_classification,
33
+ inputs=gr.Image(type="numpy"),
34
+ outputs=gr.Label(label="Prediction Scores"),
35
+ title="Deepfake Quality Detection",
36
+ description="Upload an image to check its deepfake probability scores."
37
+ )
38
+
39
+ # Launch the app
40
+ if __name__ == "__main__":
41
+ iface.launch()
dog_breed.py ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor, SiglipForImageClassification
3
+ from PIL import Image
4
+ import torch
5
+
6
+ # Load model and processor
7
+ model_name = "prithivMLmods/Dog-Breed-120"
8
+ model = SiglipForImageClassification.from_pretrained(model_name)
9
+ processor = AutoImageProcessor.from_pretrained(model_name)
10
+
11
+ def dog_breed_classification(image):
12
+ """Predicts the dog breed for an image."""
13
+ image = Image.fromarray(image).convert("RGB")
14
+ inputs = processor(images=image, return_tensors="pt")
15
+
16
+ with torch.no_grad():
17
+ outputs = model(**inputs)
18
+ logits = outputs.logits
19
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
20
+
21
+ labels = {
22
+ "0": "affenpinscher",
23
+ "1": "afghan_hound",
24
+ "2": "african_hunting_dog",
25
+ "3": "airedale",
26
+ "4": "american_staffordshire_terrier",
27
+ "5": "appenzeller",
28
+ "6": "australian_terrier",
29
+ "7": "basenji",
30
+ "8": "basset",
31
+ "9": "beagle",
32
+ "10": "bedlington_terrier",
33
+ "11": "bernese_mountain_dog",
34
+ "12": "black-and-tan_coonhound",
35
+ "13": "blenheim_spaniel",
36
+ "14": "bloodhound",
37
+ "15": "bluetick",
38
+ "16": "border_collie",
39
+ "17": "border_terrier",
40
+ "18": "borzoi",
41
+ "19": "boston_bull",
42
+ "20": "bouvier_des_flandres",
43
+ "21": "boxer",
44
+ "22": "brabancon_griffon",
45
+ "23": "briard",
46
+ "24": "brittany_spaniel",
47
+ "25": "bull_mastiff",
48
+ "26": "cairn",
49
+ "27": "cardigan",
50
+ "28": "chesapeake_bay_retriever",
51
+ "29": "chihuahua",
52
+ "30": "chow",
53
+ "31": "clumber",
54
+ "32": "cocker_spaniel",
55
+ "33": "collie",
56
+ "34": "curly-coated_retriever",
57
+ "35": "dandie_dinmont",
58
+ "36": "dhole",
59
+ "37": "dingo",
60
+ "38": "doberman",
61
+ "39": "english_foxhound",
62
+ "40": "english_setter",
63
+ "41": "english_springer",
64
+ "42": "entlebucher",
65
+ "43": "eskimo_dog",
66
+ "44": "flat-coated_retriever",
67
+ "45": "french_bulldog",
68
+ "46": "german_shepherd",
69
+ "47": "german_short-haired_pointer",
70
+ "48": "giant_schnauzer",
71
+ "49": "golden_retriever",
72
+ "50": "gordon_setter",
73
+ "51": "great_dane",
74
+ "52": "great_pyrenees",
75
+ "53": "greater_swiss_mountain_dog",
76
+ "54": "groenendael",
77
+ "55": "ibizan_hound",
78
+ "56": "irish_setter",
79
+ "57": "irish_terrier",
80
+ "58": "irish_water_spaniel",
81
+ "59": "irish_wolfhound",
82
+ "60": "italian_greyhound",
83
+ "61": "japanese_spaniel",
84
+ "62": "keeshond",
85
+ "63": "kelpie",
86
+ "64": "kerry_blue_terrier",
87
+ "65": "komondor",
88
+ "66": "kuvasz",
89
+ "67": "labrador_retriever",
90
+ "68": "lakeland_terrier",
91
+ "69": "leonberg",
92
+ "70": "lhasa",
93
+ "71": "malamute",
94
+ "72": "malinois",
95
+ "73": "maltese_dog",
96
+ "74": "mexican_hairless",
97
+ "75": "miniature_pinscher",
98
+ "76": "miniature_poodle",
99
+ "77": "miniature_schnauzer",
100
+ "78": "newfoundland",
101
+ "79": "norfolk_terrier",
102
+ "80": "norwegian_elkhound",
103
+ "81": "norwich_terrier",
104
+ "82": "old_english_sheepdog",
105
+ "83": "otterhound",
106
+ "84": "papillon",
107
+ "85": "pekinese",
108
+ "86": "pembroke",
109
+ "87": "pomeranian",
110
+ "88": "pug",
111
+ "89": "redbone",
112
+ "90": "rhodesian_ridgeback",
113
+ "91": "rottweiler",
114
+ "92": "saint_bernard",
115
+ "93": "saluki",
116
+ "94": "samoyed",
117
+ "95": "schipperke",
118
+ "96": "scotch_terrier",
119
+ "97": "scottish_deerhound",
120
+ "98": "sealyham_terrier",
121
+ "99": "shetland_sheepdog",
122
+ "100": "shih-tzu",
123
+ "101": "siberian_husky",
124
+ "102": "silky_terrier",
125
+ "103": "soft-coated_wheaten_terrier",
126
+ "104": "staffordshire_bullterrier",
127
+ "105": "standard_poodle",
128
+ "106": "standard_schnauzer",
129
+ "107": "sussex_spaniel",
130
+ "108": "test",
131
+ "109": "tibetan_mastiff",
132
+ "110": "tibetan_terrier",
133
+ "111": "toy_poodle",
134
+ "112": "toy_terrier",
135
+ "113": "vizsla",
136
+ "114": "walker_hound",
137
+ "115": "weimaraner",
138
+ "116": "welsh_springer_spaniel",
139
+ "117": "west_highland_white_terrier",
140
+ "118": "whippet",
141
+ "119": "wire-haired_fox_terrier",
142
+ "120": "yorkshire_terrier"
143
+ }
144
+
145
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
146
+ return predictions
147
+
148
+ # Create Gradio interface
149
+ iface = gr.Interface(
150
+ fn=dog_breed_classification,
151
+ inputs=gr.Image(type="numpy"),
152
+ outputs=gr.Label(label="Prediction Scores"),
153
+ title="Dog Breed Classification",
154
+ description="Upload an image to classify it into one of the 121 dog breed categories."
155
+ )
156
+
157
+ # Launch the app
158
+ if __name__ == "__main__":
159
+ iface.launch()
emotion_classification.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor
3
+ from transformers import SiglipForImageClassification
4
+ from PIL import Image
5
+ import torch
6
+
7
+ # Load model and processor
8
+ model_name = "prithivMLmods/Facial-Emotion-Detection-SigLIP2"
9
+ model = SiglipForImageClassification.from_pretrained(model_name)
10
+ processor = AutoImageProcessor.from_pretrained(model_name)
11
+
12
+ def emotion_classification(image):
13
+ """Predicts facial emotion classification for an image."""
14
+ image = Image.fromarray(image).convert("RGB")
15
+ inputs = processor(images=image, return_tensors="pt")
16
+
17
+ with torch.no_grad():
18
+ outputs = model(**inputs)
19
+ logits = outputs.logits
20
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
21
+
22
+ labels = {
23
+ "0": "Ahegao", "1": "Angry", "2": "Happy", "3": "Neutral",
24
+ "4": "Sad", "5": "Surprise"
25
+ }
26
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
27
+
28
+ return predictions
29
+
30
+ if __name__ == "__main__":
31
+ iface = gr.Interface(
32
+ fn=emotion_classification,
33
+ inputs=gr.Image(type="numpy"),
34
+ outputs=gr.Label(label="Prediction Scores"),
35
+ title="Facial Emotion Detection",
36
+ description="Upload an image to classify the facial emotion."
37
+ )
38
+ iface.launch()
fashion_mnist_cloth.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor
3
+ from transformers import SiglipForImageClassification
4
+ from transformers.image_utils import load_image
5
+ from PIL import Image
6
+ import torch
7
+
8
+ # Load model and processor
9
+ model_name = "prithivMLmods/Fashion-Mnist-SigLIP2"
10
+ model = SiglipForImageClassification.from_pretrained(model_name)
11
+ processor = AutoImageProcessor.from_pretrained(model_name)
12
+
13
+ def fashion_mnist_classification(image):
14
+ """Predicts fashion category for an image."""
15
+ image = Image.fromarray(image).convert("RGB")
16
+ inputs = processor(images=image, return_tensors="pt")
17
+
18
+ with torch.no_grad():
19
+ outputs = model(**inputs)
20
+ logits = outputs.logits
21
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
22
+
23
+ labels = {
24
+ "0": "T-shirt / top", "1": "Trouser", "2": "Pullover", "3": "Dress", "4": "Coat",
25
+ "5": "Sandal", "6": "Shirt", "7": "Sneaker", "8": "Bag", "9": "Ankle boot"
26
+ }
27
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
28
+
29
+ return predictions
30
+
31
+ # Create Gradio interface
32
+ iface = gr.Interface(
33
+ fn=fashion_mnist_classification,
34
+ inputs=gr.Image(type="numpy"),
35
+ outputs=gr.Label(label="Prediction Scores"),
36
+ title="Fashion MNIST Classification Labels",
37
+ description="Upload an image to classify it into one of the 10 Fashion-MNIST categories."
38
+ )
39
+
40
+ # Launch the app
41
+ if __name__ == "__main__":
42
+ iface.launch()
gender_classification.py ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor
3
+ from transformers import SiglipForImageClassification
4
+ from PIL import Image
5
+ import torch
6
+
7
+ # Load model and processor
8
+ model_name = "prithivMLmods/Gender-Classifier-Mini"
9
+ model = SiglipForImageClassification.from_pretrained(model_name)
10
+ processor = AutoImageProcessor.from_pretrained(model_name)
11
+
12
+ def gender_classification(image):
13
+ """Predicts gender category for an image."""
14
+ image = Image.fromarray(image).convert("RGB")
15
+ inputs = processor(images=image, return_tensors="pt")
16
+
17
+ with torch.no_grad():
18
+ outputs = model(**inputs)
19
+ logits = outputs.logits
20
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
21
+
22
+ labels = {"0": "Female ♀", "1": "Male ♂"}
23
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
24
+
25
+ return predictions
26
+
27
+ if __name__ == "__main__":
28
+ import gradio as gr
29
+ iface = gr.Interface(
30
+ fn=gender_classification,
31
+ inputs=gr.Image(type="numpy"),
32
+ outputs=gr.Label(label="Prediction Scores"),
33
+ title="Gender Classification",
34
+ description="Upload an image to classify its gender."
35
+ )
36
+ iface.launch()
gym_workout_classification.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor
3
+ from transformers import SiglipForImageClassification
4
+ from transformers.image_utils import load_image
5
+ from PIL import Image
6
+ import torch
7
+
8
+ # Load model and processor
9
+ model_name = "prithivMLmods/Gym-Workout-Classifier-SigLIP2"
10
+ model = SiglipForImageClassification.from_pretrained(model_name)
11
+ processor = AutoImageProcessor.from_pretrained(model_name)
12
+
13
+ def workout_classification(image):
14
+ """Predicts workout exercise classification for an image."""
15
+ image = Image.fromarray(image).convert("RGB")
16
+ inputs = processor(images=image, return_tensors="pt")
17
+
18
+ with torch.no_grad():
19
+ outputs = model(**inputs)
20
+ logits = outputs.logits
21
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
22
+
23
+ labels = {
24
+ "0": "barbell biceps curl", "1": "bench press", "2": "chest fly machine", "3": "deadlift",
25
+ "4": "decline bench press", "5": "hammer curl", "6": "hip thrust", "7": "incline bench press",
26
+ "8": "lat pulldown", "9": "lateral raises", "10": "leg extension", "11": "leg raises",
27
+ "12": "plank", "13": "pull up", "14": "push up", "15": "romanian deadlift",
28
+ "16": "russian twist", "17": "shoulder press", "18": "squat", "19": "t bar row",
29
+ "20": "tricep dips", "21": "tricep pushdown"
30
+ }
31
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
32
+
33
+ return predictions
34
+
35
+ # Create Gradio interface
36
+ iface = gr.Interface(
37
+ fn=workout_classification,
38
+ inputs=gr.Image(type="numpy"),
39
+ outputs=gr.Label(label="Prediction Scores"),
40
+ title="Gym Workout Classification",
41
+ description="Upload an image to classify the workout exercise."
42
+ )
43
+
44
+ # Launch the app
45
+ if __name__ == "__main__":
46
+ iface.launch()
indian_western_food_classify.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor
3
+ from transformers import SiglipForImageClassification
4
+ from transformers.image_utils import load_image
5
+ from PIL import Image
6
+ import torch
7
+
8
+ # Load model and processor
9
+ model_name = "prithivMLmods/Indian-Western-Food-34"
10
+ model = SiglipForImageClassification.from_pretrained(model_name)
11
+ processor = AutoImageProcessor.from_pretrained(model_name)
12
+
13
+ def food_classification(image):
14
+ """Predicts the type of food in an image."""
15
+ image = Image.fromarray(image).convert("RGB")
16
+ inputs = processor(images=image, return_tensors="pt")
17
+
18
+ with torch.no_grad():
19
+ outputs = model(**inputs)
20
+ logits = outputs.logits
21
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
22
+
23
+ labels = {
24
+ "0": "Baked Potato", "1": "Crispy Chicken", "2": "Donut", "3": "Fries",
25
+ "4": "Hot Dog", "5": "Sandwich", "6": "Taco", "7": "Taquito", "8": "Apple Pie",
26
+ "9": "Burger", "10": "Butter Naan", "11": "Chai", "12": "Chapati", "13": "Cheesecake",
27
+ "14": "Chicken Curry", "15": "Chole Bhature", "16": "Dal Makhani", "17": "Dhokla",
28
+ "18": "Fried Rice", "19": "Ice Cream", "20": "Idli", "21": "Jalebi", "22": "Kaathi Rolls",
29
+ "23": "Kadai Paneer", "24": "Kulfi", "25": "Masala Dosa", "26": "Momos", "27": "Omelette",
30
+ "28": "Paani Puri", "29": "Pakode", "30": "Pav Bhaji", "31": "Pizza", "32": "Samosa",
31
+ "33": "Sushi"
32
+ }
33
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
34
+
35
+ return predictions
36
+
37
+ # Create Gradio interface
38
+ iface = gr.Interface(
39
+ fn=food_classification,
40
+ inputs=gr.Image(type="numpy"),
41
+ outputs=gr.Label(label="Prediction Scores"),
42
+ title="Indian & Western Food Classification",
43
+ description="Upload a food image to classify it into one of the 34 food types."
44
+ )
45
+
46
+ # Launch the app
47
+ if __name__ == "__main__":
48
+ iface.launch()
mnist_digits.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor, SiglipForImageClassification
3
+ from transformers.image_utils import load_image
4
+ from PIL import Image
5
+ import torch
6
+
7
+ # Load model and processor
8
+ model_name = "prithivMLmods/Mnist-Digits-SigLIP2"
9
+ model = SiglipForImageClassification.from_pretrained(model_name)
10
+ processor = AutoImageProcessor.from_pretrained(model_name)
11
+
12
+ def classify_digit(image):
13
+ """Predicts the digit in the given handwritten digit image."""
14
+ image = Image.fromarray(image).convert("RGB")
15
+ inputs = processor(images=image, return_tensors="pt")
16
+
17
+ with torch.no_grad():
18
+ outputs = model(**inputs)
19
+ logits = outputs.logits
20
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
21
+
22
+ labels = {
23
+ "0": "0", "1": "1", "2": "2", "3": "3", "4": "4",
24
+ "5": "5", "6": "6", "7": "7", "8": "8", "9": "9"
25
+ }
26
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
27
+
28
+ return predictions
29
+
30
+ # Create Gradio interface
31
+ iface = gr.Interface(
32
+ fn=classify_digit,
33
+ inputs=gr.Image(type="numpy"),
34
+ outputs=gr.Label(label="Prediction Scores"),
35
+ title="MNIST Digit Classification 🔢",
36
+ description="Upload a handwritten digit image (0-9) to recognize it using MNIST-Digits-SigLIP2."
37
+ )
38
+
39
+ # Launch the app
40
+ if __name__ == "__main__":
41
+ iface.launch()
multisource_121.py ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor, SiglipForImageClassification
3
+ from transformers.image_utils import load_image
4
+ from PIL import Image
5
+ import torch
6
+
7
+ # Load model and processor
8
+ model_name = "prithivMLmods/Multisource-121-DomainNet"
9
+ model = SiglipForImageClassification.from_pretrained(model_name)
10
+ processor = AutoImageProcessor.from_pretrained(model_name)
11
+
12
+ def multisource_classification(image):
13
+ """Predicts the domain category for an input image."""
14
+ # Convert the input numpy array to a PIL Image and ensure it is in RGB format
15
+ image = Image.fromarray(image).convert("RGB")
16
+
17
+ # Process the image and convert it to model inputs
18
+ inputs = processor(images=image, return_tensors="pt")
19
+
20
+ # Get model predictions without gradient calculations
21
+ with torch.no_grad():
22
+ outputs = model(**inputs)
23
+ logits = outputs.logits
24
+ # Convert logits to probabilities using softmax
25
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
26
+
27
+ # Mapping from class indices to domain labels
28
+ labels = {
29
+ "0": "barn", "1": "baseball_bat", "2": "basket", "3": "beach", "4": "bear",
30
+ "5": "beard", "6": "bee", "7": "bird", "8": "blueberry", "9": "bowtie",
31
+ "10": "bracelet", "11": "brain", "12": "bread", "13": "broccoli", "14": "bus",
32
+ "15": "butterfly", "16": "circle", "17": "cloud", "18": "cruise_ship", "19": "dolphin",
33
+ "20": "dumbbell", "21": "elephant", "22": "eye", "23": "eyeglasses", "24": "feather",
34
+ "25": "fish", "26": "flower", "27": "foot", "28": "frog", "29": "giraffe",
35
+ "30": "goatee", "31": "golf_club", "32": "grapes", "33": "grass", "34": "guitar",
36
+ "35": "hamburger", "36": "hand", "37": "hat", "38": "headphones", "39": "helicopter",
37
+ "40": "hexagon", "41": "hockey_stick", "42": "horse", "43": "hourglass", "44": "house",
38
+ "45": "ice_cream", "46": "jacket", "47": "ladder", "48": "leg", "49": "lipstick",
39
+ "50": "megaphone", "51": "monkey", "52": "moon", "53": "mushroom", "54": "necklace",
40
+ "55": "owl", "56": "panda", "57": "pear", "58": "peas", "59": "penguin",
41
+ "60": "pig", "61": "pillow", "62": "pineapple", "63": "pizza", "64": "pool",
42
+ "65": "popsicle", "66": "rabbit", "67": "rhinoceros", "68": "rifle", "69": "river",
43
+ "70": "sailboat", "71": "sandwich", "72": "sea_turtle", "73": "shark", "74": "shoe",
44
+ "75": "skyscraper", "76": "snorkel", "77": "snowman", "78": "soccer_ball", "79": "speedboat",
45
+ "80": "spider", "81": "spoon", "82": "square", "83": "squirrel", "84": "stethoscope",
46
+ "85": "strawberry", "86": "streetlight", "87": "submarine", "88": "suitcase", "89": "sun",
47
+ "90": "sweater", "91": "sword", "92": "table", "93": "teapot", "94": "teddy-bear",
48
+ "95": "telephone", "96": "tent", "97": "The_Eiffel_Tower", "98": "The_Great_Wall_of_China",
49
+ "99": "The_Mona_Lisa", "100": "tiger", "101": "toaster", "102": "tooth", "103": "tornado",
50
+ "104": "tractor", "105": "train", "106": "tree", "107": "triangle", "108": "trombone",
51
+ "109": "truck", "110": "trumpet", "111": "umbrella", "112": "vase", "113": "violin",
52
+ "114": "watermelon", "115": "whale", "116": "windmill", "117": "wine_glass", "118": "yoga",
53
+ "119": "zebra", "120": "zigzag"
54
+ }
55
+
56
+ # Create a dictionary mapping each label to its corresponding probability (rounded)
57
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
58
+ return predictions
59
+
60
+ # Create Gradio interface
61
+ iface = gr.Interface(
62
+ fn=multisource_classification,
63
+ inputs=gr.Image(type="numpy"),
64
+ outputs=gr.Label(label="Prediction Scores"),
65
+ title="Multisource-121-DomainNet Classification",
66
+ description="Upload an image to classify it into one of 121 domain categories."
67
+ )
68
+
69
+ # Launch the app
70
+ if __name__ == "__main__":
71
+ iface.launch()
painting_126.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor, SiglipForImageClassification
3
+ from transformers.image_utils import load_image
4
+ from PIL import Image
5
+ import torch
6
+
7
+ # Load model and processor
8
+ model_name = "prithivMLmods/Painting-126-DomainNet"
9
+ model = SiglipForImageClassification.from_pretrained(model_name)
10
+ processor = AutoImageProcessor.from_pretrained(model_name)
11
+
12
+ def painting_classification(image):
13
+ """Predicts the painting category for an input image."""
14
+ # Convert the input numpy array to a PIL image and ensure it is in RGB format
15
+ image = Image.fromarray(image).convert("RGB")
16
+
17
+ # Process the image for the model
18
+ inputs = processor(images=image, return_tensors="pt")
19
+
20
+ # Get predictions from the model without gradient computation
21
+ with torch.no_grad():
22
+ outputs = model(**inputs)
23
+ logits = outputs.logits
24
+ # Convert logits to probabilities using softmax
25
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
26
+
27
+ # Define the label mapping for each class index
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
+ # Map 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 for the painting classifier
62
+ iface = gr.Interface(
63
+ fn=painting_classification,
64
+ inputs=gr.Image(type="numpy"),
65
+ outputs=gr.Label(label="Prediction Scores"),
66
+ title="Painting-126-DomainNet Classification",
67
+ description="Upload a painting to classify it into one of 126 categories."
68
+ )
69
+
70
+ # Launch the app
71
+ if __name__ == "__main__":
72
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ transformers
2
+ accelerate
3
+ torch
4
+ protobuf
5
+ sentencepiece
6
+ pillow
7
+ gradio
8
+ spaces
rice_leaf_disease.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor, SiglipForImageClassification
3
+ from transformers.image_utils import load_image
4
+ from PIL import Image
5
+ import torch
6
+
7
+ # Load model and processor
8
+ model_name = "prithivMLmods/Rice-Leaf-Disease"
9
+ model = SiglipForImageClassification.from_pretrained(model_name)
10
+ processor = AutoImageProcessor.from_pretrained(model_name)
11
+
12
+ def classify_leaf_disease(image):
13
+ """Predicts the disease type in a rice leaf image."""
14
+ image = Image.fromarray(image).convert("RGB")
15
+ inputs = processor(images=image, return_tensors="pt")
16
+
17
+ with torch.no_grad():
18
+ outputs = model(**inputs)
19
+ logits = outputs.logits
20
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
21
+
22
+ labels = {
23
+ "0": "Bacterial Blight",
24
+ "1": "Blast",
25
+ "2": "Brown Spot",
26
+ "3": "Healthy",
27
+ "4": "Tungro"
28
+ }
29
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
30
+
31
+ return predictions
32
+
33
+ # Create Gradio interface
34
+ iface = gr.Interface(
35
+ fn=classify_leaf_disease,
36
+ inputs=gr.Image(type="numpy"),
37
+ outputs=gr.Label(label="Prediction Scores"),
38
+ title="Rice Leaf Disease Classification 🌾",
39
+ description="Upload an image of a rice leaf to identify if it is healthy or affected by diseases like Bacterial Blight, Blast, Brown Spot, or Tungro."
40
+ )
41
+
42
+ # Launch the app
43
+ if __name__ == "__main__":
44
+ iface.launch()
sketch_126.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor, SiglipForImageClassification
3
+ from transformers.image_utils import load_image
4
+ from PIL import Image
5
+ import torch
6
+
7
+ # Load model and processor
8
+ model_name = "prithivMLmods/Sketch-126-DomainNet"
9
+ model = SiglipForImageClassification.from_pretrained(model_name)
10
+ processor = AutoImageProcessor.from_pretrained(model_name)
11
+
12
+ def sketch_classification(image):
13
+ """Predicts the sketch category for an input image."""
14
+ # Convert the input numpy array to a PIL Image and ensure it has 3 channels (RGB)
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 calculation
21
+ with torch.no_grad():
22
+ outputs = model(**inputs)
23
+ logits = outputs.logits
24
+ # Convert logits to probabilities using softmax
25
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
26
+
27
+ # Mapping from indices to corresponding sketch 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 predicted 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
62
+ iface = gr.Interface(
63
+ fn=sketch_classification,
64
+ inputs=gr.Image(type="numpy"),
65
+ outputs=gr.Label(label="Prediction Scores"),
66
+ title="Sketch-126-DomainNet Classification",
67
+ description="Upload a sketch to classify it into one of 126 categories."
68
+ )
69
+
70
+ # Launch the app
71
+ if __name__ == "__main__":
72
+ iface.launch()
traffic_density.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoImageProcessor
3
+ from transformers import SiglipForImageClassification
4
+ from transformers.image_utils import load_image
5
+ from PIL import Image
6
+ import torch
7
+
8
+ # Load model and processor
9
+ model_name = "prithivMLmods/Traffic-Density-Classification"
10
+ model = SiglipForImageClassification.from_pretrained(model_name)
11
+ processor = AutoImageProcessor.from_pretrained(model_name)
12
+
13
+ def traffic_density_classification(image):
14
+ """Predicts traffic density category for an image."""
15
+ image = Image.fromarray(image).convert("RGB")
16
+ inputs = processor(images=image, return_tensors="pt")
17
+
18
+ with torch.no_grad():
19
+ outputs = model(**inputs)
20
+ logits = outputs.logits
21
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
22
+
23
+ labels = {
24
+ "0": "high-traffic", "1": "low-traffic", "2": "medium-traffic", "3": "no-traffic"
25
+ }
26
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
27
+
28
+ return predictions
29
+
30
+ # Create Gradio interface
31
+ iface = gr.Interface(
32
+ fn=traffic_density_classification,
33
+ inputs=gr.Image(type="numpy"),
34
+ outputs=gr.Label(label="Prediction Scores"),
35
+ title="Traffic Density Classification",
36
+ description="Upload an image to classify it into one of the 4 traffic density categories."
37
+ )
38
+
39
+ # Launch the app
40
+ if __name__ == "__main__":
41
+ iface.launch()