Noctis77 commited on
Commit
4816f88
1 Parent(s): 0e76fa6

[UPD] app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -1,17 +1,19 @@
1
  import streamlit as st
2
  import librosa
3
  import numpy as np
4
- import pickle
5
  import IPython.display as ipd
6
  from sklearn.preprocessing import LabelEncoder
7
  from tensorflow.keras.models import load_model
8
 
9
 
10
- # le = LabelEncoder()
11
-
12
  model = load_model('model/audio_prediction_model')
13
 
14
 
 
 
 
 
15
  def prediction_audio(audiofile, model):
16
 
17
  audio_data, sample_rate = librosa.load(audiofile, res_type='kaiser_fast')
@@ -22,7 +24,7 @@ def prediction_audio(audiofile, model):
22
  predicted_label = np.argmax(model.predict(X), axis=-1)
23
  # predicted_class = le.inverse_transform(predicted_label)
24
 
25
- return predicted_label[0]
26
 
27
  st.title("Détection de coups de feu")
28
 
 
1
  import streamlit as st
2
  import librosa
3
  import numpy as np
4
+ import pandas as pd
5
  import IPython.display as ipd
6
  from sklearn.preprocessing import LabelEncoder
7
  from tensorflow.keras.models import load_model
8
 
9
 
 
 
10
  model = load_model('model/audio_prediction_model')
11
 
12
 
13
+ df = pd.read_csv('UrbanSound8K.csv')
14
+
15
+ categories = df.groupby('classID')['class'].unique
16
+
17
  def prediction_audio(audiofile, model):
18
 
19
  audio_data, sample_rate = librosa.load(audiofile, res_type='kaiser_fast')
 
24
  predicted_label = np.argmax(model.predict(X), axis=-1)
25
  # predicted_class = le.inverse_transform(predicted_label)
26
 
27
+ return categories[predicted_label][0]
28
 
29
  st.title("Détection de coups de feu")
30