asad231 commited on
Commit
8eb6c20
ยท
verified ยท
1 Parent(s): c51b4df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -11
app.py CHANGED
@@ -369,6 +369,9 @@ if uploaded_image is not None:
369
  # ---- Deepfake Video Detection Section ----
370
  st.subheader("๐ŸŽฅ Deepfake Video Detection")
371
 
 
 
 
372
  # URL Input for Video
373
  video_url = st.text_input("Enter Video URL")
374
 
@@ -403,18 +406,32 @@ def detect_deepfake_video(video_path):
403
 
404
  return {"label": final_label, "score": confidence}
405
 
406
- if video_url:
 
 
 
 
 
 
 
 
 
407
  st.video(video_url) # Show the video directly from URL
 
 
 
 
 
 
 
 
 
408
 
409
- if st.button("Analyze Video"):
410
- st.write("๐Ÿ” Processing... Please wait.")
411
- result = detect_deepfake_video(video_url) # Pass the URL directly
412
-
413
- if result["label"] == "FAKE":
414
- st.error(f"โš ๏ธ Deepfake Detected! This video appears to be FAKE. (Confidence: {result['score']:.2f})")
415
- elif result["label"] == "REAL":
416
- st.success(f"โœ… This video appears to be REAL. (Confidence: {1 - result['score']:.2f})")
417
- else:
418
- st.warning("โš ๏ธ Unable to analyze the video. Please try a different file.")
419
 
420
  st.markdown("๐Ÿ”น **Developed for Fake News & Deepfake Detection Hackathon**")
 
369
  # ---- Deepfake Video Detection Section ----
370
  st.subheader("๐ŸŽฅ Deepfake Video Detection")
371
 
372
+ # Upload video file
373
+ uploaded_video = st.file_uploader("Upload a Video", type=["mp4", "avi", "mov"])
374
+
375
  # URL Input for Video
376
  video_url = st.text_input("Enter Video URL")
377
 
 
406
 
407
  return {"label": final_label, "score": confidence}
408
 
409
+ # Process Uploaded Video
410
+ if uploaded_video is not None:
411
+ st.video(uploaded_video) # Show uploaded video
412
+ temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4")
413
+ with open(temp_file.name, "wb") as f:
414
+ f.write(uploaded_video.read())
415
+ video_path = temp_file.name # Set video path for detection
416
+
417
+ # Process Video from URL
418
+ elif video_url:
419
  st.video(video_url) # Show the video directly from URL
420
+ video_path = video_url # Use URL for detection
421
+
422
+ else:
423
+ video_path = None
424
+
425
+ # Analyze Button
426
+ if video_path and st.button("Analyze Video"):
427
+ st.write("๐Ÿ” Processing... Please wait.")
428
+ result = detect_deepfake_video(video_path)
429
 
430
+ if result["label"] == "FAKE":
431
+ st.error(f"โš ๏ธ Deepfake Detected! This video appears to be FAKE. (Confidence: {result['score']:.2f})")
432
+ elif result["label"] == "REAL":
433
+ st.success(f"โœ… This video appears to be REAL. (Confidence: {1 - result['score']:.2f})")
434
+ else:
435
+ st.warning("โš ๏ธ Unable to analyze the video. Please try a different file.")
 
 
 
 
436
 
437
  st.markdown("๐Ÿ”น **Developed for Fake News & Deepfake Detection Hackathon**")