|
|
|
|
|
import streamlit as st
|
|
import requests
|
|
from PIL import Image
|
|
from io import BytesIO
|
|
from transformers import pipeline
|
|
|
|
def extract_thumbnail_url(youtube_url):
|
|
"""Extracts the thumbnail URL from a YouTube video link."""
|
|
video_id = youtube_url.split("v=")[-1].split("&")[0]
|
|
return f"https://img.youtube.com/vi/{video_id}/maxresdefault.jpg"
|
|
|
|
def load_image(url):
|
|
"""Loads an image from a URL."""
|
|
response = requests.get(url)
|
|
if response.status_code == 200:
|
|
return Image.open(BytesIO(response.content))
|
|
return None
|
|
|
|
def main():
|
|
st.title("π YouTube Fake Video Detector")
|
|
st.write("Enter a YouTube video link to detect if its thumbnail is AI-generated or manipulated.")
|
|
|
|
youtube_url = st.text_input("YouTube Video Link")
|
|
|
|
if youtube_url:
|
|
thumbnail_url = extract_thumbnail_url(youtube_url)
|
|
st.subheader("Thumbnail Preview:")
|
|
image = load_image(thumbnail_url)
|
|
|
|
if image:
|
|
st.image(image, caption="Video Thumbnail", use_column_width=True)
|
|
|
|
with st.spinner("Analyzing thumbnail..."):
|
|
|
|
model = pipeline("image-classification", model="nateraw/resnet50-oxford-flowers")
|
|
results = model(thumbnail_url)
|
|
|
|
st.subheader("Detection Results:")
|
|
for result in results:
|
|
st.write(f"**{result['label']}**: {result['score']*100:.2f}% confidence")
|
|
else:
|
|
st.error("Failed to load thumbnail. Please check the YouTube link.")
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|