Update app.py
Browse files
app.py
CHANGED
|
@@ -371,7 +371,6 @@ if uploaded_image is not None:
|
|
| 371 |
# st.success(f"✅ This video appears to be REAL. (Confidence: {1 - result['score']:.2f})")
|
| 372 |
# else:
|
| 373 |
# st.warning("⚠️ Unable to analyze the video. Please try a different file.")
|
| 374 |
-
# ---- Deepfake Video Detection Section ----
|
| 375 |
st.subheader("🎥 Deepfake Video Detection")
|
| 376 |
|
| 377 |
# Upload video file
|
|
@@ -441,23 +440,36 @@ def download_youtube_video(youtube_url):
|
|
| 441 |
|
| 442 |
# Select Video Source
|
| 443 |
video_path = None
|
|
|
|
| 444 |
|
| 445 |
# Process Uploaded Video
|
| 446 |
if uploaded_video is not None:
|
| 447 |
-
st.video(uploaded_video) # Show uploaded video
|
| 448 |
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4")
|
| 449 |
with open(temp_file.name, "wb") as f:
|
| 450 |
f.write(uploaded_video.read())
|
| 451 |
video_path = temp_file.name # Set video path for detection
|
|
|
|
| 452 |
|
| 453 |
# Process Video from URL (Check if YouTube or Direct Link)
|
| 454 |
elif video_url:
|
| 455 |
if "youtube.com" in video_url or "youtu.be" in video_url:
|
| 456 |
-
st.video(video_url) # Show YouTube video
|
| 457 |
video_path = download_youtube_video(video_url) # Download YouTube video
|
|
|
|
| 458 |
else:
|
| 459 |
-
st.video(video_url) # Show direct MP4 video
|
| 460 |
video_path = download_video(video_url) # Download direct MP4 video
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 461 |
|
| 462 |
# ✅ "Analyze Video" بٹن ہمیشہ شو ہوگا
|
| 463 |
analyze_button = st.button("Analyze Video")
|
|
|
|
| 371 |
# st.success(f"✅ This video appears to be REAL. (Confidence: {1 - result['score']:.2f})")
|
| 372 |
# else:
|
| 373 |
# st.warning("⚠️ Unable to analyze the video. Please try a different file.")
|
|
|
|
| 374 |
st.subheader("🎥 Deepfake Video Detection")
|
| 375 |
|
| 376 |
# Upload video file
|
|
|
|
| 440 |
|
| 441 |
# Select Video Source
|
| 442 |
video_path = None
|
| 443 |
+
video_display_url = None
|
| 444 |
|
| 445 |
# Process Uploaded Video
|
| 446 |
if uploaded_video is not None:
|
|
|
|
| 447 |
temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4")
|
| 448 |
with open(temp_file.name, "wb") as f:
|
| 449 |
f.write(uploaded_video.read())
|
| 450 |
video_path = temp_file.name # Set video path for detection
|
| 451 |
+
video_display_url = temp_file.name
|
| 452 |
|
| 453 |
# Process Video from URL (Check if YouTube or Direct Link)
|
| 454 |
elif video_url:
|
| 455 |
if "youtube.com" in video_url or "youtu.be" in video_url:
|
|
|
|
| 456 |
video_path = download_youtube_video(video_url) # Download YouTube video
|
| 457 |
+
video_display_url = video_url
|
| 458 |
else:
|
|
|
|
| 459 |
video_path = download_video(video_url) # Download direct MP4 video
|
| 460 |
+
video_display_url = video_url
|
| 461 |
+
|
| 462 |
+
# ✅ Small Video Display using HTML + CSS
|
| 463 |
+
if video_display_url:
|
| 464 |
+
st.markdown(
|
| 465 |
+
f"""
|
| 466 |
+
<video controls width="300">
|
| 467 |
+
<source src="{video_display_url}" type="video/mp4">
|
| 468 |
+
Your browser does not support the video tag.
|
| 469 |
+
</video>
|
| 470 |
+
""",
|
| 471 |
+
unsafe_allow_html=True,
|
| 472 |
+
)
|
| 473 |
|
| 474 |
# ✅ "Analyze Video" بٹن ہمیشہ شو ہوگا
|
| 475 |
analyze_button = st.button("Analyze Video")
|