Spaces:
Runtime error
Runtime error
neerajhanda
commited on
Commit
•
f1238a3
1
Parent(s):
bb84eed
Added application code and model
Browse files
app.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AUTOGENERATED! DO NOT EDIT! File to edit: ../app.ipynb.
|
2 |
+
|
3 |
+
# %% auto 0
|
4 |
+
__all__ = ['learn', 'categories', 'image', 'label', 'examples', 'intf', 'classify_image']
|
5 |
+
|
6 |
+
# %% ../app.ipynb 1
|
7 |
+
from fastai.vision.all import *
|
8 |
+
import gradio as gr
|
9 |
+
|
10 |
+
# %% ../app.ipynb 2
|
11 |
+
learn = load_learner('model.pkl')
|
12 |
+
|
13 |
+
# %% ../app.ipynb 6
|
14 |
+
categories = ('didgeridoo','tambourine','xylophone','acordian','alphorn','bagpipes','banjo','bongo drum','casaba','castanets','clarinet','clavichord','concertina','drums','dulcimer','flute','guiro','guitar','harmonica','harp','marakas','ocarina','piano','saxaphone','sitar','steel drum','trombone','trumpet','tuba','violin')
|
15 |
+
def classify_image(img):
|
16 |
+
pred,idx,probs = learn.predict(img)
|
17 |
+
return dict(zip(categories,map(float,probs)))
|
18 |
+
|
19 |
+
# %% ../app.ipynb 8
|
20 |
+
image = gr.inputs.Image(shape=(224,224))
|
21 |
+
label=gr.outputs.Label()
|
22 |
+
examples=['banjo.jpg']
|
23 |
+
intf = gr.Interface(fn=classify_image,inputs=image,outputs=label,examples=examples)
|
24 |
+
intf.launch(inline=False)
|
banjo.jpg
ADDED
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:74ed647357a1c7a6c823426003ac3e675fd8a8f5dd93625185a84015eaea46c0
|
3 |
+
size 47081297
|