wolktm commited on
Commit
9833080
1 Parent(s): 7ec5bfa
Files changed (2) hide show
  1. app.py +16 -3
  2. mig_or_su.pkl +3 -0
app.py CHANGED
@@ -1,7 +1,20 @@
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
  import gradio as gr
2
+ from fastai.vision.all import *
3
+ # def greet(name):
4
+ # return "Hello " + name + "!!"
5
 
6
+ learn = load_learner('mig_or_su.pkl')
 
7
 
8
+ labels = learn.dls.vocab
9
+
10
+ def predict(img):
11
+ img = PILImage.create(img)
12
+ pred,pred_idx,probs = learn.predict(img)
13
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
14
+
15
+
16
+ gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3))
17
+ .launch()
18
+
19
+ # iface = gr.Interface(fn=greet, inputs="text", outputs="text")
20
  iface.launch()
mig_or_su.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bc2070cdfc6a962a20171fc7c02d4cf4b8c1348f4c51be824546ce8cd53d5e62
3
+ size 87472517