Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SAP-DSP

Review-period partial release for MLLMGenSet: A Benchmark Dataset for Detecting MLLM-Generated Images from GPT Image 2 and Nano Banana 2.

This folder contains the public subset of the project released during manuscript review. It includes only the dataset interface and the SAP-DSP model implementation. Training scripts, loss definitions, checkpoints, ablation code, and paper-specific analysis files are intentionally not included in this release folder.

Included Components

data/               Metadata-driven dataset class and image transforms
models/             SAP-DSP architecture and promptable ViT backbone
requirements.txt    Minimal dependencies for the public modules
README.md           Public release documentation
LICENSE             Code license

Dataset

The dataset is hosted on Hugging Face:

https://huggingface.co/datasets/zr-zhang/MLLM-Generated-Image-Detection-Dataset

The MLLM-Generated Image Detection Dataset contains real images and generated images from GPT-Image2 and Nano-Banana2. Images are organized around three artifact regimes:

  • hybrid: mixed texture and structure artifacts
  • structure: structure-dominant artifacts
  • texture: texture-dominant artifacts

A convenient download option is:

python -m pip install -U huggingface_hub
python -c "from huggingface_hub import snapshot_download; snapshot_download(repo_id='zr-zhang/MLLM-Generated-Image-Detection-Dataset', repo_type='dataset', local_dir='datasets/tsaigc')"

The data loader accepts a metadata CSV with image paths and labels. If optional metadata columns are missing, default values are filled automatically.

from data import TSAIGCDataset, build_transforms

transform = build_transforms("test", image_size=224, resize_size=256)
dataset = TSAIGCDataset(
    root="datasets/tsaigc",
    metadata="datasets/tsaigc/metadata.csv",
    split="train",
    transform=transform,
)

sample = dataset[0]
print(sample["image"].shape, sample["label"])

Expected core metadata fields:

Column Required Description
path or file_name yes Image path, either absolute or relative to root.
label recommended Binary label, where 0 denotes real and 1 denotes generated. Missing values default to 0.
split optional Split name such as train, val, or test. Missing values default to train.
domain optional Artifact regime, e.g. hybrid, structure, or texture.
generator optional Image source, e.g. real, gpt_image2, or nano_banana2.

Model

SAP-DSP combines explicit artifact priors with prompt-based visual representation learning.

  • Structural artifact prior. Edge, line, Laplacian, and local-variance cues are extracted from raw RGB images.
  • Texture and structure prompts. Separate prompt tokens encourage the ViT backbone to model complementary visual evidence.
  • Structure-aware fusion. A learned gate fuses texture and structure features using structural-prior statistics.

Minimal model construction:

import torch
from models import SAPDSP

cfg = {
    "model": {
        "backbone": "vit_base_patch16_224",
        "pretrained": False,
        "freeze_backbone": True,
        "use_transition_head": False,
    }
}

model = SAPDSP(cfg).eval()
images = torch.randn(2, 3, 224, 224)
outputs = model({"image": images, "image_raw": images})
print(outputs["logits"].shape)

Set pretrained=True to initialize the ViT backbone from timm when pretrained weights are available. External checkpoints and paper-specific trained weights are not part of this partial release.

Installation

The public modules are intended for Python 3.10+.

python -m venv .venv
source .venv/bin/activate
python -m pip install -U pip
python -m pip install -r requirements.txt

On Windows PowerShell:

.\.venv\Scripts\Activate.ps1
python -m pip install -U pip
python -m pip install -r requirements.txt

Citation

The manuscript is currently under review. A formal citation will be added after publication. During this partial public release, please cite the repository and the Hugging Face dataset page when referencing the released code or dataset.

License

This code is released under the MIT License. The dataset is distributed separately on Hugging Face; please refer to the dataset card for dataset-specific licensing and usage terms.

About

Review-period partial release for _MLLMGenSet: A Benchmark Dataset for Detecting MLLM-Generated Images from GPT Image 2 and Nano Banana 2_.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages