|
import streamlit as st |
|
from transformers import pipeline |
|
from PIL import Image |
|
import requests |
|
from io import BytesIO |
|
|
|
|
|
st.title("Deepfake Image & Video Detector") |
|
st.write("Upload an image or enter a video link to check for AI manipulations.") |
|
|
|
|
|
def detect_image(image_file): |
|
model = pipeline("image-classification", model="microsoft/resnet-50") |
|
image = Image.open(image_file) |
|
results = model(image) |
|
return results |
|
|
|
|
|
def detect_video(video_link): |
|
st.write("Video detection coming soon.") |
|
|
|
|
|
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 = st.text_input("Enter a video link") |
|
if video_link: |
|
st.write(f"Analyzing video at: {video_link}") |
|
detect_video(video_link) |
|
|