File size: 1,746 Bytes
01c9857 dc4f473 01c9857 dc4f473 01c9857 dc4f473 01c9857 dc4f473 01c9857 dc4f473 01c9857 dc4f473 01c9857 dc4f473 |
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 47 |
from transformers import pipeline
import streamlit as st
import torch
import requests
from PIL import Image
from pytube import YouTube
import tempfile
def detect_image(image):
model = pipeline("image-classification", model="google/vit-base-patch16-224")
return model(image)
def detect_video(video_url):
yt = YouTube(video_url)
stream = yt.streams.filter(file_extension='mp4').first()
with tempfile.NamedTemporaryFile(delete=False, suffix='.mp4') as tmp_file:
stream.download(filename=tmp_file.name)
video_path = tmp_file.name
return video_path
def main():
st.title("VerifiAI - Image & Video Authenticity Checker")
option = st.sidebar.selectbox("Select Option", ["Image Detection", "Video Detection"])
if option == "Image Detection":
uploaded_image = st.file_uploader("Upload an Image", type=["jpg", "jpeg", "png"])
if uploaded_image:
image = Image.open(uploaded_image)
st.image(image, caption="Uploaded Image", use_container_width=True)
with st.spinner("Analyzing Image..."):
results = detect_image(image)
for result in results:
st.write(f"{result['label']}: {result['score']*100:.2f}%")
elif option == "Video Detection":
video_url = st.text_input("Enter YouTube Video Link")
if video_url:
st.video(video_url)
with st.spinner("Analyzing Video..."):
video_path = detect_video(video_url)
st.success("Video downloaded for analysis. Video detection model coming soon.")
if __name__ == "__main__":
if not torch.cuda.is_available():
st.warning("CUDA not available. Running on CPU might be slower.")
main()
|