Spaces:
Running
Running
George Sergia
commited on
Commit
·
fc71058
1
Parent(s):
46ebe29
Add examples and udpate app file
Browse files- app.py +13 -4
- black.jpg +0 -0
- brown.jpg +0 -0
- grizzly.jpg +0 -0
- requirements.txt +2 -0
- teddy.jpg +0 -0
- white.jpg +0 -0
app.py
CHANGED
@@ -1,7 +1,16 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
return f"Hello {name}"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.vision.all import *
|
2 |
import gradio as gr
|
3 |
|
4 |
+
learner = load_learner("bears.pkl")
|
|
|
5 |
|
6 |
+
categories = ("grizzly", "black", "white", "brown", "teddy")
|
7 |
+
def classify_bear(img):
|
8 |
+
pred,idx,probs=learner.predict(img)
|
9 |
+
return dict(zip(categories, map(float,probs)))
|
10 |
+
|
11 |
+
image = gr.inputs.Image(shape=(192,192))
|
12 |
+
label = gr.outputs.Label()
|
13 |
+
examples=["grizzly.jpg", "brown.jpg", "white.jpg", "black.jpg", "teddy.jpg"]
|
14 |
+
|
15 |
+
iface = gr.Interface(fn=classify_bear, inputs=image, outputs=label, examples=examples)
|
16 |
+
iface.launch(inline=False)
|
black.jpg
ADDED
![]() |
brown.jpg
ADDED
![]() |
grizzly.jpg
ADDED
![]() |
requirements.txt
CHANGED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|
teddy.jpg
ADDED
![]() |
white.jpg
ADDED
![]() |