8000 GitHub - Yingjian-Chen/TARS: Official Implementation of paper "One Patch Is Not Enough: A General Framework for Full-Resolution AI Image Detection" · GitHub
[go: up one dir, main page]

Skip to content
Yingjian-ChenPublic

About

Official Implementation of paper "One Patch Is Not Enough: A General Framework for Full-Resolution AI Image Detection"

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

One Patch Is Not Enough: A General Framework for Full-Resolution AI Image Detection

This repository provides the evaluation code for TARS (Texture-Aware Region Selection), a training-free framework that applies existing AI-generated image detectors to multiple texture-rich patches from a full-resolution image.

TARS pipeline

Environment Setup

pip install -r requirements.txt

The selected detector may require additional dependencies from its official repository.

Dataset

We evaluate TARS on UniversalFakeDetect and GenImage. Please follow the dataset download and preparation instructions provided by ForgeLens.

TARS uses the same dataset organization and binary labels:

  • 0_real: real images
  • 1_fake: AI-generated images

Pass the prepared UniversalFakeDetect or GenImage directory to --eval_data_root during evaluation.

Detector Setup

TARS can be used with an existing detector. Download its official code and checkpoint, then implement load_model(opt) in evaluation_new.py:

def load_model(opt):
    model = build_your_detector()
    checkpoint = torch.load(opt.weights, map_location="cpu")
    model.load_state_dict(checkpoint)
    return model

The detector must return one fake-class logit for each input patch. Center cropping and CLIP normalization are already performed by the evaluation script.

Evaluation

TARS is training-free and does not require an additional training stage.

UniversalFakeDetect:

python evaluation_new.py \
  --test_set UniversalFakeDetect \
  --eval_data_root /path/to/UniversalFakeDetect \
  --weights /path/to/detector_checkpoint.pth

GenImage:

python evaluation_new.py \
  --test_set GenImage \
  --eval_data_root /path/to/GenImage \
  --weights /path/to/detector_checkpoint.pth

The default TARS settings are patch_size=224, stride=224, max_patches=1000, and top_k=7. They can be changed through the corresponding command-line arguments.

About

Official Implementation of paper "One Patch Is Not Enough: A General Framework for Full-Resolution AI Image Detection"

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0