bigyunicorn commited on
Commit
8539cc1
·
1 Parent(s): c5bf3ae

adding updated app.py with loading model logic and requirements.txt

Browse files
Files changed (2) hide show
  1. app.py +19 -3
  2. requirements.txt +2 -0
app.py CHANGED
@@ -1,7 +1,23 @@
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
5
 
6
- iface = gr.Interface(fn=greet, inputs="text", outputs="text")
 
 
 
 
 
 
 
 
7
  iface.launch()
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: sashimiIdentier.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learner', 'categories', 'img_examples', 'iface', 'sashimiIentifer']
5
+
6
+ # %% sashimiIdentier.ipynb 19
7
+ from fastai.vision.all import *
8
  import gradio as gr
9
 
10
+ # %% sashimiIdentier.ipynb 20
11
+ # first load the learner
12
+ learner = load_learner ('./sashimiModel.pkl')
13
 
14
+ # %% sashimiIdentier.ipynb 21
15
+ # combine with gradio.
16
+ categories = ['Ahi(Yellowfin & Bigeye Tuna)', 'Ebi(Sweet Shrimp/Prawns)', 'Hamachi(Yellowtail)', 'Hamadai(Red Snapper)', 'Hotate(Scallops)', 'Ika(Squid)', 'Katsuo(Bonito/Skipjack Tuna)', 'Maguro(Bluefin Tuna)', 'Saba(Japanese Mackerel)', 'Sake(Salmon)']
17
+ def sashimiIentifer(input_imgFilePath):
18
+ (pred,idx,probs) = learner.predict(input_imgFilePath)
19
+ return dict(zip(categories, map(float, probs)))
20
+
21
+ img_examples = ["Hotate_Scallops.jpg", "Ahi_YellowfinAndBigeyeTuna_Sashimi.jpg", "dalle_EngawaAndHotate.png"]
22
+ iface = gr.Interface(fn=sashimiIentifer, inputs="image", outputs="label", examples =img_examples, title="Sashimi Identier", description="This app identifies which sashimi it is based on the given image")
23
  iface.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai
2
+ gradio