Bear classifier
Browse files- app.py +14 -4
- examples/grizzly_bear.jpg +0 -0
- model.pkl +3 -0
app.py
CHANGED
@@ -1,7 +1,17 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from fastai.vision.all import load_learner, PILImage
|
3 |
|
4 |
+
learn = load_learner('export.pkl')
|
5 |
+
labels = learn.dls.vocab
|
6 |
+
def predict(img):
|
7 |
+
img = PILImage.create(img)
|
8 |
+
pred,pred_idx,probs = learn.predict(img)
|
9 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
10 |
|
11 |
+
title = "Bear Classifier"
|
12 |
+
description = "A prototype bear classifier developed with fastaiwith images from ddg. Created as a demo for Gradio and HuggingFace Spaces."
|
13 |
+
examples = [r'examples/grizzly_bear.jpg']
|
14 |
+
|
15 |
+
|
16 |
+
demo = gr.Interface(fn=predict, inputs="image", outputs="label")
|
17 |
+
demo.launch()
|
examples/grizzly_bear.jpg
ADDED
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:09864bc5b4e8cd2057c5c4f2159e0aca4fa6a88334c03f3423b6a3c1c734a1d1
|
3 |
+
size 46967274
|