File size: 1,425 Bytes
b1f6a8b
dc4f473
93dd3e3
b1f6a8b
 
 
93dd3e3
1dbeab5
b1f6a8b
1dbeab5
b1f6a8b
 
 
 
 
 
 
 
 
 
1dbeab5
b1f6a8b
1dbeab5
b1f6a8b
1dbeab5
b1f6a8b
 
1dbeab5
 
b1f6a8b
 
 
 
 
 
1dbeab5
b1f6a8b
 
 
 
 
 
93dd3e3
b1f6a8b
 
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from pytube import YouTube
import streamlit as st
from transformers import pipeline
from PIL import Image
import requests
from io import BytesIO

st.set_page_config(page_title="Video Deepfake Detector", layout="centered")
st.title("🎥 Video Deepfake Detector")

@st.cache_data
def get_thumbnail(url):
    try:
        yt = YouTube(url)
        response = requests.get(yt.thumbnail_url)
        if response.status_code == 200:
            return Image.open(BytesIO(response.content))
    except Exception as e:
        st.error(f"Error fetching thumbnail: {e}")
    return None

@st.cache_resource
def load_model():
    return pipeline("image-classification", model="facebook/deit-base-distilled-patch16-224")

def detect_deepfake(image, model):
    results = model(image)
    return results

def main():
    video_url = st.text_input("Enter YouTube Video URL:")
    if st.button("Analyze") and video_url:
        thumbnail = get_thumbnail(video_url)
        if thumbnail:
            st.image(thumbnail, caption="Video Thumbnail", use_container_width=True)
            model = load_model()
            results = detect_deepfake(thumbnail, model)
            st.subheader("Detection Results:")
            for res in results:
                st.write(f"{res['label']}: {res['score']:.4f}")
        else:
            st.warning("Unable to fetch thumbnail. Please check the video URL.")

if __name__ == "__main__":
    main()