Spaces:
Runtime error
Runtime error
Nifdi Guliyev
commited on
Commit
·
ba67d64
1
Parent(s):
3a68b05
message
Browse files
app.py
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from fastai.vision.all import *
|
| 2 |
import gradio as gr
|
| 3 |
import timm
|
| 4 |
|
|
|
|
| 5 |
learn = load_learner('breed_model.pkl')
|
| 6 |
|
|
|
|
| 7 |
categories = learn.dls.vocab
|
| 8 |
|
| 9 |
def classify_image(img):
|
| 10 |
-
pred,
|
| 11 |
-
return dict(zip(categories, map(float,
|
| 12 |
|
| 13 |
-
|
|
|
|
| 14 |
label = gr.outputs.Label()
|
| 15 |
examples = ['basset.jpg']
|
| 16 |
|
|
|
|
| 17 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 18 |
-
intf.launch(
|
|
|
|
| 1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: . (unless otherwise specified).
|
| 2 |
+
|
| 3 |
+
__all__ = ['learn', 'classify_image', 'categories', 'image', 'label', 'examples', 'intf']
|
| 4 |
+
|
| 5 |
+
# Cell
|
| 6 |
from fastai.vision.all import *
|
| 7 |
import gradio as gr
|
| 8 |
import timm
|
| 9 |
|
| 10 |
+
# Cell
|
| 11 |
learn = load_learner('breed_model.pkl')
|
| 12 |
|
| 13 |
+
# Cell
|
| 14 |
categories = learn.dls.vocab
|
| 15 |
|
| 16 |
def classify_image(img):
|
| 17 |
+
pred,idx,probs = learn.predict(img)
|
| 18 |
+
return dict(zip(categories, map(float,probs)))
|
| 19 |
|
| 20 |
+
# Cell
|
| 21 |
+
image = gr.inputs.Image(shape=(192, 192))
|
| 22 |
label = gr.outputs.Label()
|
| 23 |
examples = ['basset.jpg']
|
| 24 |
|
| 25 |
+
# Cell
|
| 26 |
intf = gr.Interface(fn=classify_image, inputs=image, outputs=label, examples=examples)
|
| 27 |
+
intf.launch()
|