mhdhrubo's picture
model,interface,examples added
21673ed
raw
history blame
954 Bytes
from fastai.vision.all import load_learner
import gradio as gr
musical_instruments = (
'Bansuri',
'Harmonium',
'Pakhawaz',
'Santoor',
'Sarangi',
'Sarod',
'Shehnai',
'Sitar',
'Tabla',
'Tanpura'
)
model = load_learner(f"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.inputs.Image(shape=(192,192))
label = gr.outputs.Label()
examples = [
'test_data/bansuri.jfif',
'test_data/harmonium.jfif',
'test_data/pakhawaj.jfif',
'test_data/santoor.jfif',
'test_data/sarengi.jfif',
'test_data/sarod.jfif',
'test_data/shehnai.jfif',
'test_data/sitar.jfif',
'test_data/tabla.jfif',
'test_data/tanpura.jfif'
]
iface = gr.Interface(fn=recognize_image, inputs = image, outputs= label, examples = examples)
iface.launch(inline =False, share = True)