PaDT-MLLM commited on
Commit
69aa98c
·
verified ·
1 Parent(s): 6580a79

Upload 7 files

Browse files
.gitattributes CHANGED
@@ -34,3 +34,9 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  tokenizer.json filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
  tokenizer.json filter=lfs diff=lfs merge=lfs -text
37
+ assets/Motivation.webp filter=lfs diff=lfs merge=lfs -text
38
+ assets/Pipeline.webp filter=lfs diff=lfs merge=lfs -text
39
+ assets/REC_OVD.webp filter=lfs diff=lfs merge=lfs -text
40
+ assets/RIC.webp filter=lfs diff=lfs merge=lfs -text
41
+ assets/TAM.webp filter=lfs diff=lfs merge=lfs -text
42
+ assets/TaskIntroduction.webp filter=lfs diff=lfs merge=lfs -text
README.md CHANGED
@@ -1,3 +1,185 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Patch-as-Decodable-Token: Towards Unified Multi-Modal Vision Tasks in MLLMs
2
+
3
+ <font size=4><div align='center'>[[🔗 Released Code](https://github.com/Gorilla-Lab-SCUT/PaDT)]
4
+ [[🤗 Datasets](https://huggingface.co/collections/PaDT-MLLM/padt-dataset-68e400440ffb8c8f95e5ee20)] [[🤗 Checkpoints](https://huggingface.co/collections/PaDT-MLLM/padt-68e3f5c22e8ecbd6d0d13d43)]</div></font>
5
+ <font size=4><div align='center'>[[📄 Tech Report](https://arxiv.org/abs/2510.01954)]</div></font>
6
+
7
+ <div align="center">
8
+ <img src="./assets/Pipeline.webp" width="900"/>
9
+ <p>Figure A. PaDT pipeline.</p>
10
+ </div>
11
+
12
+ # 🌟 Introduction
13
+
14
+ We are pleased to introduce **Patch-as-Decodable Token (PaDT)**, a unified paradigm that enables multimodal large language models (MLLMs) to directly generate both textual and visual outputs.
15
+
16
+ At the core of PaDT are **Visual Reference Tokens (VRTs)**. Unlike conventional MLLMs that represent visual targets using text-based bounding box coordinates (which are often less semantic and poorly aligned with the actual objects, as shown in Figure B), PaDT allows MLLMs to represent visual targets directly through visual patches. These VRTs let the model reason about visual information within the output sequence in a more natural and direct way.
17
+
18
+ By introducing VRTs, we achieve **semantic reasoning and object-specific visual tokens prediction** within the MLLM’s autoregressive generation process. The predicted visual tokens are then decoded into **low-level outputs** such as localization or segmentation maps using a plug-and-play lightweight PaDT decoder.
19
+
20
+ As illustrated in Figure C, we have validated PaDT across four major visual perception and understanding tasks. In all cases, PaDT achieves **state-of-the-art** performance compared to conventional character-by-character coordinate-generation MLLMs.
21
+
22
+ We hope this work will inspire further exploration in the community:
23
+
24
+ - What does true multimodal reasoning look like?
25
+
26
+ - How can textual and visual elements be generated together in an MLLM output sequence?
27
+
28
+ - And is a purely text-based output ever sufficient for visual reasoning?
29
+
30
+ <div align="center">
31
+ <img src="./assets/Motivation.webp" width="900"/>
32
+ <p>Figure B. Some observations on conventional character-by-character coordinate-generation MLLMs and our PaDT.</p>
33
+ </div>
34
+
35
+
36
+ <div align="center">
37
+ <img src="./assets/TaskIntroduction.webp" width="900"/>
38
+ <p>Figure C. PaDT works on four visual perception and understanding tasks.</p>
39
+ </div>
40
+
41
+ # Quick Start
42
+
43
+ Clone this repo, and set up the environment with a few commands.
44
+
45
+ ```bash
46
+ git clone https://github.com/Gorilla-Lab-SCUT/PaDT.git
47
+
48
+ conda create -n PaDT python=3.11
49
+ conda activate PaDT
50
+
51
+ bash setup.sh
52
+ ```
53
+
54
+ The following contains a code snippet illustrating how to use our PaDT.
55
+
56
+ ```python
57
+ import torch
58
+ from transformers import AutoProcessor
59
+ from qwen_vl_utils import process_vision_info
60
+ from PaDT import PaDTForConditionalGeneration, VisonTextProcessingClass, parseVRTintoCompletion
61
+
62
+
63
+ TEST_IMG_PATH="./eval/imgs/000000368335.jpg"
64
+ MODEL_PATH="PaDT-MLLM/PaDT_Pro_3B"
65
+
66
+ # load model
67
+ model = PaDTForConditionalGeneration.from_pretrained(MODEL_PATH, torch_dtype=torch.bfloat16, device_map={"": 0})
68
+ # load processor
69
+ processor = AutoProcessor.from_pretrained(
70
+ MODEL_PATH
71
+ )
72
+ processor = VisonTextProcessingClass(processor, model.config.vision_config.spatial_merge_size)
73
+ processor.prepare(model.model.embed_tokens.weight.shape[0])
74
+
75
+ # question prompt
76
+ PROMPT = "Please describe this image."
77
+
78
+ # construct conversation
79
+ message = [
80
+ {
81
+ "role": "user",
82
+ "content": [
83
+ {
84
+ "type": "image",
85
+ "image": TEST_IMG_PATH
86
+ }, {
87
+ "type": "text",
88
+ "text": PROMPT
89
+ }
90
+ ]
91
+ }
92
+ ]
93
+ text = processor.apply_chat_template(message, tokenize=False, add_generation_prompt=True)
94
+ image_inputs, video_inputs = process_vision_info(message)
95
+ prompt_inputs = processor(
96
+ text=[text],
97
+ images=image_inputs,
98
+ padding=True,
99
+ padding_side="left",
100
+ return_tensors="pt",
101
+ add_special_tokens=False
102
+ ).to("cuda:0")
103
+
104
+ # generate
105
+ with torch.inference_mode():
106
+ generate_returned_result = model.generate(**prompt_inputs, use_cache=True, max_new_tokens=1024, do_sample=False,
107
+ output_hidden_states=True, return_dict_in_generate=True)
108
+ prompt_length = prompt_inputs["input_ids"].size(1)
109
+ completion_ids = generate_returned_result['sequences'][:, prompt_length:]
110
+
111
+ # extract Visual Reference Tokens within the sequence
112
+ completions, feats, labels, vrts, vrts_feats = parseVRTintoCompletion(processor, completion_ids, generate_returned_result['hidden_states'], torch.Tensor([False]))
113
+
114
+ print("\ngenerate result:", completions[0])
115
+
116
+ # decode low-level visual task results
117
+ low_res_image_embeds = generate_returned_result.past_image_embeds
118
+ high_res_image_embeds = generate_returned_result.past_high_res_image_embeds
119
+ visual_pe = generate_returned_result.past_visual_pe
120
+ decoded_list = model.vl_decode(feats, low_res_image_embeds, high_res_image_embeds, prompt_inputs['image_grid_thw'], visual_pe)
121
+
122
+ print(f"\npred_bboxes: {decoded_list['pred_boxes']},\npred_scores: {decoded_list['pred_score'].sigmoid()}\n")
123
+ ```
124
+
125
+ # Models
126
+
127
+ - PaDT_OVD: Trained on COCO2017 training set.
128
+ - PaDT_REC: Trained on RefCOCO/+/g training set.
129
+ - PaDT_RIC: Trained on Referring Image Captioning training set.
130
+ - PaDT_Pro: Trained on the combined set of COCO2017, RefCOCO/+/g and Referring Image Captioning training sets.
131
+
132
+ | Model | Base VLM | Checkpoint | Task Type |
133
+ | - | - | - | - |
134
+ | PaDT_OVD_3B | Qwen2.5VL-3B | [PaDT-MLLM/PaDT_OVD_3B](https://huggingface.co/PaDT-MLLM/PaDT_OVD_3B) | Open Vocabulary Detection |
135
+ | PaDT_REC_3B | Qwen2.5VL-3B | [PaDT-MLLM/PaDT_REC_3B](https://huggingface.co/PaDT-MLLM/PaDT_REC_3B) | Referring Expression Comprehension/Segmentation |
136
+ | PaDT_RIC_3B | Qwen2.5VL-3B | [PaDT-MLLM/PaDT_RIC_3B](https://huggingface.co/PaDT-MLLM/PaDT_RIC_3B) | Referring Image Captioning |
137
+ | PaDT_Pro_3B | Qwen2.5VL-3B | [PaDT-MLLM/PaDT_Pro_3B](https://huggingface.co/PaDT-MLLM/PaDT_Pro_3B) | ALL |
138
+ | PaDT_OVD_7B | Qwen2.5VL-7B | [PaDT-MLLM/PaDT_OVD_7B](https://huggingface.co/PaDT-MLLM/PaDT_OVD_7B) | Open Vocabulary Detection |
139
+ | PaDT_REC_7B | Qwen2.5VL-7B | [PaDT-MLLM/PaDT_REC_7B](https://huggingface.co/PaDT-MLLM/PaDT_REC_7B) | Referring Expression Comprehension/Segmentation |
140
+ | PaDT_RIC_7B | Qwen2.5VL-7B | [PaDT-MLLM/PaDT_RIC_7B](https://huggingface.co/PaDT-MLLM/PaDT_RIC_7B) | Referring Image Captioning |
141
+ | PaDT_Pro_7B | Qwen2.5VL-7B | [PaDT-MLLM/PaDT_Pro_7B](https://huggingface.co/PaDT-MLLM/PaDT_Pro_7B) | ALL |
142
+
143
+
144
+ # Showcase
145
+
146
+ Here are some randomly selected test examples showcasing PaDT’s excellent performance.
147
+
148
+ - Referring Expression Comprehension/Segmentation and Open Vocabulary Detection Tasks
149
+
150
+ <div align="center">
151
+ <img src="./assets/REC_OVD.webp" width="900"/>
152
+ </div>
153
+
154
+ - Referring Image Captioning Task
155
+
156
+ <div align="center">
157
+ <img src="./assets/RIC.webp" width="900"/>
158
+ </div>
159
+
160
+ - Token Activation Map Comparison
161
+
162
+ <div align="center">
163
+ <img src="./assets/TAM.webp" width="900"/>
164
+ </div>
165
+
166
+ # License Agreement
167
+
168
+ PaDT is licensed under Apache 2.0.
169
+
170
+ # Citation
171
+
172
+ We kindly encourage citation of our work if you find it useful.
173
+
174
+ ```
175
+ @misc{su2025patchasdecodabletokenunifiedmultimodalvision,
176
+ title={Patch-as-Decodable-Token: Towards Unified Multi-Modal Vision Tasks in MLLMs},
177
+ author={Yongyi Su and Haojie Zhang and Shijie Li and Nanqing Liu and Jingyi Liao and Junyi Pan and Yuan Liu and Xiaofen Xing and Chong Sun and Chen Li and Nancy F. Chen and Shuicheng Yan and Xulei Yang and Xun Xu},
178
+ year={2025},
179
+ eprint={2510.01954},
180
+ archivePrefix={arXiv},
181
+ primaryClass={cs.CV},
182
+ url={https://arxiv.org/abs/2510.01954},
183
+ }
184
+ ```
185
+
assets/Motivation.webp ADDED

Git LFS Details

  • SHA256: 66c13af7576db662c3e41b28ccb3abe7db1f4897e28090f61b039dc6ad3eb299
  • Pointer size: 131 Bytes
  • Size of remote file: 309 kB
assets/Pipeline.webp ADDED

Git LFS Details

  • SHA256: bf3205efa1911bee0eecb65dd0333ac4691c24903e9fa5df10e74f24442e9d37
  • Pointer size: 131 Bytes
  • Size of remote file: 449 kB
assets/REC_OVD.webp ADDED

Git LFS Details

  • SHA256: fc9af5981ca3f04aef62ce96d8c74d890815d8e4589dea54bc9066465ec6e997
  • Pointer size: 132 Bytes
  • Size of remote file: 1.44 MB
assets/RIC.webp ADDED

Git LFS Details

  • SHA256: 91ce1b4f7d3dfb0e53253521f2cbc110694ef1352e21e50c3b73c567e5050bb3
  • Pointer size: 132 Bytes
  • Size of remote file: 1.64 MB
assets/TAM.webp ADDED

Git LFS Details

  • SHA256: d09631a9a0647a1731df0c5c915698014e342e8310fd549d79fa4d56065c4f9e
  • Pointer size: 131 Bytes
  • Size of remote file: 868 kB
assets/TaskIntroduction.webp ADDED

Git LFS Details

  • SHA256: fccec4afd04b46702d10c3801368330450bdc656348529fd0f6a6abc6b817cd3
  • Pointer size: 132 Bytes
  • Size of remote file: 1.47 MB