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.
pip install -r requirements.txtThe selected detector may require additional dependencies from its official repository.
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 images1_fake: AI-generated images
Pass the prepared UniversalFakeDetect or GenImage directory to
--eval_data_root during evaluation.
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 modelThe detector must return one fake-class logit for each input patch. Center cropping and CLIP normalization are already performed by the evaluation script.
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.pthGenImage:
python evaluation_new.py \
--test_set GenImage \
--eval_data_root /path/to/GenImage \
--weights /path/to/detector_checkpoint.pthThe 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.