Spaces:
Runtime error
Runtime error
Yulu Fu
commited on
Fix input handling and update interface for multiple models
Browse files
app.py
CHANGED
@@ -6,13 +6,13 @@ audio_model = pipeline("audio-classification", model="MelodyMachine/Deepfake-aud
|
|
6 |
image_model = pipeline("image-classification", model="dima806/deepfake_vs_real_image_detection")
|
7 |
|
8 |
# Define the prediction function
|
9 |
-
def predict(
|
10 |
-
print("Data received:",
|
11 |
try:
|
12 |
if model_choice == "Audio Deepfake Detection":
|
13 |
-
result = audio_model(
|
14 |
elif model_choice == "Image Deepfake Detection":
|
15 |
-
result = image_model(
|
16 |
else:
|
17 |
return {"error": "Invalid model choice"}
|
18 |
|
@@ -42,6 +42,6 @@ with gr.Blocks() as iface:
|
|
42 |
model_choice.change(fn=update_interface, inputs=model_choice, outputs=[audio_input, image_input])
|
43 |
|
44 |
submit_button = gr.Button("Submit")
|
45 |
-
submit_button.click(fn=predict, inputs=[
|
46 |
|
47 |
iface.launch()
|
|
|
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:
|
12 |
if model_choice == "Audio Deepfake Detection":
|
13 |
+
result = audio_model(audio)
|
14 |
elif model_choice == "Image Deepfake Detection":
|
15 |
+
result = image_model(image)
|
16 |
else:
|
17 |
return {"error": "Invalid model choice"}
|
18 |
|
|
|
42 |
model_choice.change(fn=update_interface, inputs=model_choice, outputs=[audio_input, image_input])
|
43 |
|
44 |
submit_button = gr.Button("Submit")
|
45 |
+
submit_button.click(fn=predict, inputs=[audio_input, image_input, model_choice], outputs=output)
|
46 |
|
47 |
iface.launch()
|