nkgreenk commited on
Commit
1e42e9a
1 Parent(s): 7f39f7e

feat(app): init bear classifier app

Browse files
Files changed (3) hide show
  1. app.py +25 -0
  2. bear-classifier.pkl +3 -0
  3. grizzly.jpg +0 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastai.vision.all import *
2
+ import gradio as gr
3
+
4
+
5
+ learn = load_learner("bear-classifier.pkl")
6
+ labels = learn.dls.vocab
7
+
8
+ def predict(img):
9
+ """
10
+ Prediction APIs.
11
+ """
12
+ _, _, probs = learn.predict(PILImage.create(img))
13
+
14
+ return {labels[i]: float(probs[i]) for i in range(len(labels))}
15
+
16
+
17
+ demo = gr.Interface(
18
+ fn=predict,
19
+ inputs=gr.Image(),
20
+ outputs=gr.Label(num_top_classes=3),
21
+ title="Bear Classifier",
22
+ description="A bear classifier fine tuned on ResNet18 with a few bear samples from the internet. Its task is to recognize whether an image is a grizzy bear, a black bear or just a cute litte teddy bear!",
23
+ examples=["grizzly.jpg"]
24
+ )
25
+ demo.launch()
bear-classifier.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0e40bf0a5f9539cc8ad4e946e9678a919021c56a50624d1c429dd714941eb53f
3
+ size 46976562
grizzly.jpg ADDED