Update app.py
Browse files
app.py
CHANGED
@@ -3,15 +3,17 @@ import gradio as gr
|
|
3 |
|
4 |
def is_cat(x): return x[0].isupper()
|
5 |
|
|
|
|
|
|
|
|
|
6 |
def predict(img):
|
7 |
-
img = PILImage.create(img)
|
8 |
pred,pred_idx,probs = learn.predict(img)
|
9 |
-
return
|
10 |
|
11 |
-
learn = load_learner('model.pkl')
|
12 |
-
labels = learn.dls.vocab
|
13 |
|
14 |
-
input = gr.inputs.Image(shape=(
|
15 |
-
output = gr.outputs.Label(
|
|
|
16 |
|
17 |
-
gr.Interface(fn=predict, inputs=input, outputs=output).launch(share=
|
|
|
3 |
|
4 |
def is_cat(x): return x[0].isupper()
|
5 |
|
6 |
+
categories = ('Dog', 'Cat')
|
7 |
+
|
8 |
+
learn = load_learner('model.pkl')
|
9 |
+
|
10 |
def predict(img):
|
|
|
11 |
pred,pred_idx,probs = learn.predict(img)
|
12 |
+
return dict(zip(categories,map(float,probs)))
|
13 |
|
|
|
|
|
14 |
|
15 |
+
input = gr.inputs.Image(shape=(192, 192))
|
16 |
+
output = gr.outputs.Label()
|
17 |
+
|
18 |
|
19 |
+
gr.Interface(fn=predict, inputs=input, outputs=output).launch(share=False)
|