File size: 899 Bytes
21673ed
3b5ebda
 
eae88a9
 
 
b4c25fe
21673ed
 
 
 
 
 
 
 
 
 
 
 
3b5ebda
b4c25fe
 
 
 
21673ed
 
 
 
 
 
 
b4c25fe
 
21673ed
624b056
 
 
 
 
 
 
 
 
 
21673ed
 
 
f7be381
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from fastai.vision.all import load_learner
import gradio as gr

# import pathlib
# temp = pathlib.PosixPath
# pathlib.PosixPath = pathlib.WindowsPath

musical_instruments = (
    'Bansuri',
    'Harmonium',
    'Pakhawaz',
    'Santoor',
    'Sarangi',
    'Sarod',
    'Shehnai',
    'Sitar',
    'Tabla',
    'Tanpura'
)



model = load_learner("models/musical-instrument-recognizer-v6.pkl")


def recognize_image(image):
  pred, idx, probs = model.predict(image)
  return dict(zip(musical_instruments, map(float, probs)))



image = gr.Image()
label = gr.Label()
examples = [
    'bansuri.jfif',
    'harmonium.jfif',
    'pakhawaj.jfif',
    'santoor.jfif',
    'sarengi.jfif',
    'sarod.jfif',
    'shehnai.jfif',
    'sitar.jfif',
    'tabla.jfif',
    'tanpura.jfif'
]

iface = gr.Interface(fn=recognize_image, inputs = image, outputs= label, examples = examples)
iface.launch(inline =False)