Views
No views yet
2026.4 Our paper has been accepted by ICMR 2026.2026.2 We release our models 🚀Ivy-xDetector for AI-generated image and video detection🔥🔥🔥!2025.12 The Ivy-Fake Dataset is released.2025.5 We release the Arxivtransformers library.1import torch
2from transformers import Qwen2_5_VLForConditionalGeneration, AutoProcessor
3from qwen_vl_utils import process_vision_info
4
5# Initialize Model and Processor
6model_id = "AI-Safeguard/Ivy-Fake"
7model = Qwen2_5_VLForConditionalGeneration.from_pretrained(
8 model_id,
9 torch_dtype=torch.bfloat16,
10 attn_implementation="flash_attention_2",
11 device_map="auto",
12)
13processor = AutoProcessor.from_pretrained(model_id)
14
15# Define the Detection Prompt
16messages = [
17 {
18 "role": "system",
19 "content": "You are an AI-generated content detector. Classify the media as real or fake. Provide reasoning inside <think>...</think> tags. End with exactly one word—real or fake—wrapped in <conclusion>...</conclusion>."
20 },
21 {
22 "role": "user",
23 "content": [
24 {
25 "type": "image",
26 "image": "https://path-to-your-image.jpg", # Replace with your media path
27 },
28 {"type": "text", "text": "Is this image real or fake?"},
29 ],
30 }
31]
32
33# Preparation for Inference
34text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
35image_inputs, video_inputs = process_vision_info(messages)
36inputs = processor(
37 text=[text],
38 images=image_inputs,
39 videos=video_inputs,
40 padding=True,
41 return_tensors="pt",
42).to("cuda")
43
44# Generation
45generated_ids = model.generate(**inputs, max_new_tokens=2048, do_sample=False)
46generated_ids_trimmed = [
47 out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)
48]
49output_text = processor.batch_decode(
50 generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False
51)
52
53print(output_text[0])1@article{jiang2025ivy,
2 title={Ivy-fake: A unified explainable framework and benchmark for image and video aigc detection},
3 author={Jiang, Changjiang and Dong, Wenhui and Zhang, Zhonghao and Si, Chenyang and Yu, Fengchang and Peng, Wei and Yuan, Xinbin and Bi, Yifei and Zhao, Ming and Zhou, Zian and others},
4 journal={arXiv preprint arXiv:2506.00979},
5 year={2025}
6}