Spaces:
Runtime error
Runtime error
dhairyashah
commited on
Commit
•
942b161
1
Parent(s):
1336633
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
|
|
3 |
|
4 |
# Load the models using pipeline
|
5 |
audio_model = pipeline("audio-classification", model="MelodyMachine/Deepfake-audio-detection-V2")
|
6 |
image_model = pipeline("image-classification", model="dima806/deepfake_vs_real_image_detection")
|
7 |
|
8 |
# Define the prediction function
|
|
|
9 |
def predict(audio, image, model_choice):
|
10 |
print("Data received:", audio if model_choice == "Audio Deepfake Detection" else image) # Debugging statement
|
11 |
try:
|
@@ -26,6 +28,7 @@ def predict(audio, image, model_choice):
|
|
26 |
return {"error": str(e)}
|
27 |
|
28 |
# Update interface based on the selected model
|
|
|
29 |
def update_interface(model_choice):
|
30 |
if model_choice == "Audio Deepfake Detection":
|
31 |
return gr.update(visible=True), gr.update(visible=False)
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
+
import spaces
|
4 |
|
5 |
# Load the models using pipeline
|
6 |
audio_model = pipeline("audio-classification", model="MelodyMachine/Deepfake-audio-detection-V2")
|
7 |
image_model = pipeline("image-classification", model="dima806/deepfake_vs_real_image_detection")
|
8 |
|
9 |
# Define the prediction function
|
10 |
+
@spaces.GPU
|
11 |
def predict(audio, image, model_choice):
|
12 |
print("Data received:", audio if model_choice == "Audio Deepfake Detection" else image) # Debugging statement
|
13 |
try:
|
|
|
28 |
return {"error": str(e)}
|
29 |
|
30 |
# Update interface based on the selected model
|
31 |
+
@spaces.GPU
|
32 |
def update_interface(model_choice):
|
33 |
if model_choice == "Audio Deepfake Detection":
|
34 |
return gr.update(visible=True), gr.update(visible=False)
|