James_Byers commited on
Commit ·
4a3bd29
1
Parent(s): cde4692
changed app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,20 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import fastbook
|
| 3 |
+
from fastbook import *
|
| 4 |
+
from fastai.vision.all import *
|
| 5 |
+
from fastcore.all import*
|
| 6 |
|
| 7 |
+
learn = load_learner('my_model.pkl')
|
| 8 |
+
|
| 9 |
+
labels = learn.dls.vocab
|
| 10 |
+
|
| 11 |
+
def predict(img):
|
| 12 |
+
img = PILImage.create(im)
|
| 13 |
+
pred, pred_idx, probs = learn.predict(img)
|
| 14 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 15 |
+
|
| 16 |
+
intf = gr.Interface(fn=predict,
|
| 17 |
+
inputs=gr.inputs.Image(shape=(512, 512)),
|
| 18 |
+
outputs=gr.outputs.Label(num_top_classes=2))
|
| 19 |
+
|
| 20 |
+
intf.launch(inline=False)
|