kellyshreeve commited on
Commit
e6e53fd
·
verified ·
1 Parent(s): f823d93

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -3
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(share=True)
 
1
  import gradio as gr
2
+ from fastai.vision.all import *
3
+ import skimage
4
 
5
+ neural_net = load_learner('trained-NN.pkl')
 
6
 
7
+ labels = neural_net.dls.vocab
8
+
9
+ def predict(img):
10
+ img = PILImage.create(img)
11
+ category, idx, probs = neural_net.predict(img)
12
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
13
+
14
+ title = 'Natural Language Classifier'
15
+
16
+ examples = ['farm.jpg']
17
+
18
+ iface = gr.Interface(fn=predict,
19
+ inputs=gr.inputs.Image(shape=(512,512)),
20
+ outputs=gr.outputs.Label(num_top_classes=4),
21
+ title=title,
22
+ examples=examples)
23
  iface.launch(share=True)