Spaces:
Build error
Build error
Commit ·
d83e0f7
1
Parent(s): f977834
Initial commit 2
Browse files- app.py +12 -0
- bears_model.pkl +3 -0
- requirements.txt +1 -0
app.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from fastai.vision.all import *
|
| 3 |
+
|
| 4 |
+
learn = load_learner('bears_model.pkl')
|
| 5 |
+
labels = learn.dls.vocab
|
| 6 |
+
|
| 7 |
+
def predict(img):
|
| 8 |
+
img = PILImage.create(img)
|
| 9 |
+
pred,pred_idx,probs = learn.predict(img)
|
| 10 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
| 11 |
+
|
| 12 |
+
gr.Interface(fn=predict,inputs="image",outputs="label").launch()
|
bears_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:eb11037b4d1b03a02ec003ed4e68890d2a4f454ff1577d8192b871d906b6b6ea
|
| 3 |
+
size 46975102
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
fastai
|