Spaces:
Runtime error
Runtime error
Yulu Fu
commited on
Update placeholder for image
Browse files
app.py
CHANGED
@@ -25,34 +25,23 @@ def predict(data, model_choice):
|
|
25 |
print("Error during prediction:", e) # Debugging statement
|
26 |
return {"error": str(e)}
|
27 |
|
28 |
-
#
|
29 |
def update_interface(model_choice):
|
30 |
if model_choice == "Audio Deepfake Detection":
|
31 |
-
return gr.
|
32 |
elif model_choice == "Image Deepfake Detection":
|
33 |
-
return gr.
|
34 |
-
else:
|
35 |
-
return None, None
|
36 |
|
37 |
# Create the Gradio interface
|
38 |
with gr.Blocks() as iface:
|
39 |
model_choice = gr.Radio(choices=["Audio Deepfake Detection", "Image Deepfake Detection"], label="Select Model", value="Audio Deepfake Detection")
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
input_placeholder.update(visible=True, component=input_component)
|
47 |
-
output_placeholder.update(visible=True, component=output_component)
|
48 |
-
|
49 |
-
input_placeholder = gr.Placeholder(gr.Component, visible=True)
|
50 |
-
output_placeholder = gr.Placeholder(gr.Component, visible=True)
|
51 |
-
|
52 |
-
model_choice.change(fn=update_inputs, inputs=model_choice, outputs=[input_placeholder, output_placeholder])
|
53 |
-
|
54 |
submit_button = gr.Button("Submit")
|
55 |
-
submit_button.click(fn=predict, inputs=[
|
56 |
|
57 |
iface.launch()
|
58 |
-
|
|
|
25 |
print("Error during prediction:", e) # Debugging statement
|
26 |
return {"error": str(e)}
|
27 |
|
28 |
+
# Function to update the 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)
|
32 |
elif model_choice == "Image Deepfake Detection":
|
33 |
+
return gr.update(visible=False), gr.update(visible=True)
|
|
|
|
|
34 |
|
35 |
# Create the Gradio interface
|
36 |
with gr.Blocks() as iface:
|
37 |
model_choice = gr.Radio(choices=["Audio Deepfake Detection", "Image Deepfake Detection"], label="Select Model", value="Audio Deepfake Detection")
|
38 |
+
audio_input = gr.Audio(type="filepath", label="Upload Audio File")
|
39 |
+
image_input = gr.Image(type="filepath", label="Upload Image File", visible=False)
|
40 |
+
output = gr.Label()
|
41 |
+
|
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=[gr.State(audio_input), gr.State(image_input), model_choice], outputs=output)
|
46 |
|
47 |
iface.launch()
|
|