AI-RESEARCHER-2024 commited on
Commit
42b5b0a
·
verified ·
1 Parent(s): 713c885

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -15
app.py CHANGED
@@ -63,6 +63,7 @@ def process_video(video_path, true_label=None):
63
  qcnn_class1 = 0
64
  total_frames = len(sampled_frames)
65
  for frame in sampled_frames:
 
66
  cnn_pred = cnn_model.predict(frame)
67
  cnn_label = np.argmax(cnn_pred)
68
  if cnn_label == 0:
@@ -125,21 +126,44 @@ def predict(video_input):
125
  return result
126
 
127
  with gr.Blocks() as demo:
128
- gr.Markdown("<h1 style='text-align: center;'>Quanvolutional Neural Networks for Deepfake Detection</h1>")
129
- gr.Markdown("<h2 style='text-align: center;'>Steven Fernandes, Ph.D.</h2>")
130
-
131
- with gr.Row():
132
- with gr.Column():
133
- video_input = gr.Video(label="Upload Video or Select an Example")
134
  gr.Examples(
135
- examples=[example['path'] for example in examples],
136
- inputs=video_input,
137
- label="Examples"
138
  )
139
- predict_button = gr.Button("Predict")
140
- with gr.Column():
141
- output = gr.Textbox(label="Result")
142
-
143
- predict_button.click(fn=predict, inputs=video_input, outputs=output)
144
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  demo.launch()
 
63
  qcnn_class1 = 0
64
  total_frames = len(sampled_frames)
65
  for frame in sampled_frames:
66
+ frame = frame.reshape(1, -1) # Flatten the frame
67
  cnn_pred = cnn_model.predict(frame)
68
  cnn_label = np.argmax(cnn_pred)
69
  if cnn_label == 0:
 
126
  return result
127
 
128
  with gr.Blocks() as demo:
129
+ gr.HTML("<h1 style='text-align: center;'>Quanvolutional Neural Networks for Deepfake Detection</h1>")
130
+ gr.HTML("<h2 style='text-align: center;'>Steven Fernandes, Ph.D.</h2>")
131
+
132
+ with gr.Tabs():
133
+ with gr.TabItem("Original Videos"):
134
+ original_input = gr.Video(label="Upload Original Video or Select an Example")
135
  gr.Examples(
136
+ examples=[example['path'] for example in original_videos],
137
+ inputs=original_input,
138
+ label="Original Examples"
139
  )
140
+ with gr.TabItem("Deepfake Roop Videos"):
141
+ deepfake_roop_input = gr.Video(label="Upload Deepfake Roop Video or Select an Example")
142
+ gr.Examples(
143
+ examples=[example['path'] for example in deepfake_roop_videos],
144
+ inputs=deepfake_roop_input,
145
+ label="Deepfake Roop Examples"
146
+ )
147
+ with gr.TabItem("Deepfake Web Videos"):
148
+ deepfake_web_input = gr.Video(label="Upload Deepfake Web Video or Select an Example")
149
+ gr.Examples(
150
+ examples=[example['path'] for example in deepfake_web_videos],
151
+ inputs=deepfake_web_input,
152
+ label="Deepfake Web Examples"
153
+ )
154
+
155
+ predict_button = gr.Button("Predict")
156
+ output = gr.Textbox(label="Result")
157
+
158
+ # Function to handle input from any tab
159
+ def predict_combined(original_video, deepfake_roop_video, deepfake_web_video):
160
+ video_input = original_video or deepfake_roop_video or deepfake_web_video
161
+ return predict(video_input)
162
+
163
+ predict_button.click(
164
+ fn=predict_combined,
165
+ inputs=[original_input, deepfake_roop_input, deepfake_web_input],
166
+ outputs=output
167
+ )
168
+
169
  demo.launch()