lucasvw commited on
Commit
6dbdc0a
1 Parent(s): 47fe1a3

app + requirements

Browse files
Files changed (2) hide show
  1. app.py +24 -4
  2. requirements.txt +2 -0
app.py CHANGED
@@ -1,7 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: ../01.ipynb.
2
+
3
+ # %% auto 0
4
+ __all__ = ['learner', 'labels', 'image', 'predict']
5
+
6
+ # %% ../01.ipynb 3
7
+ from fastai.vision.all import *
8
+
9
+ # %% ../01.ipynb 4
10
+ learner = load_learner('model.pkl')
11
+
12
+ # %% ../01.ipynb 5
13
+ labels = learner.dls.vocab
14
+ def predict(img):
15
+ img = PILImage.create(img)
16
+ pred,pred_idx,probs = learner.predict(img)
17
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
18
+
19
+ # %% ../01.ipynb 7
20
  import gradio as gr
21
 
22
+ # %% ../01.ipynb 8
23
+ image = gr.inputs.Image(shape=(512, 512))
24
+ labels = gr.outputs.Label(num_top_classes=3)
25
 
26
+ gr.Interface(fn=predict, inputs=image, outputs=labels)
27
+ gr.launch(inline=False)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ fastai==2.7.10
2
+ scikit-image