Kimata commited on
Commit
3f3f7e7
·
1 Parent(s): e50136c

add librosa to requirements and add audio labelmap

Browse files
Files changed (2) hide show
  1. pipeline.py +7 -1
  2. requirements.txt +2 -1
pipeline.py CHANGED
@@ -205,6 +205,11 @@ def load_audio_model():
205
  model = model.load_state_dict(ckpt, model_dict)
206
  return model
207
 
 
 
 
 
 
208
  def deepfakes_audio_predict(input_audio):
209
  #Perform inference on audio.
210
  x, sr = librosa.load(input_audio)
@@ -220,4 +225,5 @@ def deepfakes_audio_predict(input_audio):
220
  #Get the argmax.
221
  grads_np = grads.detach().numpy()
222
  result = np.argmax(grads_np)
223
- return result
 
 
205
  model = model.load_state_dict(ckpt, model_dict)
206
  return model
207
 
208
+ audio_label_map = {
209
+ 0: "real"
210
+ 1: "fake"
211
+ }
212
+
213
  def deepfakes_audio_predict(input_audio):
214
  #Perform inference on audio.
215
  x, sr = librosa.load(input_audio)
 
225
  #Get the argmax.
226
  grads_np = grads.detach().numpy()
227
  result = np.argmax(grads_np)
228
+
229
+ return audio_label_map[result]
requirements.txt CHANGED
@@ -5,4 +5,5 @@ numpy
5
  opencv-python
6
  opencv-python-headless
7
  mtcnn
8
- moviepy
 
 
5
  opencv-python
6
  opencv-python-headless
7
  mtcnn
8
+ moviepy
9
+ librosa