Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from icevision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
learn = load_learner('fasterRCNNKangaroo.pth')
|
5 |
+
|
6 |
+
labels = learn.dls.vocab
|
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 |
+
gr.Interface(fn=predict, inputs=gr.inputs.Image(shape=(128,128)), outputs=gr.outputs.Label(num_top_classes=3),examples=['00001.jpg','00002.jpg']).launch(share=False)
|