File size: 1,571 Bytes
7af2795 70e05ba 7af2795 70e05ba 80f0c7d 70e05ba 7af2795 ab41980 80f0c7d 7af2795 4362c52 7af2795 4362c52 |
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
import os
import gradio as gr
import warnings
from huggingface_hub import Repository, login
warnings.filterwarnings("ignore")
login(token=os.environ['HF_TOKEN'])
repo = Repository(
local_dir="dataset",
repo_type="dataset",
clone_from=os.environ['DATASET'],
token=True
)
repo.git_pull()
# Import the AI detector
from dataset.model import AIContentDetector
# Initialize the detector
detector = AIContentDetector()
def analyze_image(image):
"""Wrapper function for image analysis."""
if image is None:
return "Please upload an image", 0
result, confidence = detector.detect_ai_image(image)
return result, confidence
def analyze_video(video):
"""Wrapper function for video analysis."""
if video is None:
return "Please upload a video", 0
result, confidence = detector.detect_ai_video(video)
return result, confidence
def analyze_audio(audio):
"""Wrapper function for audio analysis."""
if audio is None:
return "Please upload an audio file", 0
result, confidence = detector.detect_ai_audio(audio)
return result, confidence
# Create the Gradio interface
demo = gr.Interface(
fn=analyze_image,
inputs=gr.Image(type="pil", label="Upload Image"),
outputs=[
gr.Textbox(label="Detection Result"),
gr.Number(label="Confidence Score (%)")
],
title="🕵️ GuanFu - AI Content Detector",
description="Upload an image to detect if it was generated by AI.",
theme=gr.themes.Soft()
)
if __name__ == "__main__":
demo.launch()
|