Spaces:
Sleeping
Sleeping
Updating app.py per Gradio tutorial
Browse files- app.py +10 -0
- black bear.jfif +0 -0
- grizzly bear.jfif +0 -0
- requirements.txt +2 -1
app.py
CHANGED
@@ -1,15 +1,25 @@
|
|
1 |
from fastai.vision.all import *
|
2 |
import gradio as gr
|
|
|
3 |
|
4 |
learn = load_learner('bearmodel.pkl')
|
5 |
|
|
|
|
|
6 |
def predict(img):
|
7 |
img = PILImage.create(img)
|
8 |
pred,pred_idx,probs = learn.predict(img)
|
9 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
10 |
|
|
|
|
|
|
|
11 |
image = gr.Image(height=192, width=192)
|
12 |
label = gr.Label()
|
|
|
|
|
|
|
|
|
13 |
|
14 |
intf = gr.Interface(fn=predict, inputs=image, outputs=label)
|
15 |
intf.launch(inline=False)
|
|
|
1 |
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
+
import skimage
|
4 |
|
5 |
learn = load_learner('bearmodel.pkl')
|
6 |
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
|
9 |
def predict(img):
|
10 |
img = PILImage.create(img)
|
11 |
pred,pred_idx,probs = learn.predict(img)
|
12 |
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
13 |
|
14 |
+
title = "Bear Breed Classifier"
|
15 |
+
description = "A bear breed classifier trained on a custom dataset from DDG images with fastai. Created as a demo for Gradio and HuggingFace Spaces."
|
16 |
+
interpretation='default'
|
17 |
image = gr.Image(height=192, width=192)
|
18 |
label = gr.Label()
|
19 |
+
examples = ['black bear.jpg', 'grizzly bear.jpg']
|
20 |
+
|
21 |
+
|
22 |
+
enable_queue=True
|
23 |
|
24 |
intf = gr.Interface(fn=predict, inputs=image, outputs=label)
|
25 |
intf.launch(inline=False)
|
black bear.jfif
ADDED
Binary file (11.6 kB). View file
|
|
grizzly bear.jfif
ADDED
Binary file (12.8 kB). View file
|
|
requirements.txt
CHANGED
@@ -1 +1,2 @@
|
|
1 |
-
fastai
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|