Datasets:

ArXiv:
License:
DreamMr commited on
Commit
8de7749
·
verified ·
1 Parent(s): afab1dc

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +176 -0
README.md CHANGED
@@ -1,3 +1,179 @@
1
  ---
2
  license: apache-2.0
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
  ---
4
+
5
+ <div align="center">
6
+
7
+ # *TranX-Adapter*:<br> Bridging Artifacts and Semantics within MLLMs for Robust AI-generated Image Detection
8
+
9
+ <a href="https://arxiv.org/abs/2602.21716" target="_blank">
10
+ <img alt="arXiv" src="https://img.shields.io/badge/arXiv-2602.21716-red?logo=arxiv" height="25" />
11
+ </a>
12
+ <a href="https://huggingface.co/collections/DreamMr/tranxadapter" target="_blank">
13
+ <img alt="HF Models: TranX-Adapter" src="https://img.shields.io/badge/%F0%9F%A4%97%20_Models-TranX--Adapter-ffc107?color=ffc107&logoColor=white" height="25" />
14
+ </a>
15
+ <a href="https://huggingface.co/datasets/DreamMr/TranXAdapter-Dataset" target="_blank">
16
+ <img alt="HF Data: TranXAdapter-Data" src="https://img.shields.io/badge/%F0%9F%A4%97%20_Data-TranX--Adapter Data-3cb371?color=3cb371&logoColor=white" height="25" />
17
+ </a>
18
+
19
+ <div style="font-family: charter;">
20
+ Wenbin Wang<sup>1</sup>,
21
+ Yuge Huang<sup>2</sup>,
22
+ Jianqing Xu<sup>2</sup>,
23
+ Yue Yu<sup>2</sup>,
24
+ Jiangtao Yan<sup>2</sup>,
25
+ <br>
26
+ Shouhong Ding<sup>2</sup>,
27
+ Pan Zhou<sup>3</sup>,
28
+ Yong Luo<sup>1</sup>
29
+ </div>
30
+
31
+ <div style="font-family: charter;">
32
+ <sup>1</sup>Wuhan University&nbsp;&nbsp;
33
+ <sup>2</sup>Tencent YouTu Lab&nbsp;&nbsp;
34
+ <sup>3</sup>Singapore Management University
35
+ </div>
36
+
37
+
38
+ </div>
39
+
40
+ ## News
41
+
42
+ [2026.06.03] TranX-Adapter code is available! Additionally, we have also open-sourced the [trained models](https://huggingface.co/collections/DreamMr/tranxadapter) along with the corresponding [training and evaluation data](https://huggingface.co/datasets/DreamMr/TranXAdapter-Dataset).
43
+
44
+ [2026.05.01] Our paper was accepted to ICML 2026! 🎉
45
+
46
+ [2026.02.25] We released the ArXiv paper. 🚀
47
+
48
+ ## TL;DR
49
+
50
+ While prior work improves AIGI detection by combining artifact and semantic features in MLLMs, we find that artifact features often suffer from high intra-feature similarity, causing uniform attention and ineffective fusion. To address this attention dilution problem, we propose **TranX-Adapter**, a lightweight fusion module that combines task-aware optimal-transport fusion and cross-attention-based X-Fusion to enable bidirectional interaction between artifact and semantic features.
51
+
52
+
53
+ ## 🔧 Installation
54
+
55
+ 1. Clone this repository and navigate into the codebase
56
+ ```bash
57
+ git clone https://github.com/DreamMr/TranX-Adapter.git
58
+ cd TranX-Adapter
59
+ ```
60
+
61
+ 2. Install Packages
62
+ ```bash
63
+ bash install.sh
64
+ ```
65
+
66
+ When the environment is created successfully, you will see:
67
+
68
+ `Conda environment name tranxadapter has been created🎉. Now you can run "conda activate tranxadapter"`
69
+
70
+ ## 📦 Preparation
71
+
72
+ 1. Download the datasets
73
+
74
+ - Training Data: [GenImage](https://genimage-dataset.github.io/), [RRDataset](https://arxiv.org/abs/2509.09172), [BFree](https://github.com/grip-unina/B-Free/tree/main/training_data) (SD2.1_selfconditioned_origBG.zip (ai) and COCO_real_512.zip (real)).
75
+
76
+ - Evaluation Data: [GenImage](https://genimage-dataset.github.io/), [Chameleon](https://github.com/shilinyan99/AIDE/issues/7), [RRDataset](https://arxiv.org/abs/2509.09172)
77
+
78
+ - [Our constructed VQA dataset](https://huggingface.co/datasets/DreamMr/TranXAdapter-Dataset/tree/main)
79
+
80
+ Download the above data to `./Dataset`, with the structure as follows:
81
+
82
+ ```text
83
+ Dataset/
84
+ ├── TranXAdapter-Dataset/
85
+ │ ├── training/
86
+ │ │ └── GenImage_Sdv1d4.jsonl
87
+ │ │ └── GenImageAll.jsonl
88
+ │ │ └── RRDataset.jsonl
89
+ │ │ └── BFP.jsonl
90
+ │ ├── evaluation/
91
+ │ │ └── Chamelon.tsv
92
+ │ │ └── GenImage.tsv
93
+ │ │ └── RR.tsv
94
+ ├── GenImage/
95
+ │ ├── ADM
96
+ │ ├── test
97
+ │ ├── ...
98
+ ├── Chameleon/test/
99
+ │ ├── 0_real
100
+ │ ├── 1_fake
101
+ ├── RRDataset_final/
102
+ │ ├── original
103
+ │ ├── redigital
104
+ │ ├── ...
105
+ ├── RRDataset_original_train_val
106
+ │ ├── train
107
+ │ ├── val
108
+ ├── BFP
109
+ │ ├── ai
110
+ │ ├── real
111
+ ```
112
+
113
+ 2. Process Data
114
+
115
+ Run `python preprocess_data.py` to replace the image paths in JSONL/CSV files with absolute paths.
116
+
117
+ **Note: You need to copy the MD5 values corresponding to the CSV files into DATASET_MD5 in ./VLMEvalKit/vlmeval/dataset/aigc_detection.py**
118
+
119
+
120
+ ## 🏋️ Training
121
+
122
+ 1. Merge TranX-Adapter into the MLLM
123
+
124
+ First, TranX-Adapter needs to be merged into the MLLM so that it can be directly loaded with `from_pretrained()`. We provide merge scripts (`./llavanpr/merge_model.py` and `./qwen3vlnpr/merge_model.py`) as well as the merged models: [DreamMr/TranXAdapter-LLaVA-next-mistral7B-v0](https://huggingface.co/DreamMr/TranXAdapter-LLaVA-next-mistral7B-v0), [DreamMr/TranXAdapter-Qwen3VL2B-v0](https://huggingface.co/DreamMr/TranXAdapter-Qwen3VL2B-v0), [DreamMr/TranXAdapter-Qwen3VL4B-v0](https://huggingface.co/DreamMr/TranXAdapter-Qwen3VL4B-v0)
125
+
126
+
127
+ 2. Start training
128
+ Take training Qwen3Vl-2B on GenImage Sdv1.4 as an example:
129
+
130
+ ```bash
131
+ cd ms-swift/scripts/training
132
+ bash train_qwen3vl_Chameleon.sh
133
+ ```
134
+
135
+
136
+
137
+ i. If you want to train on RRDataset, you need to set the input image resolution to 512x512 (`./ms-swift/swift/llm/template/template/qwen.py line 637` and `./ms-swift/swift/llm/template/templatellava.py line192`).
138
+
139
+ ii. We found that if the model is trained directly on GenImage Sdv1.4, the MLLM tends to overfit to the input image resolution. Therefore, we recommend training with real and fake images that have the same resolution. We use the [BiasFree part](https://github.com/grip-unina/B-Free/tree/main/training_data) (SD2.1_selfconditioned_origBG.zip and COCO_real_512.zip) to prevent the model from overfitting to image resolution. We recommend downloading the data from the [official link](https://github.com/grip-unina/B-Free/tree/main/training_data).
140
+
141
+ iii. We found that MLLM training converges quickly and also overfits rapidly. Therefore, we recommend using a checkpoint from the middle of training.
142
+
143
+ ## 📈 Evaluation
144
+
145
+ 1. Modify the LMUData in `./VLMEvalKit/scripts/run_task.sh`
146
+
147
+ You need to modify `LMUData` to the absolute path of `Dataset`.
148
+
149
+ 2. Modify `DATASET_URL` and `DATASET_MD5` in `./VLMEvalKit/vlmeval/dataset/aigc_detection.py`.
150
+
151
+ Replace `DATASET_URL` with the absolute path of the CSV file, and fill in `DATASET_MD5` with the MD5 value [computed earlier](#📦preparation).
152
+
153
+ 3. Run code
154
+ ```bash
155
+ cd VLMEvalKit/scripts
156
+ bash run_task.sh
157
+ ```
158
+
159
+
160
+
161
+ ## 📧 Contact
162
+ - Wenbin Wang: [wangwenbin97@whu.edu.cn](wangwenbin97@whu.edu.cn)
163
+
164
+ ## 🖊️ Citation
165
+
166
+ If you use TranX-Adapter in your research, please cite our work:
167
+ ```
168
+ @inproceedings{wang2026tranx,
169
+ title={TranX-Adapter: Bridging Artifacts and Semantics within MLLMs for Robust AI-generated Image Detection},
170
+ author={Wang, Wenbin and Huang, Yuge and Xu, Jianqing and Yu, Yue and Yan, Jiangtao and Ding, Shouhong and Zhou, Pan and Luo, Yong},
171
+ booktitle={Forty-third International Conference on Machine Learning},
172
+ url={https://arxiv.org/abs/2602.21716}
173
+ }
174
+ ```
175
+
176
+ ## 🙏 Acknowledgement
177
+
178
+ - [VLMEvalKit](https://github.com/open-compass/VLMEvalKit)
179
+ - [ms-swift](https://github.com/modelscope/ms-swift)