mendhak commited on
Commit
d82cea1
·
1 Parent(s): 3801370

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +44 -0
app.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from fastai.vision.all import *
3
+
4
+
5
+ learn = load_learner('model.pkl')
6
+
7
+ categories = ('apple_pie', 'baby_back_ribs', 'baklava', 'beef_carpaccio',
8
+ 'beef_tartare', 'beet_salad', 'beignets', 'bibimbap',
9
+ 'bread_pudding', 'breakfast_burrito', 'bruschetta', 'caesar_salad',
10
+ 'cannoli', 'caprese_salad', 'carrot_cake', 'ceviche', 'cheesecake',
11
+ 'cheese_plate', 'chicken_curry', 'chicken_quesadilla',
12
+ 'chicken_wings', 'chocolate_cake', 'chocolate_mousse', 'churros',
13
+ 'clam_chowder', 'club_sandwich', 'crab_cakes', 'creme_brulee',
14
+ 'croque_madame', 'cup_cakes', 'deviled_eggs', 'donuts',
15
+ 'dumplings', 'edamame', 'eggs_benedict', 'escargots', 'falafel',
16
+ 'filet_mignon', 'fish_and_chips', 'foie_gras', 'french_fries',
17
+ 'french_onion_soup', 'french_toast', 'fried_calamari',
18
+ 'fried_rice', 'frozen_yogurt', 'garlic_bread', 'gnocchi',
19
+ 'greek_salad', 'grilled_cheese_sandwich', 'grilled_salmon',
20
+ 'guacamole', 'gyoza', 'hamburger', 'hot_and_sour_soup', 'hot_dog',
21
+ 'huevos_rancheros', 'hummus', 'ice_cream', 'lasagna',
22
+ 'lobster_bisque', 'lobster_roll_sandwich', 'macaroni_and_cheese',
23
+ 'macarons', 'miso_soup', 'mussels', 'nachos', 'omelette',
24
+ 'onion_rings', 'oysters', 'pad_thai', 'paella', 'pancakes',
25
+ 'panna_cotta', 'peking_duck', 'pho', 'pizza', 'pork_chop',
26
+ 'poutine', 'prime_rib', 'pulled_pork_sandwich', 'ramen', 'ravioli',
27
+ 'red_velvet_cake', 'risotto', 'samosa', 'sashimi', 'scallops',
28
+ 'seaweed_salad', 'shrimp_and_grits', 'spaghetti_bolognese',
29
+ 'spaghetti_carbonara', 'spring_rolls', 'steak',
30
+ 'strawberry_shortcake', 'sushi', 'tacos', 'takoyaki', 'tiramisu',
31
+ 'tuna_tartare', 'waffles')
32
+
33
+ def classify_image(img):
34
+ pred, idx, probs = learn.predict(img)
35
+ return dict(zip(categories, map(float, probs)))
36
+
37
+
38
+ image = gr.inputs.Image(shape = (192,192))
39
+ label = gr.outputs.Label()
40
+
41
+ examples = ['tiramisu.jpeg', 'pizza.jpeg']
42
+
43
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
44
+ intf.launch(inline=False)