update .gitattributes so git lfs will track .pkl files
Browse files- app.py +27 -0
- bears_identifier_final.pkl +3 -0
- grizzly.jpg +3 -0
- requirements.txt +2 -0
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
import skimage
|
| 4 |
+
|
| 5 |
+
learn = load_learner('bears_identifier_final.pkl')
|
| 6 |
+
|
| 7 |
+
labels = learn.dls.vocab
|
| 8 |
+
def predict(img):
|
| 9 |
+
img = PILImage.create(img)
|
| 10 |
+
pred,pred_idx,probs = learn.predict(img)
|
| 11 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 12 |
+
|
| 13 |
+
title = "Bear Classifier"
|
| 14 |
+
description = "A bear classifier trained on DDG images with Fastai. Created as demo for Gradio and HuggingFace Spaces."
|
| 15 |
+
article="<p style='text-align: center'><a href='#' target='_blank'>TBD</a></p>"
|
| 16 |
+
examples = ['grizzly.jpg']
|
| 17 |
+
interpretation='default'
|
| 18 |
+
enable_queue=True
|
| 19 |
+
|
| 20 |
+
gr.Interface(
|
| 21 |
+
fn=predict,
|
| 22 |
+
inputs=gr.Image(),
|
| 23 |
+
outputs=gr.Label(num_top_classes=3),
|
| 24 |
+
title=title,
|
| 25 |
+
description=description,
|
| 26 |
+
article=article,
|
| 27 |
+
examples=examples,).launch(share=True)
|
bears_identifier_final.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9d61f8fdc84c322f5e46d46368f602d612b3406968c88727b005bde6b62cbf6b
|
| 3 |
+
size 46973822
|
grizzly.jpg
ADDED
|
Git LFS Details
|
requirements.txt
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastai
|
| 2 |
+
scikit-image
|