VidGuard / app.py
TruthLens's picture
Update app.py
93dd3e3 verified
raw
history blame
1.09 kB
import streamlit as st
from pytube import YouTube
from transformers import pipeline
import tempfile
import os
st.title("Deepfake Video Detection")
video_url = st.text_input("Enter YouTube Video URL:")
if st.button("Submit") and video_url:
with st.spinner("Downloading and analyzing video..."):
try:
yt = YouTube(video_url)
stream = yt.streams.filter(file_extension='mp4', progressive=True).first()
temp_dir = tempfile.mkdtemp()
video_path = os.path.join(temp_dir, "video.mp4")
stream.download(output_path=temp_dir, filename="video.mp4")
model = pipeline("image-classification", model="facebook/deit-base-distilled-patch16-224")
results = model(video_path)
st.success("Analysis Complete")
st.write("Prediction:", results[0]['label'])
st.write("Confidence:", f"{results[0]['score'] * 100:.2f}%")
os.remove(video_path)
os.rmdir(temp_dir)
except Exception as e:
st.error(f"Error: {e}")