Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,12 +1,7 @@
|
|
| 1 |
import os, io, tempfile, warnings
|
| 2 |
import numpy as np
|
| 3 |
import gradio as gr
|
| 4 |
-
import os
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
os.environ["OMP_NUM_THREADS"] = "4"
|
| 9 |
-
os.environ["MKL_NUM_THREADS"] = "4"
|
| 10 |
# =========================
|
| 11 |
# TensorFlow / Keras
|
| 12 |
# =========================
|
|
@@ -206,15 +201,15 @@ def to_verdict(score):
|
|
| 206 |
def run_inference(video_file):
|
| 207 |
lazy_load()
|
| 208 |
if video_file is None:
|
| 209 |
-
return
|
| 210 |
|
| 211 |
video_prob, vmsg = predict_video_prob(video_file)
|
| 212 |
if video_prob is None:
|
| 213 |
-
return
|
| 214 |
|
| 215 |
verdict = f"VIDEO ONLY: {to_verdict(video_prob)}"
|
| 216 |
-
|
| 217 |
-
|
| 218 |
|
| 219 |
# =========================
|
| 220 |
# Gradio UI
|
|
@@ -238,13 +233,5 @@ with gr.Blocks(title="Deepfake Detector — Video Only (GPU-ready)") as demo:
|
|
| 238 |
go.click(run_inference, inputs=[video_in], outputs=[v_out, verdict_out, msg_out])
|
| 239 |
|
| 240 |
if __name__ == "__main__":
|
| 241 |
-
|
| 242 |
-
os.environ["OMP_NUM_THREADS"] = "4"
|
| 243 |
-
os.environ["MKL_NUM_THREADS"] = "4"
|
| 244 |
-
|
| 245 |
-
print("[INFO] Video model loaded.")
|
| 246 |
-
print("[INFO] MTCNN ready on cuda.")
|
| 247 |
-
print("[INFO] dlib detector + predictor ready.")
|
| 248 |
-
|
| 249 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
| 250 |
-
|
|
|
|
| 1 |
import os, io, tempfile, warnings
|
| 2 |
import numpy as np
|
| 3 |
import gradio as gr
|
|
|
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# =========================
|
| 6 |
# TensorFlow / Keras
|
| 7 |
# =========================
|
|
|
|
| 201 |
def run_inference(video_file):
|
| 202 |
lazy_load()
|
| 203 |
if video_file is None:
|
| 204 |
+
return None, None, "Please upload a video file."
|
| 205 |
|
| 206 |
video_prob, vmsg = predict_video_prob(video_file)
|
| 207 |
if video_prob is None:
|
| 208 |
+
return None, None, vmsg or "Unable to process the video."
|
| 209 |
|
| 210 |
verdict = f"VIDEO ONLY: {to_verdict(video_prob)}"
|
| 211 |
+
fmt = lambda x: None if x is None else round(float(x), 4)
|
| 212 |
+
return fmt(video_prob), verdict, None
|
| 213 |
|
| 214 |
# =========================
|
| 215 |
# Gradio UI
|
|
|
|
| 233 |
go.click(run_inference, inputs=[video_in], outputs=[v_out, verdict_out, msg_out])
|
| 234 |
|
| 235 |
if __name__ == "__main__":
|
| 236 |
+
lazy_load()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|