Spaces:
Runtime error
Runtime error
ttcielott
commited on
Commit
·
d84fc54
1
Parent(s):
d93573e
initial upload
Browse files- .DS_Store +0 -0
- app.py +29 -0
- c.jpeg +0 -0
- e.jpeg +0 -0
- e2.jpeg +0 -0
- e3.jpeg +0 -0
- ec.jpeg +0 -0
- export.pkl +3 -0
- g.jpeg +0 -0
- requirements.txt +1 -0
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import fastai
|
3 |
+
from fastai.vision.all import *
|
4 |
+
|
5 |
+
learn = load_learner("export.pkl")
|
6 |
+
|
7 |
+
labels = learn.dls.vocab
|
8 |
+
|
9 |
+
def predict(img):
|
10 |
+
img = PILImage.create(img)
|
11 |
+
pred, pred_idx, probs = learn.predict(img)
|
12 |
+
return {labels[i]: float(probs[i]) for i in range(len(labels))}
|
13 |
+
|
14 |
+
title = 'Animal Classifier'
|
15 |
+
description = 'Animal classifier tried with downloaded data from internet. Created as a demo for Gradio and HuggingFace Spaces.'
|
16 |
+
|
17 |
+
examples = ['c.jpeg', 'e.jpeg', 'e2.jpeg', 'e3.jpeg', 'g.jpeg', 'ec.jpeg']
|
18 |
+
interpretation = 'default'
|
19 |
+
enable_queue = True
|
20 |
+
|
21 |
+
gr.Interface(fn = predict,
|
22 |
+
inputs = gr.inputs.Image(shape=(224,224)),
|
23 |
+
outputs = gr.outputs.Label(num_top_classes = 4),
|
24 |
+
title = title,
|
25 |
+
description = description,
|
26 |
+
examples = examples,
|
27 |
+
interpretation = interpretation,
|
28 |
+
enable_queue = enable_queue
|
29 |
+
).launch(share = False)
|
c.jpeg
ADDED
![]() |
e.jpeg
ADDED
![]() |
e2.jpeg
ADDED
![]() |
e3.jpeg
ADDED
![]() |
ec.jpeg
ADDED
![]() |
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:27349ddffdd666145c588a9c924b32faa2ee70717d20db03790982a725cfb714
|
3 |
+
size 46977377
|
g.jpeg
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai
|