File size: 1,204 Bytes
01c9857
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from transformers import pipeline
from PIL import Image
import requests
from io import BytesIO

# Title and description
st.title("Deepfake Image & Video Detector")
st.write("Upload an image or enter a video link to check for AI manipulations.")

# Image Detection Function
def detect_image(image_file):
    model = pipeline("image-classification", model="microsoft/resnet-50")
    image = Image.open(image_file)
    results = model(image)
    return results

# Video Detection Function (Placeholder)
def detect_video(video_link):
    st.write("Video detection coming soon.")

# Image Upload Section
uploaded_image = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"])
if uploaded_image:
    st.image(uploaded_image, caption="Uploaded Image", use_container_width=True)
    with st.spinner("Analyzing image..."):
        image_results = detect_image(uploaded_image)
    st.write("### Detection Results:")
    for result in image_results:
        st.write(f"{result['label']}: {result['score']*100:.2f}%")

# Video Link Section
video_link = st.text_input("Enter a video link")
if video_link:
    st.write(f"Analyzing video at: {video_link}")
    detect_video(video_link)