--- license: apache-2.0 ---
## News [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). [2026.05.01] Our paper was accepted to ICML 2026! π [2026.02.25] We released the ArXiv paper. π ## TL;DR 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. ## π§ Installation 1. Clone this repository and navigate into the codebase ```bash git clone https://github.com/DreamMr/TranX-Adapter.git cd TranX-Adapter ``` 2. Install Packages ```bash bash install.sh ``` When the environment is created successfully, you will see: `Conda environment name tranxadapter has been createdπ. Now you can run "conda activate tranxadapter"` ## π¦ Preparation 1. Download the datasets - 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)). - Evaluation Data: [GenImage](https://genimage-dataset.github.io/), [Chameleon](https://github.com/shilinyan99/AIDE/issues/7), [RRDataset](https://arxiv.org/abs/2509.09172) - [Our constructed VQA dataset](https://huggingface.co/datasets/DreamMr/TranXAdapter-Dataset/tree/main) Download the above data to `./Dataset`, with the structure as follows: ```text Dataset/ βββ TranXAdapter-Dataset/ β βββ training/ β β βββ GenImage_Sdv1d4.jsonl β β βββ GenImageAll.jsonl β β βββ RRDataset.jsonl β β βββ BFP.jsonl β βββ evaluation/ β β βββ Chamelon.tsv β β βββ GenImage.tsv β β βββ RR.tsv βββ GenImage/ β βββ ADM β βββ test β βββ ... βββ Chameleon/test/ β βββ 0_real β βββ 1_fake βββ RRDataset_final/ β βββ original β βββ redigital β βββ ... βββ RRDataset_original_train_val β βββ train β βββ val βββ BFP β βββ ai β βββ real ``` 2. Process Data Run `python preprocess_data.py` to replace the image paths in JSONL/CSV files with absolute paths. **Note: You need to copy the MD5 values corresponding to the CSV files into DATASET_MD5 in ./VLMEvalKit/vlmeval/dataset/aigc_detection.py** ## ποΈ Training 1. Merge TranX-Adapter into the MLLM 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) 2. Start training Take training Qwen3Vl-2B on GenImage Sdv1.4 as an example: ```bash cd ms-swift/scripts/training bash train_qwen3vl_Chameleon.sh ``` 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`). 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). iii. We found that MLLM training converges quickly and also overfits rapidly. Therefore, we recommend using a checkpoint from the middle of training. ## π Evaluation 1. Modify the LMUData in `./VLMEvalKit/scripts/run_task.sh` You need to modify `LMUData` to the absolute path of `Dataset`. 2. Modify `DATASET_URL` and `DATASET_MD5` in `./VLMEvalKit/vlmeval/dataset/aigc_detection.py`. Replace `DATASET_URL` with the absolute path of the CSV file, and fill in `DATASET_MD5` with the MD5 value [computed earlier](#π¦preparation). 3. Run code ```bash cd VLMEvalKit/scripts bash run_task.sh ``` ## π§ Contact - Wenbin Wang: [wangwenbin97@whu.edu.cn](wangwenbin97@whu.edu.cn) ## ποΈ Citation If you use TranX-Adapter in your research, please cite our work: ``` @inproceedings{wang2026tranx, title={TranX-Adapter: Bridging Artifacts and Semantics within MLLMs for Robust AI-generated Image Detection}, author={Wang, Wenbin and Huang, Yuge and Xu, Jianqing and Yu, Yue and Yan, Jiangtao and Ding, Shouhong and Zhou, Pan and Luo, Yong}, booktitle={Forty-third International Conference on Machine Learning}, url={https://arxiv.org/abs/2602.21716} } ``` ## π Acknowledgement - [VLMEvalKit](https://github.com/open-compass/VLMEvalKit) - [ms-swift](https://github.com/modelscope/ms-swift)