Views
No views yet

Indian-Western-Food-34 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 food images into various Indian and Western dishes using the SiglipForImageClassification architecture.
1Classification Report:
2 precision recall f1-score support
3
4 Baked Potato 0.9912 0.9780 0.9846 1500
5Crispy Chicken 0.9811 0.9707 0.9759 1500
6 Donut 0.9893 0.9893 0.9893 1500
7 Fries 0.9742 0.9827 0.9784 1500
8 Hot Dog 0.9830 0.9735 0.9783 1548
9 Sandwich 0.9898 0.9673 0.9784 1500
10 Taco 0.9327 0.9427 0.9377 1500
11 Taquito 0.9624 0.9387 0.9504 1500
12 Apple Pie 0.9666 0.9540 0.9602 1000
13 Burger 0.9114 0.9940 0.9509 331
14 Butter Naan 0.9691 0.9186 0.9431 307
15 Chai 0.9801 1.0000 0.9899 344
16 Chapati 0.9188 0.9694 0.9435 327
17 Cheesecake 0.9573 0.9640 0.9606 1000
18 Chicken Curry 0.9610 0.9850 0.9728 1000
19 Chole Bhature 0.9841 0.9867 0.9854 376
20 Dal Makhani 0.9698 0.9797 0.9747 295
21 Dhokla 0.9959 0.9959 0.9959 245
22 Fried Rice 0.9485 1.0000 0.9736 350
23 Ice Cream 0.9569 0.9770 0.9668 1000
24 Idli 0.9934 1.0000 0.9967 302
25 Jalebi 0.9931 1.0000 0.9965 288
26 Kaathi Rolls 0.9640 0.9606 0.9623 279
27 Kadai Paneer 0.9848 0.9731 0.9789 334
28 Kulfi 0.9810 0.9673 0.9741 214
29 Masala Dosa 0.9890 0.9890 0.9890 273
30 Momos 0.9908 0.9969 0.9938 323
31 Omelette 0.9829 0.9790 0.9810 1000
32 Paani Puri 0.9281 0.9861 0.9562 144
33 Pakode 0.9738 0.9665 0.9701 269
34 Pav Bhaji 0.9901 0.9803 0.9852 305
35 Pizza 0.9647 0.9927 0.9785 275
36 Samosa 0.9878 0.9959 0.9918 244
37 Sushi 0.9969 0.9800 0.9884 1000
38
39 accuracy 0.9729 23873
40 macro avg 0.9719 0.9775 0.9745 23873
41 weighted avg 0.9731 0.9729 0.9729 23873!pip install -q transformers torch pillow gradio1import gradio as gr
2from transformers import AutoImageProcessor
3from transformers import SiglipForImageClassification
4from transformers.image_utils import load_image
5from PIL import Image
6import torch
7
8# Load model and processor
9model_name = "prithivMLmods/Indian-Western-Food-34"
10model = SiglipForImageClassification.from_pretrained(model_name)
11processor = AutoImageProcessor.from_pretrained(model_name)
12
13def 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
38iface = 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
47if __name__ == "__main__":
48 iface.launch()