Spaces:
Sleeping
Sleeping
GVAmaresh
commited on
Commit
·
4a2f439
1
Parent(s):
3743694
dev check working
Browse files
app.py
CHANGED
|
@@ -86,8 +86,8 @@ class UnifiedDeepfakeDetector:
|
|
| 86 |
def __init__(self):
|
| 87 |
self.input_shape = (224, 224, 3)
|
| 88 |
self.vgg_model = self.build_vgg16_model()
|
| 89 |
-
self.dense_model = tf.keras.models.load_model('file.h5')
|
| 90 |
-
self.cnn_model = tf.keras.models.load_model('file2.h5')
|
| 91 |
self.melody_machine = pipeline(model="MelodyMachine/Deepfake-audio-detection-V2")
|
| 92 |
|
| 93 |
def build_vgg16_model(self):
|
|
@@ -264,4 +264,35 @@ def classify_audio(features):
|
|
| 264 |
if entropy > 150:
|
| 265 |
return True, entropy
|
| 266 |
else:
|
| 267 |
-
return False, entropy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
def __init__(self):
|
| 87 |
self.input_shape = (224, 224, 3)
|
| 88 |
self.vgg_model = self.build_vgg16_model()
|
| 89 |
+
self.dense_model = tf.keras.models.load_model('./downloads/file.h5')
|
| 90 |
+
self.cnn_model = tf.keras.models.load_model('./downloads/file2.h5')
|
| 91 |
self.melody_machine = pipeline(model="MelodyMachine/Deepfake-audio-detection-V2")
|
| 92 |
|
| 93 |
def build_vgg16_model(self):
|
|
|
|
| 264 |
if entropy > 150:
|
| 265 |
return True, entropy
|
| 266 |
else:
|
| 267 |
+
return False, entropy
|
| 268 |
+
|
| 269 |
+
#--------------------------------------------------------------------------------------------------------------------
|
| 270 |
+
from fastapi import FastAPI, File, UploadFile, Form
|
| 271 |
+
from fastapi.responses import JSONResponse
|
| 272 |
+
import torch
|
| 273 |
+
from scipy.stats import skew, kurtosis, median_abs_deviation
|
| 274 |
+
import shutil
|
| 275 |
+
import subprocess
|
| 276 |
+
import os
|
| 277 |
+
import librosa
|
| 278 |
+
|
| 279 |
+
|
| 280 |
+
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
|
| 281 |
+
os.environ["MPLCONFIGDIR"] = "/tmp/matplotlib"
|
| 282 |
+
os.environ["FONTCONFIG_PATH"] = "/tmp/fontconfig"
|
| 283 |
+
os.environ["HF_HOME"] = "/tmp/huggingface_cache"
|
| 284 |
+
|
| 285 |
+
os.makedirs("/tmp/matplotlib", exist_ok=True)
|
| 286 |
+
os.makedirs("/tmp/fontconfig", exist_ok=True)
|
| 287 |
+
os.makedirs("/tmp/huggingface_cache", exist_ok=True)
|
| 288 |
+
|
| 289 |
+
SAVE_DIR = './audio'
|
| 290 |
+
os.makedirs(SAVE_DIR, exist_ok=True)
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
def reencode_audio(input_path, output_path):
|
| 294 |
+
command = [
|
| 295 |
+
'ffmpeg', '-i', input_path, '-acodec', 'pcm_s16le', '-ar', '16000', '-ac', '1', output_path
|
| 296 |
+
]
|
| 297 |
+
subprocess.run(command, check=True)
|
| 298 |
+
|