prithivMLmods commited on
Commit
fa06f2f
·
verified ·
1 Parent(s): a30cdf5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +115 -1
README.md CHANGED
@@ -3,7 +3,9 @@ license: apache-2.0
3
  datasets:
4
  - ewanlong/Food_Classification_Dataset
5
  ---
 
6
 
 
7
 
8
  ```py
9
  Classification Report:
@@ -47,4 +49,116 @@ Crispy Chicken 0.9811 0.9707 0.9759 1500
47
  accuracy 0.9729 23873
48
  macro avg 0.9719 0.9775 0.9745 23873
49
  weighted avg 0.9731 0.9729 0.9729 23873
50
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  datasets:
4
  - ewanlong/Food_Classification_Dataset
5
  ---
6
+ # **Indian-Western-Food-34**
7
 
8
+ > **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.
9
 
10
  ```py
11
  Classification Report:
 
49
  accuracy 0.9729 23873
50
  macro avg 0.9719 0.9775 0.9745 23873
51
  weighted avg 0.9731 0.9729 0.9729 23873
52
+ ```
53
+
54
+ ---
55
+
56
+ The model categorizes images into 34 food classes:
57
+
58
+ ### **Western Foods**
59
+ - **Class 0:** "Baked Potato"
60
+ - **Class 1:** "Crispy Chicken"
61
+ - **Class 2:** "Donut"
62
+ - **Class 3:** "Fries"
63
+ - **Class 4:** "Hot Dog"
64
+ - **Class 5:** "Sandwich"
65
+ - **Class 6:** "Taco"
66
+ - **Class 7:** "Taquito"
67
+ - **Class 8:** "Apple Pie"
68
+ - **Class 9:** "Burger"
69
+ - **Class 13:** "Cheesecake"
70
+ - **Class 18:** "Fried Rice"
71
+ - **Class 19:** "Ice Cream"
72
+ - **Class 27:** "Omelette"
73
+ - **Class 31:** "Pizza"
74
+ - **Class 33:** "Sushi"
75
+
76
+ ### **Indian Foods**
77
+ - **Class 10:** "Butter Naan"
78
+ - **Class 11:** "Chai"
79
+ - **Class 12:** "Chapati"
80
+ - **Class 14:** "Chicken Curry"
81
+ - **Class 15:** "Chole Bhature"
82
+ - **Class 16:** "Dal Makhani"
83
+ - **Class 17:** "Dhokla"
84
+ - **Class 20:** "Idli"
85
+ - **Class 21:** "Jalebi"
86
+ - **Class 22:** "Kaathi Rolls"
87
+ - **Class 23:** "Kadai Paneer"
88
+ - **Class 24:** "Kulfi"
89
+ - **Class 25:** "Masala Dosa"
90
+ - **Class 26:** "Momos"
91
+ - **Class 28:** "Paani Puri"
92
+ - **Class 29:** "Pakode"
93
+ - **Class 30:** "Pav Bhaji"
94
+ - **Class 32:** "Samosa"
95
+
96
+ ---
97
+
98
+ # **Run with Transformers🤗**
99
+
100
+ ```python
101
+ !pip install -q transformers torch pillow gradio
102
+ ```
103
+
104
+ ```python
105
+ import gradio as gr
106
+ from transformers import AutoImageProcessor
107
+ from transformers import SiglipForImageClassification
108
+ from transformers.image_utils import load_image
109
+ from PIL import Image
110
+ import torch
111
+
112
+ # Load model and processor
113
+ model_name = "prithivMLmods/Indian-Western-Food-34"
114
+ model = SiglipForImageClassification.from_pretrained(model_name)
115
+ processor = AutoImageProcessor.from_pretrained(model_name)
116
+
117
+ def food_classification(image):
118
+ """Predicts the type of food in an image."""
119
+ image = Image.fromarray(image).convert("RGB")
120
+ inputs = processor(images=image, return_tensors="pt")
121
+
122
+ with torch.no_grad():
123
+ outputs = model(**inputs)
124
+ logits = outputs.logits
125
+ probs = torch.nn.functional.softmax(logits, dim=1).squeeze().tolist()
126
+
127
+ labels = {
128
+ "0": "Baked Potato", "1": "Crispy Chicken", "2": "Donut", "3": "Fries",
129
+ "4": "Hot Dog", "5": "Sandwich", "6": "Taco", "7": "Taquito", "8": "Apple Pie",
130
+ "9": "Burger", "10": "Butter Naan", "11": "Chai", "12": "Chapati", "13": "Cheesecake",
131
+ "14": "Chicken Curry", "15": "Chole Bhature", "16": "Dal Makhani", "17": "Dhokla",
132
+ "18": "Fried Rice", "19": "Ice Cream", "20": "Idli", "21": "Jalebi", "22": "Kaathi Rolls",
133
+ "23": "Kadai Paneer", "24": "Kulfi", "25": "Masala Dosa", "26": "Momos", "27": "Omelette",
134
+ "28": "Paani Puri", "29": "Pakode", "30": "Pav Bhaji", "31": "Pizza", "32": "Samosa",
135
+ "33": "Sushi"
136
+ }
137
+ predictions = {labels[str(i)]: round(probs[i], 3) for i in range(len(probs))}
138
+
139
+ return predictions
140
+
141
+ # Create Gradio interface
142
+ iface = gr.Interface(
143
+ fn=food_classification,
144
+ inputs=gr.Image(type="numpy"),
145
+ outputs=gr.Label(label="Prediction Scores"),
146
+ title="Indian & Western Food Classification",
147
+ description="Upload a food image to classify it into one of the 34 food types."
148
+ )
149
+
150
+ # Launch the app
151
+ if __name__ == "__main__":
152
+ iface.launch()
153
+ ```
154
+
155
+ ---
156
+
157
+ # **Intended Use:**
158
+
159
+ The **Indian-Western-Food-34** model is designed to classify food images into Indian and Western dishes. Potential use cases include:
160
+
161
+ - **Restaurant & Food Delivery Apps:** Enhancing food recognition for better menu recommendations.
162
+ - **Health & Nutrition Apps:** Tracking calorie intake and diet preferences.
163
+ - **Food Blogging & Social Media:** Auto-tagging food items in posts.
164
+ - **Educational Purposes:** Teaching AI-based food classification.