Spaces:
Sleeping
Sleeping
Added files
Browse files- app.py +21 -0
- bear_classifier_myver.pkl +3 -0
- black+bear1.jpg +0 -0
- black_bear2.jpg +0 -0
- grizzly_bear1.jpg +0 -0
- grizzly_bear2.jpg +0 -0
- requirements.txt +1 -0
- teddy1.jpg +0 -0
- teddy2.jpg +0 -0
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
__all__=['learn','classify_image','categories','examples','intf']
|
2 |
+
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
#load the learner
|
6 |
+
learn=load_learner('bear_classifier_myver.pkl')
|
7 |
+
|
8 |
+
# define categories
|
9 |
+
categories=['Black bear','Grizzly bear','Teddy bear']
|
10 |
+
|
11 |
+
# define the function to classify images
|
12 |
+
def classify_image(img):
|
13 |
+
pred,idx,probs=learn.predict(img)
|
14 |
+
return dict(zip(categories,map(float,probs)))
|
15 |
+
|
16 |
+
# example images
|
17 |
+
examples=['grizzly_bear1.jpg','grizzly_bear2.jpg','black+bear1.jpg','black_bear2.jpg','teddy1.jpg','teddy1.jpg']
|
18 |
+
|
19 |
+
# creating the interface
|
20 |
+
intf=gr.Interface(fn=classify_image,inputs="image",outputs="label",examples=examples)
|
21 |
+
intf.launch(inline=False)
|
bear_classifier_myver.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2a2f26b35bfa797d048c3e6f8ae818dfd5a39fcb8febbde5d5848a8c28e96730
|
3 |
+
size 46982442
|
black+bear1.jpg
ADDED
black_bear2.jpg
ADDED
grizzly_bear1.jpg
ADDED
grizzly_bear2.jpg
ADDED
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai
|
teddy1.jpg
ADDED
teddy2.jpg
ADDED