Spaces:
Runtime error
Runtime error
Commit
·
dcdd6b6
1
Parent(s):
b293739
Add model
Browse files- app.py +28 -4
- black_bear.jpg +0 -0
- brizzly_bear.jpg +0 -0
- model.pkl +3 -0
- requirements.txt +1 -1
- teddy_bear.jpg +0 -0
app.py
CHANGED
@@ -1,7 +1,31 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
|
4 |
+
learn = load_learner("model.pkl")
|
|
|
5 |
|
6 |
+
categories = learn.dls.vocab
|
7 |
+
|
8 |
+
|
9 |
+
def predict(img):
|
10 |
+
pred, pred_idx, probs = learn.predict(img)
|
11 |
+
return dict(zip(categories, map(float, probs)))
|
12 |
+
|
13 |
+
|
14 |
+
title = "Bear Classifier"
|
15 |
+
description = "A bear classifier trained on the images downloaded from bing serach with fastai."
|
16 |
+
|
17 |
+
image = gr.inputs.Image(shape=(192, 192))
|
18 |
+
label = gr.outputs.Label()
|
19 |
+
examples = ["black_bear.jpg", "brizzly_bear.jpg", "teddy_bear.jpg"]
|
20 |
+
interpretation = "default"
|
21 |
+
enable_queue = True
|
22 |
+
|
23 |
+
itf = gr.Interface(fn=predict,
|
24 |
+
inputs=image,
|
25 |
+
outputs=label,
|
26 |
+
title=title,
|
27 |
+
examples=examples,
|
28 |
+
interpretation=interpretation,
|
29 |
+
enable_queue=enable_queue)
|
30 |
+
|
31 |
+
itf.launch()
|
black_bear.jpg
ADDED
![]() |
brizzly_bear.jpg
ADDED
![]() |
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a833796d069acc4ac134e87f8044a6e29b0b872949fc77f19cac7d35ab40f72d
|
3 |
+
size 46969551
|
requirements.txt
CHANGED
@@ -1 +1 @@
|
|
1 |
-
|
|
|
1 |
+
fastai
|
teddy_bear.jpg
ADDED
![]() |