messing with gradio interfaces
Browse files
app.py
CHANGED
@@ -2,9 +2,14 @@ from fastai.vision.all import *
|
|
2 |
import gradio as gr
|
3 |
|
4 |
learn = load_learner('model.pkl')
|
|
|
5 |
|
6 |
-
def
|
7 |
-
|
|
|
8 |
|
9 |
-
iface = gr.Interface(fn=
|
|
|
|
|
|
|
10 |
iface.launch()
|
|
|
2 |
import gradio as gr
|
3 |
|
4 |
learn = load_learner('model.pkl')
|
5 |
+
categories = ('Cat', 'Dog')
|
6 |
|
7 |
+
def classify_image(img):
|
8 |
+
pred,idx,probs = learn.predict(img)
|
9 |
+
return dict(zip(categories, map(float,probs)))
|
10 |
|
11 |
+
iface = gr.Interface(fn=classify_image,
|
12 |
+
inputs=gr.inputs.Image(shape=(512, 512)),
|
13 |
+
outputs=gr.outputs.Label(num_top_classes=1),
|
14 |
+
title="Pet classifier")
|
15 |
iface.launch()
|