VidGuard / app.py
TruthLens's picture
Update app.py
01c9857 verified
raw
history blame
1.2 kB
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)