Spaces:
Sleeping
Sleeping
pkarthik15
commited on
Commit
•
76b17f3
1
Parent(s):
01583d8
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
model = load_learner('model.pkl')
|
5 |
+
labels = model.dls.vocab
|
6 |
+
|
7 |
+
def predict(img):
|
8 |
+
pred, pred_idex, probs = model.predict(img)
|
9 |
+
return {labels[i] : float(probs[i]) for i in range(len(labels))}
|
10 |
+
|
11 |
+
ip = gr.Image(type="pil")
|
12 |
+
op = gr.Label(num_top_classes=10)
|
13 |
+
|
14 |
+
interface = gr.Interface(fn=predict, inputs=ip, outputs=op)
|
15 |
+
interface.launch()
|