|
import gradio as gr |
|
from fastai.vision.all import * |
|
|
|
import pathlib |
|
temp = pathlib.PosixPath |
|
pathlib.PosixPath = pathlib.WindowsPath |
|
|
|
food_names = ( |
|
'Aloo Baingan', 'Aloo Gobi', 'Aloo Matar', 'Aloo Paratha', 'Aloo Tikki', 'Apple pie', 'Arayes', 'Arayes Kafta', 'Baba Ghanoush', 'Baby back ribs', 'Baghlava', 'Baklava', 'Balah El Sham', 'Balaleet', 'Bamia', 'Bamieh', 'Basbousa', 'Batata Harra', 'Beef carpaccio', 'Beef tartare', 'Beignets', 'Bhindi Masala', 'Bibimbap', 'Biryani', 'Bread pudding', 'Breakfast burrito food', 'Bruschetta', 'Butter Chicken', 'Butter Naan', 'Caesar salad', 'Cannoli', 'Caprese salad', 'Carrot cake', 'Ceviche', 'Chana Masala food', 'Cheeseburger', 'Cheesecake', 'Chicken 555', 'Chicken 65', 'Chicken 65 Biryani', 'Chicken Biriyani', 'Chicken Biryani', 'Chicken Chettinad', 'Chicken Chilli', 'Chicken Dum Biryani food', 'Chicken Frankie', 'Chicken Fried Rice', 'Chicken Handi', 'Chicken Kebab', 'Chicken Korma', 'Chicken Liver Fry', 'Chicken Lollipop', 'Chicken Manchurian', 'Chicken Masala', 'Chicken Noodles', 'Chicken Popcorn', 'Chicken Pulao', 'Chicken Shawarma', 'Chicken Tandoori', 'Chicken Tikka Masala', 'Chicken curry', 'Chicken quesadilla', 'Chicken wings', 'Chocolate cake', 'Chocolate mousse', 'Chole Bhature', 'Churros', 'Clam chowder', 'Club sandwich', 'Crab cakes', 'Creme brulee', 'Croque madame', 'Cupcakes', 'Dajaj Mashwi', 'Dal Makhani', 'Deviled eggs', 'Donuts', 'Dosa', 'Dumplings', 'Egg Biryani food item', 'Egg Curry', 'Egg Fried Rice', 'Egg Masala', 'Eggs benedict', 'Escargots', 'Falafel', 'Fasolia food item', 'Fatayer', 'Fatteh', 'Fattoush', 'Fesenjan', 'Filet mignon', 'Fish Biryani', 'Fish Curry', 'Fish Fry', 'Fish Masala', 'Fish and chips', 'Foie gras', 'Foul Medames', 'Foul Mudammas', 'French fries', 'French onion soup', 'French toast', 'Fried calamari', 'Fried rice', 'Frozen yogurt', 'Ful Medames', 'Gajar Ka Halwa', 'Garlic bread', 'Gazpacho', 'Ghorayebah', 'Gnocchi', 'Gobi Manchurian', 'Greek salad', 'Grilled cheese sandwich', 'Grilled salmon', 'Guacamole', 'Gulab Jamun', 'Gyoza', 'Halva', 'Hamburger', 'Haneeth', 'Harees', 'Hareesah', 'Harira', 'Harisi', 'Hawawshi', 'Hot and sour soup', 'Hot dog', 'Huevos rancheros', 'Hummus', 'Hyderabadi Biryani', 'Ice cream', 'Idli', 'Jalebi', 'Jallab', 'Jallab Drink', 'Jareesh', 'Jibneh Arabieh', 'Kabsa', |
|
'Kanafeh', 'Kebab', 'Kheer', 'Kibbeh', 'Kibbeh Nayyeh food item', 'Kofta', 'Koshari', 'Kubbah Hamouth', 'Kunafa', 'Labneh', 'Lahmacun', 'Lasagna', 'Layali Lubnan', 'Lgeimat food item', 'Lobster bisque', 'Lobster roll sandwich', 'Lubia Polo', 'Luqaimat', 'Macaroni and cheese', 'Macarons', 'Machboos', 'Machbous', 'Madrouba', 'Mahalabiya', 'Mahshi', 'Majboos', 'Majoon', 'Maklouba', 'Malabar Paratha', 'Malai Kofta', 'Malfouf', 'Malpua', 'Manakish', 'Mansaf', 'Manti', 'Maqluba', 'Margherita pizza', 'Markook food item', 'Masala Dosa', 'Mashwi', 'Matar Paneer', 'Matar Pulao', 'Meshwi', 'Mhammar', 'Miso soup', 'Moghrabieh', 'Molokhia', 'Motabbaq', 'Moutabal', 'Muhammara food item', 'Mujadara', 'Mujaddara', 'Mushroom Biryani food item', 'Mushroom Masala', 'Mussels', 'Mutabbaq', 'Mutton Biryani', 'Mutton Chops', 'Mutton Curry', 'Mutton Korma', 'Mutton Masala', 'Mutton Pulao', 'Mutton Rogan Josh', 'Nachos', 'Omelette', 'Onion rings', 'Ouzi', 'Oysters', 'Pacha', 'Pad thai', 'Paella', 'Palak Paneer', 'Pancakes', 'Paneer Biryani', 'Paneer Butter Masala', 'Paneer Tikka', 'Pani Puri', 'Panna cotta', 'Pav Bhaji', 'Payasam', 'Peda', 'Peking duck', 'Pho food', 'Pizza', 'Pork chop', 'Poutine', 'Prawn Biryani', 'Prawn Curry', 'Prawn Fried Rice', 'Prawn Masala', 'Prawn Pulao food item', 'Prime rib', 'Pulled pork sandwich', 'Quzi', 'Rabri', 'Rajma Chawal', 'Ramen', 'Rasgulla', 'Rasmalai', 'Ravioli', 'Red velvet cake', 'Risotto', 'Rogan Josh', 'Sahlab', 'Salata Hara', 'Samak Meshwi', 'Samboosa', 'Sambousek', 'Samosa', 'Sashimi food', 'Scallops', 'Seaweed salad', 'Sfiha', 'Shakshuka', 'Shanklish', 'Shawarma', 'Shawarma Rice', 'Shish Barak food item', 'Shish Taouk', 'Shorbat Adas', 'Shrimp and grits food', 'Spaghetti bolognese', 'Spaghetti carbonara', 'Spring rolls', 'Steak', 'Strawberry shortcake', 'Stuffed Grape Leaves (Dolma)', 'Sushi', 'Tabbouleh', 'Tabouleh', 'Tacos', 'Takoyaki', 'Tandoori Chicken', 'Tandoori Roti', 'Tashreeb', 'Tepsi Baytinijan', 'Tharid', 'Tiramisu', 'Tuna tartare', 'Umm Ali', 'Vada Pav', 'Veg Fried Rice', 'Veg Noodles', 'Vegetable Biryani', 'Vegetable Pulao', 'Waffles', 'Warak Enab', 'Xiao long bao (soup dumplings)', "Za'atar Bread" |
|
) |
|
|
|
model = load_learner('food_items_v_2.pkl') |
|
|
|
|
|
def food_item_names(image): |
|
pred, idx, probs = model.predict(image) |
|
print(pred, idx, probs) |
|
return dict(zip(food_names, map(float, probs))) |
|
|
|
|
|
image = gr.inputs.Image(shape=(192, 192)) |
|
label = gr.outputs.Label(num_top_classes=5) |
|
|
|
examples = [ |
|
'samples/test_1.jpg', |
|
'samples/test_2.jpg', |
|
'samples/test_3.jpg', |
|
'samples/test_4.jpg', |
|
'samples/test_5.jpg', |
|
'samples/test_6.jpg', |
|
'samples/test_7.jpg' |
|
] |
|
|
|
iface = gr.Interface(fn=food_item_names, inputs=image, |
|
outputs=label, examples=examples) |
|
iface.launch(inline=False, share=True) |
|
|