ForeAgent — Qwen3-VL-8B for Agentic Image Forensics
ForeAgent (Forensics Agent) is a fine-tuned Qwen3-VL-8B model for AI-generated image detection. It determines whether an image is real (authentic) or fake (AI-generated) through multi-view forensic analysis spanning semantic, frequency-domain, and spatial-domain features.
Paper: Perception, Verdict, and Evolution: Hindsight-Driven Self-Refining Forensics Agent for AI-Generated Image Detection
Highlights
82.18% accuracy on Chameleon benchmark, outperforming AIDE by 16.41%
Competitive results on AIGCDetectBenchmark
Reasoning quality comparable to GPT-5 (per qualitative evaluations)
Dual-input analysis: original image + frequency-domain representation (wavelet cD)
Produces structured JSON output with conclusion, confidence, and reasoning
ForeAgent aggregates multi-view cues for forensic analysis:
Semantic features — the original image, analyzed for texture anomalies, anatomical integrity, physical consistency, and artifact detection
Frequency-domain features — diagonal detail coefficients (cD) from wavelet transform, revealing spectral patterns characteristic of AI-generated images
Spatial-domain features — noise pattern residuals (NPR) from a spatial expert model, detecting GAN-specific artifacts
An MLLM-based Critic fuses these multi-view signals to produce a logically grounded verdict.
Hindsight-Driven Self-Refining (EFA Pipeline)
The model is trained through an iterative Sampling → Reflection → Evolution loop:
Iteration N:
1. Agent Inference — Two-round reasoning (Perception + Critic) on data split N
2. Sample Classification — Separate correct vs incorrect predictions
3. Quality Assessment — Dual-model gating (Qwen3-VL-8B + Qwen3-VL-Plus)
4. Reflection — Guided by ground-truth, regenerate high-quality reasoning
5. Training Data — Merge reflections + knowledge retention, label-balanced
6. LoRA Fine-tuning — Update model weights
7. Evaluation — Test on held-out benchmarks
→ Next iteration uses the improved model
Usage
Quick Start (Single Image)
python
1from transformers import Qwen2VLForConditionalGeneration, AutoProcessor
2from qwen_vl_utils import process_vision_info
34model = Qwen2VLForConditionalGeneration.from_pretrained(5"Shimin/qwen3_vl_8b_foreagent",6 torch_dtype="auto",7 device_map="auto",8)9processor = AutoProcessor.from_pretrained("Shimin/qwen3_vl_8b_foreagent")1011messages =[12{13"role":"user",14"content":[15{"type":"image","image":"path/to/image.jpg"},16{"type":"text","text":(17"You are an expert forensic analyst specializing in distinguishing "18"natural images from AI-generated images. Analyze the given image "19"systematically.\n\n"20"## Output JSON Format:\n"21'```json\n{\n "conclusion": "real or fake",\n'22' "confidence": 0.0-1.0,\n'23' "reasoning": "Brief reasoning (max 64 words)."\n}\n```\n\n'24"Please analyze this image and determine if it is real or AI-generated."25)},26],27}28]2930text = processor.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)31image_inputs, video_inputs = process_vision_info(messages)32inputs = processor(33 text=[text],34 images=image_inputs,35 videos=video_inputs,36 padding=True,37 return_tensors="pt",38).to(model.device)3940generated_ids = model.generate(**inputs, max_new_tokens=256)41output_text = processor.batch_decode(42 generated_ids[:, inputs.input_ids.shape[1]:],43 skip_special_tokens=True,44)[0]45print(output_text)
Dual-Image Mode (Original + Wavelet Frequency Domain)
For best performance, provide both the original image and its wavelet-transformed frequency-domain representation (diagonal detail coefficients cD):
python
1import numpy as np
2import pywt
3from PIL import Image
45defextract_wavelet_cd(image_path, output_size=256):6"""Extract diagonal detail coefficients (cD) via wavelet transform."""7 img = Image.open(image_path).convert("L")8 img_array = np.array(img, dtype=np.float64)9 coeffs = pywt.dwt2(img_array,"db1")10 _,(_, _, cD)= coeffs
11 cD_normalized = np.clip((cD - cD.min())/(cD.max()- cD.min()+1e-8)*255,0,255)12 cD_image = Image.fromarray(cD_normalized.astype(np.uint8))13return cD_image.resize((output_size, output_size), Image.BILINEAR)1415wavelet_image = extract_wavelet_cd("path/to/image.jpg")16wavelet_image.save("path/to/wavelet.png")1718messages =[19{20"role":"user",21"content":[22{"type":"image","image":"path/to/image.jpg"},23{"type":"image","image":"path/to/wavelet.png"},24{"type":"text","text":(25"You are an expert forensic analyst specializing in distinguishing "26"natural images from AI-generated images. You are given two images: "27"the original image and its frequency domain representation "28"(diagonal detail coefficients cD from wavelet transform). "29"Analyze them systematically.\n\n"30"## Output JSON Format:\n"31'```json\n{\n "conclusion": "real or fake",\n'32' "confidence": 0.0-1.0,\n'33' "reasoning": "Brief reasoning (max 64 words)."\n}\n```\n\n'34"Based on the original image and its frequency domain representation, "35"judge whether this image is real or fake."36)},37],38}39]4041# ... same inference code as above
Frequency Domain — wavelet coefficient distributions, spectral anomalies
Semantic Coherence — object relationships, scene composition logic
Training Data
The model is trained on a mixture of:
GenImage — diverse AI-generated images from multiple generators
ProGAN — GAN-generated face images
Iteratively refined through the EFA pipeline with dual-model quality gating
Training data undergoes label balancing (undersampling) and includes:
Reflection samples — full reasoning traces for error correction
Knowledge retention samples — conclusion-only samples to preserve existing capabilities
Intended Use
AI-generated image detection and forensic analysis
Deepfake detection in content moderation pipelines
Research on multimodal reasoning for image authenticity verification
Integration into agentic forensic workflows
Limitations
Performance varies across different AI generation methods; GAN-generated faces may be harder to detect than diffusion-based generations depending on the specific generator
Frequency-domain analysis (dual-image mode) improves accuracy but requires wavelet preprocessing
The model outputs natural language reasoning which may occasionally be inconsistent with the final conclusion
Detection accuracy may degrade on heavily compressed or low-resolution images
Technical Requirements
GPU Memory: ~32 GB (float16) for inference
Dependencies: transformers, qwen-vl-utils, pywt (PyWavelets) for wavelet preprocessing
Serving: Compatible with SGLang, vLLM, and standard Transformers inference
Citation
bibtex
1@article{foreagent2025,
2 title={Perception, Verdict, and Evolution: Hindsight-Driven Self-Refining Forensics Agent for AI-Generated Image Detection},
3 author={Yangjun Wu, Keyu Yan, Yu Liu, Jingren Zhou, Fei Huang, Rong Zhang, Zhou Zhao, and Fei Wu},
4 year={2026}
5}