Spaces:
Sleeping
Sleeping
Muhammad Abdullahi
commited on
Commit
·
7499d49
1
Parent(s):
094ec05
changed the code
Browse files- app.py +16 -7
- kentish.png +0 -0
- white-faced.png +0 -0
app.py
CHANGED
|
@@ -3,14 +3,23 @@ from fastai.vision.all import *
|
|
| 3 |
|
| 4 |
learner = load_learner('model.pkl')
|
| 5 |
|
|
|
|
|
|
|
| 6 |
def classify_images(img):
|
| 7 |
pred, index, probs = learner.predict(img)
|
| 8 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
intface.launch(share=True)
|
|
|
|
| 3 |
|
| 4 |
learner = load_learner('model.pkl')
|
| 5 |
|
| 6 |
+
categories = ('Kentish plover', 'White-faced plover')
|
| 7 |
+
|
| 8 |
def classify_images(img):
|
| 9 |
pred, index, probs = learner.predict(img)
|
| 10 |
+
return dict(zip(categories, map(float, probs)))
|
| 11 |
+
# return {learner.dls.vocab[i]: float(probs[i]) for i in range(len(learner.dls.vocab))}
|
| 12 |
+
|
| 13 |
+
image = gr.inputs.Image(shape=(192,192))
|
| 14 |
+
label = gr.outputs.Label()
|
| 15 |
+
examples = ['kentish.png', 'white-faced.png']
|
| 16 |
|
| 17 |
+
intf = gr.Interface(fn=classify_images, inputs=image, outputs=label, examples=examples)
|
| 18 |
+
intf.launch(inline=False)
|
| 19 |
+
# intface = gr.Interface(fn=classify_images, inputs=gr.inputs.Image(type='pil'),
|
| 20 |
+
# outputs=gr.outputs.Label(num_top_classes=2),
|
| 21 |
+
# title="Kentish plover vs White-faced plover Classifier",
|
| 22 |
+
# description="Upload an image of either Kentish plover and White-faced plover."
|
| 23 |
+
# )
|
| 24 |
|
| 25 |
+
# intface.launch(share=True)
|
kentish.png
ADDED
|
white-faced.png
ADDED
|