Spaces:
Sleeping
Sleeping
Arun Prakash
commited on
Commit
β’
794d03f
1
Parent(s):
1762772
add model
Browse files- README.md +3 -3
- app.py +31 -0
- bird2.jpg +0 -0
- export.pkl +3 -0
- forest.jpg +0 -0
- requirements.txt +1 -0
- teddy.jpg +0 -0
README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: blue
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.1.2
|
|
|
1 |
---
|
2 |
+
title: Birds
|
3 |
+
emoji: π
|
4 |
+
colorFrom: gray
|
5 |
colorTo: blue
|
6 |
sdk: gradio
|
7 |
sdk_version: 3.1.2
|
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from fastai.vision.all import *
|
3 |
+
|
4 |
+
learn = load_learner("export.pkl")
|
5 |
+
|
6 |
+
labels = learn.dls.vocab
|
7 |
+
|
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 |
+
|
15 |
+
title = "Bird or Not Classifier"
|
16 |
+
description = "A bird or not classifier trained with downloaded data from internet. Created as a demo for Gradio and HuggingFace Spaces."
|
17 |
+
|
18 |
+
examples = ["bird.jpg", "forest.jpg", "teddy.jpg"]
|
19 |
+
interpretation = "default"
|
20 |
+
enable_queue = True
|
21 |
+
|
22 |
+
gr.Interface(
|
23 |
+
fn=predict,
|
24 |
+
inputs=gr.inputs.Image(shape=(512, 512)),
|
25 |
+
outputs=gr.outputs.Label(num_top_classes=2),
|
26 |
+
title=title,
|
27 |
+
description=description,
|
28 |
+
examples=examples,
|
29 |
+
interpretation=interpretation,
|
30 |
+
enable_queue=enable_queue,
|
31 |
+
).launch()
|
bird2.jpg
ADDED
export.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0c4296d2342e7acc71fb94c54dfab4fbee014b9731e51414a59c9aa9639a5b36
|
3 |
+
size 46964769
|
forest.jpg
ADDED
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai
|
teddy.jpg
ADDED