Update app.py
Browse files
app.py
CHANGED
|
@@ -5,14 +5,14 @@ from model_utils import load_model, prepare_input_for_model, interpret_predictio
|
|
| 5 |
|
| 6 |
MODEL_PATH = "best_audio_model.keras"
|
| 7 |
|
| 8 |
-
# Load
|
| 9 |
model = load_model(MODEL_PATH)
|
| 10 |
|
| 11 |
def predict_audio(file_path):
|
| 12 |
try:
|
| 13 |
features = extract_features_with_time_series(file_path)
|
| 14 |
if features is None:
|
| 15 |
-
return {"Error": "Feature extraction failed. Please check the audio."}
|
| 16 |
|
| 17 |
input_data = prepare_input_for_model(features, model)
|
| 18 |
raw_pred = model.predict(input_data)
|
|
@@ -26,8 +26,8 @@ iface = gr.Interface(
|
|
| 26 |
inputs=gr.Audio(type="filepath", label="Upload an audio file"),
|
| 27 |
outputs=gr.Label(num_top_classes=2, label="Prediction"),
|
| 28 |
title="Audio Deepfake Detection",
|
| 29 |
-
description="Upload an audio clip to
|
| 30 |
)
|
| 31 |
|
| 32 |
if __name__ == "__main__":
|
| 33 |
-
iface.launch(server_name="0.0.0.0", server_port=7860
|
|
|
|
| 5 |
|
| 6 |
MODEL_PATH = "best_audio_model.keras"
|
| 7 |
|
| 8 |
+
# Load the model once
|
| 9 |
model = load_model(MODEL_PATH)
|
| 10 |
|
| 11 |
def predict_audio(file_path):
|
| 12 |
try:
|
| 13 |
features = extract_features_with_time_series(file_path)
|
| 14 |
if features is None:
|
| 15 |
+
return {"Error": "Feature extraction failed. Please check the audio file."}
|
| 16 |
|
| 17 |
input_data = prepare_input_for_model(features, model)
|
| 18 |
raw_pred = model.predict(input_data)
|
|
|
|
| 26 |
inputs=gr.Audio(type="filepath", label="Upload an audio file"),
|
| 27 |
outputs=gr.Label(num_top_classes=2, label="Prediction"),
|
| 28 |
title="Audio Deepfake Detection",
|
| 29 |
+
description="Upload an audio clip to check if it's Real or Fake using your trained .keras model."
|
| 30 |
)
|
| 31 |
|
| 32 |
if __name__ == "__main__":
|
| 33 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|