Update app.py
Browse files
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.
|
129 |
-
gr.
|
130 |
-
|
131 |
-
with gr.
|
132 |
-
with gr.
|
133 |
-
|
134 |
gr.Examples(
|
135 |
-
examples=[example['path'] for example in
|
136 |
-
inputs=
|
137 |
-
label="Examples"
|
138 |
)
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
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()
|