Spaces:
Runtime error
Runtime error
let's deploy to huggingface spaces
Browse files- .DS_Store +0 -0
- app.py +21 -0
- black_bear.jpeg +0 -0
- model.pkl +3 -0
- requirements.txt +2 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
import skimage
|
4 |
+
|
5 |
+
learn = load_learner('./model.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 Type Classifier'
|
14 |
+
description = 'FasiAI Example on how to classify types of bears.'
|
15 |
+
article="<p style='text-align: center'><a href='https://tmabraham.github.io/blog/gradio_hf_spaces_tutorial' target='_blank'>Tutorial</a></p>"
|
16 |
+
interpretation='default'
|
17 |
+
enable_queue = True
|
18 |
+
examples = ['./black_bear.jpeg']
|
19 |
+
|
20 |
+
iface = gr.Interface(fn=predict, inputs=gr.Image(shape=(512, 512)), outputs="label", title=title, description=description, article=article, examples=examples, interpretation=interpretation, enable_queue=enable_queue)
|
21 |
+
iface.launch()
|
black_bear.jpeg
ADDED
![]() |
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7a7ce3e6b1d8b8b11c207a91d65d23dd5b9a09ccef1ea8571668137e246fa7dc
|
3 |
+
size 46971287
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
fastai
|
2 |
+
scikit-image
|