Spaces:
Sleeping
Sleeping
add model file and new gradio code
Browse files- _orig_app.py +8 -0
- app.py +25 -4
- model.pkl +3 -0
- sample1.jpg +0 -0
- sample2.jpg +0 -0
- sample3.jpg +0 -0
_orig_app.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import fastai.vision.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
def greet(name):
|
5 |
+
return "Hello " + name + "!!"
|
6 |
+
|
7 |
+
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
8 |
+
iface.launch(share=True)
|
app.py
CHANGED
@@ -1,7 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
iface.launch(share=True)
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: BearClassifierGradio.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
|
5 |
+
|
6 |
+
# %% BearClassifierGradio.ipynb 3
|
7 |
+
# importing dependencies
|
8 |
+
from fastai.vision.all import *
|
9 |
import gradio as gr
|
10 |
|
11 |
+
# %% BearClassifierGradio.ipynb 4
|
12 |
+
# creating inference
|
13 |
+
learn = load_learner('model.pkl')
|
14 |
+
|
15 |
+
# %% BearClassifierGradio.ipynb 5
|
16 |
+
categories = ('Black', 'Grizzly', 'Teddy')
|
17 |
+
|
18 |
+
def classify_image(img):
|
19 |
+
pred, idx, probs = learn.predict(img)
|
20 |
+
return dict(zip(categories, map(float, probs)))
|
21 |
+
|
22 |
+
# %% BearClassifierGradio.ipynb 6
|
23 |
+
# gradio interface Setup
|
24 |
+
image = gr.Image()
|
25 |
+
label = gr.Label()
|
26 |
+
examples = ['sample1.jpg', 'sample2.jpg', 'sample3.jpg']
|
27 |
|
28 |
+
intf = gr.Interface(fn = classify_image, inputs = image, outputs = label, examples = examples).launch()
|
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0e91f26108afdc5c460aa3ed3396c909ce7005fae6bcf4de8b84b44fd3897fd8
|
3 |
+
size 46970538
|
sample1.jpg
ADDED
sample2.jpg
ADDED
sample3.jpg
ADDED