Spaces:
Sleeping
Sleeping
nkhimin
commited on
Commit
·
4d52199
1
Parent(s):
55cf0b2
added categorization
Browse files
app.py
CHANGED
@@ -18,11 +18,11 @@ learn = load_learner("model-export.pkl")
|
|
18 |
|
19 |
labels = learn.dls.vocab
|
20 |
|
21 |
-
|
22 |
-
def
|
23 |
img = PILImage.create(img)
|
24 |
-
pred,
|
25 |
-
return
|
26 |
|
27 |
|
28 |
title = "Pet Breed Classifier"
|
@@ -33,7 +33,7 @@ allowed_extensions = {'.png', '.jpg', '.jpeg', '.bmp', '.gif'}
|
|
33 |
examples = [file for file in path.iterdir() if file.suffix.lower() in allowed_extensions]
|
34 |
|
35 |
gr.Interface(
|
36 |
-
fn=
|
37 |
inputs="image",
|
38 |
outputs="label",
|
39 |
title=title,
|
|
|
18 |
|
19 |
labels = learn.dls.vocab
|
20 |
|
21 |
+
categories = ('Dog', 'Cat')
|
22 |
+
def classify_image(img):
|
23 |
img = PILImage.create(img)
|
24 |
+
pred,idx,probs = learn.predict(img)
|
25 |
+
return dict(zip(categories, map(float,probs)))
|
26 |
|
27 |
|
28 |
title = "Pet Breed Classifier"
|
|
|
33 |
examples = [file for file in path.iterdir() if file.suffix.lower() in allowed_extensions]
|
34 |
|
35 |
gr.Interface(
|
36 |
+
fn=classify_image,
|
37 |
inputs="image",
|
38 |
outputs="label",
|
39 |
title=title,
|