File size: 1,478 Bytes
30f32d0
 
 
 
ed060a2
 
42031f0
 
 
 
 
a913d8c
30f32d0
 
 
 
 
6ef206a
30f32d0
 
 
09e4761
30f32d0
 
 
 
 
 
 
 
 
ed060a2
30f32d0
 
 
13fc1f5
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
import gradio as gr

from fastai.vision.all import *

from fastaudio.core.all import *

def get_x(df):
    return df.path
def get_y(df):
    return df.pattern
   
learn = load_learner('xresnet50_pitch3.pkl')

labels = learn.dls.vocab

def predict(path):

    pred,pred_idx,probs = learn.predict(str(path))

    return {labels[i]: float(probs[i]) for i in range(len(labels))}

print(predict('example1.mp3'))

title = "Japanese Pitch Accent Pattern Detector"

description = "Fire and Smoke classifier created with fastai. Created as a demo for Gradio and HuggingFace Spaces. Fire accidents are not uncommon and has catastrophic impact on the company both interms of social and financial terms. This application can be deployed on device and can work as 24X365 surveillance. This app classify an image into three classes. 1. Fire, 2. Smoke, 3. Neutral. Try your hand and check. For any general purpose, model file can be copied and used for the stated purpose"

article="<p style='text-align: center'><a href='https://github.com/mldurga/projects/blob/master/Fire_smoke_detector.ipynb' target='_blank'>Blog post</a></p>"

interpretation='default'

examples = ['example1.mp3']

enable_queue=True

gr.Interface(fn=predict,inputs=gr.inputs.Audio(source='microphone', type='filepath'),outputs=gr.outputs.Label(num_top_classes=3),title=title,description=description,article=article,interpretation=interpretation,examples=examples).launch(debug=True,share=True,enable_queue=enable_queue)