File size: 1,086 Bytes
dc4f473
 
93dd3e3
dc4f473
93dd3e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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}")