ptoro commited on
Commit
4a8d93f
1 Parent(s): 8a05d62

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -3
app.py CHANGED
@@ -1,6 +1,26 @@
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
- def greet(name):
4
- return "Hello" + name + "."
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- gr.Interface(fn=greet, inputs="text", outputs="text").launch()
 
 
1
+ # AUTOGENERATED! DO NOT EDIT! File to edit: app.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learn', 'labels', 'image', 'label', 'examples', 'intf', 'classify_image']
5
+
6
+ # %% app.ipynb 1
7
+ from fastai.vision.all import *
8
  import gradio as gr
9
 
10
+ # %% app.ipynb 3
11
+ learn = load_learner('eh_native_plants.pkl')
12
+
13
+ # %% app.ipynb 6
14
+ labels = learn.dls.vocab
15
+
16
+ def classify_image(img):
17
+ pred,pred_idx,probs = learn.predict(img)
18
+ return dict(zip(labels, map(float, probs)))
19
+
20
+ # %% app.ipynb 8
21
+ image = gr.Image(shape=(192,192))
22
+ label = gr.Label()
23
+ examples = ['ind_grass.jpg', 'reed.jpg']
24
 
25
+ intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, example=examples)
26
+ intf.launch(inline=False)