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