Yulu Fu commited on
Commit
51c1e80
1 Parent(s): f753e4b

Fix input handling and update interface for multiple models

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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(data, model_choice):
10
- print("Data received:", data) # Debugging statement
11
  try:
12
  if model_choice == "Audio Deepfake Detection":
13
- result = audio_model(data)
14
  elif model_choice == "Image Deepfake Detection":
15
- result = image_model(data)
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=[gr.State(audio_input), gr.State(image_input), model_choice], outputs=output)
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()