zainali95 commited on
Commit ·
5ad288c
1
Parent(s): 2f5da92
check update
Browse files- app.py +3 -4
- requirements.txt +1 -2
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from fastai.vision.all import *
|
| 3 |
-
|
| 4 |
|
| 5 |
|
| 6 |
learn = load_learner('export.pkl')
|
|
@@ -8,18 +8,17 @@ learn = load_learner('export.pkl')
|
|
| 8 |
labels = learn.dls.vocab
|
| 9 |
def predict(img):
|
| 10 |
img = PILImage.create(img)
|
| 11 |
-
|
| 12 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 13 |
|
| 14 |
title = "Bear Detector"
|
| 15 |
description = "A Bear classifier trained on the Duck Duck go data with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
| 16 |
-
article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Blog post</a></p>"
|
| 17 |
examples = ['grizzly.jpg','teddy.jpg','black.jpg']
|
| 18 |
interpretation='default'
|
| 19 |
enable_queue=True
|
| 20 |
|
| 21 |
gr.Interface(fn=predict,
|
| 22 |
-
inputs=gr.
|
| 23 |
outputs=gr.outputs.Label(num_top_classes=3),
|
| 24 |
title=title,
|
| 25 |
description=description,
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from fastai.vision.all import *
|
| 3 |
+
|
| 4 |
|
| 5 |
|
| 6 |
learn = load_learner('export.pkl')
|
|
|
|
| 8 |
labels = learn.dls.vocab
|
| 9 |
def predict(img):
|
| 10 |
img = PILImage.create(img)
|
| 11 |
+
_,_,probs = learn.predict(img)
|
| 12 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 13 |
|
| 14 |
title = "Bear Detector"
|
| 15 |
description = "A Bear classifier trained on the Duck Duck go data with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
|
|
|
| 16 |
examples = ['grizzly.jpg','teddy.jpg','black.jpg']
|
| 17 |
interpretation='default'
|
| 18 |
enable_queue=True
|
| 19 |
|
| 20 |
gr.Interface(fn=predict,
|
| 21 |
+
inputs=gr.Image(height=512, width=512),
|
| 22 |
outputs=gr.outputs.Label(num_top_classes=3),
|
| 23 |
title=title,
|
| 24 |
description=description,
|
requirements.txt
CHANGED
|
@@ -1,3 +1,2 @@
|
|
| 1 |
fastai
|
| 2 |
-
scikit-image
|
| 3 |
-
gradio==3.50
|
|
|
|
| 1 |
fastai
|
| 2 |
+
scikit-image
|
|
|