SakibRumu commited on
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastai.vision.all import load_learner
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
#import pathlib
|
| 5 |
+
#temp=pathlib.PosixPath
|
| 6 |
+
#pathlib.PosixPath=pathlib.WindowsPath
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
food_labels = [
|
| 10 |
+
'Baked Potato',
|
| 11 |
+
'Crispy Chicken',
|
| 12 |
+
'Donut',
|
| 13 |
+
'Fries',
|
| 14 |
+
'Hot Dog',
|
| 15 |
+
'Sandwich',
|
| 16 |
+
'Taco',
|
| 17 |
+
'Taquito',
|
| 18 |
+
'Apple Pie',
|
| 19 |
+
'Burger',
|
| 20 |
+
'Butter Naan',
|
| 21 |
+
'Chai',
|
| 22 |
+
'Chapati',
|
| 23 |
+
'Cheesecake',
|
| 24 |
+
'Chicken Curry',
|
| 25 |
+
'Chole Bhature',
|
| 26 |
+
'Dal Makhani',
|
| 27 |
+
'Dhokla',
|
| 28 |
+
'Fried Rice',
|
| 29 |
+
'Ice Cream',
|
| 30 |
+
'Idli',
|
| 31 |
+
'Jalebi',
|
| 32 |
+
'Kaathi Rolls',
|
| 33 |
+
'Kadai Paneer',
|
| 34 |
+
'Kulfi',
|
| 35 |
+
'Masala Dosa',
|
| 36 |
+
'Momos',
|
| 37 |
+
'Omelette',
|
| 38 |
+
'Paani Puri',
|
| 39 |
+
'Pakode',
|
| 40 |
+
'Pancakes',
|
| 41 |
+
'Quesadilla',
|
| 42 |
+
'Ratatouille',
|
| 43 |
+
'Samosa',
|
| 44 |
+
'Spring Rolls',
|
| 45 |
+
'Stuffed Bell Peppers',
|
| 46 |
+
'Tandoori Chicken',
|
| 47 |
+
'Uttapam',
|
| 48 |
+
'Veggie Burger',
|
| 49 |
+
'Waffles',
|
| 50 |
+
'Zucchini Bread']
|
| 51 |
+
|
| 52 |
+
model=load_learner("food_model_v2.pkl")
|
| 53 |
+
|
| 54 |
+
def recognize_image(image):
|
| 55 |
+
#import pdb;pdb.set_trace()
|
| 56 |
+
pred,idx,probs=model.predict(image)
|
| 57 |
+
print(pred)
|
| 58 |
+
return dict(zip(jersey_labels, map(float,probs)))
|
| 59 |
+
|
| 60 |
+
image = gr.Image()
|
| 61 |
+
label = gr.Label()
|
| 62 |
+
examples = [
|
| 63 |
+
"food1.jpg",
|
| 64 |
+
"food2.jpg",
|
| 65 |
+
"food3.jpg",
|
| 66 |
+
"food4.jpg"]
|
| 67 |
+
|
| 68 |
+
iface = gr.Interface(fn=recognize_image, inputs=image, outputs=label,examples=examples)
|
| 69 |
+
iface.launch(inline=False,share=True)
|