Spaces:
Runtime error
Runtime error
Updated .py to include example images in interface
Browse files
app.py
CHANGED
@@ -1,7 +1,24 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
return f"Hello, {name}"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
|
|
|
|
|
4 |
|
5 |
+
learn = load_learner("export.pkl")
|
6 |
+
|
7 |
+
labels = learn.dls.vocab
|
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 |
+
title = "Bear classifier"
|
14 |
+
description = "It can only do panda, polar or spectacled bears so far..."
|
15 |
+
interpretation= "default"
|
16 |
+
examples = ["panda.jpg","polar.jpg","spectacled.jpg"]
|
17 |
+
|
18 |
+
gr.Interface(fn = predict,
|
19 |
+
inputs = gr.inputs.Image(shape = (512, 512)),
|
20 |
+
outputs = gr.outputs.Label(num_top_classes=3),
|
21 |
+
title = title,
|
22 |
+
description = description,
|
23 |
+
examples = examples,
|
24 |
+
interpretation = interpretation).launch(share=True)
|