test
Browse files
app.py
CHANGED
@@ -1,7 +1,21 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
|
4 |
+
path = Path()
|
5 |
+
learn_inf = load_learner(path / 'export.pkl')
|
6 |
|
7 |
+
labels = ['beach', 'field', 'lake']
|
8 |
+
|
9 |
+
def predict(img):
|
10 |
+
img = PILImage.create(img)
|
11 |
+
pred, pred_idx, probs = learn_inf.predict(img)
|
12 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
13 |
+
|
14 |
+
|
15 |
+
gr_interface = gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)),
|
16 |
+
outputs=gr.outputs.Label(num_top_classes=len(labels)), interpretation="default")
|
17 |
+
|
18 |
+
gr_interface = gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(512, 512)),
|
19 |
+
outputs=gr.outputs.Label(num_top_classes=len(labels)),
|
20 |
+
interpretation="default")
|
21 |
+
gr_interface.launch()
|