Spaces:
Runtime error
Runtime error
klyap
commited on
Commit
•
e78d451
1
Parent(s):
bbf8f3b
add .pkl
Browse files- app.py +15 -4
- export.pkl +3 -0
app.py
CHANGED
@@ -1,7 +1,18 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
|
5 |
|
6 |
-
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
-
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
# def greet(name):
|
5 |
+
# return "Hello " + name + "!!"
|
6 |
|
7 |
+
# iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
8 |
+
# iface.launch()
|
9 |
+
|
10 |
+
learn = load_learner('export.pkl')
|
11 |
+
|
12 |
+
labels = learn.dls.vocab
|
13 |
+
def predict(img):
|
14 |
+
img = PILImage.create(img)
|
15 |
+
pred,pred_idx,probs = learn.predict(img)
|
16 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
17 |
+
|
18 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)), outputs=gr.outputs.Label(num_top_classes=3)).launch(share=True)
|
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:58579556e90a98836cc0fcd3f6d10fbcff1ec3d33baa5caac510a120c66b1da7
|
3 |
+
size 46953438
|