Views
No views yet



1git clone https://github.com/Gorilla-Lab-SCUT/PaDT.git
2
3conda create -n PaDT python=3.11
4conda activate PaDT
5
6bash setup.sh1import torch
2from transformers import AutoProcessor
3from qwen_vl_utils import process_vision_info
4from PaDT import PaDTForConditionalGeneration, VisonTextProcessingClass, parseVRTintoCompletion
5
6
7TEST_IMG_PATH="./eval/imgs/000000368335.jpg"
8MODEL_PATH="PaDT-MLLM/PaDT_Pro_3B"
9
10# load model
11model = PaDTForConditionalGeneration.from_pretrained(MODEL_PATH, torch_dtype=torch.bfloat16, device_map={"": 0})
12# load processor
13processor = AutoProcessor.from_pretrained(
14 MODEL_PATH
15)
16processor = VisonTextProcessingClass(processor, model.config.vision_config.spatial_merge_size)
17processor.prepare(model.model.embed_tokens.weight.shape[0])
18
19# question prompt
20PROMPT = "Please describe this image."
21
22# construct conversation
23message = [
24 {
25 "role": "user",
26 "content": [
27 {
28 "type": "image",
29 "image": TEST_IMG_PATH
30 }, {
31 "type": "text",
32 "text": PROMPT
33 }
34 ]
35 }
36]
37text = processor.apply_chat_template(message, tokenize=False, add_generation_prompt=True)
38image_inputs, video_inputs = process_vision_info(message)
39prompt_inputs = processor(
40 text=[text],
41 images=image_inputs,
42 padding=True,
43 padding_side="left",
44 return_tensors="pt",
45 add_special_tokens=False
46).to("cuda:0")
47
48# generate
49with torch.inference_mode():
50 generate_returned_result = model.generate(**prompt_inputs, use_cache=True, max_new_tokens=1024, do_sample=False,
51 output_hidden_states=True, return_dict_in_generate=True)
52 prompt_length = prompt_inputs["input_ids"].size(1)
53 completion_ids = generate_returned_result['sequences'][:, prompt_length:]
54
55 # extract Visual Reference Tokens within the sequence
56 completions, feats, labels, vrts, vrts_feats = parseVRTintoCompletion(processor, completion_ids, generate_returned_result['hidden_states'], torch.Tensor([False]))
57
58 print("\ngenerate result:", completions[0])
59
60 # decode low-level visual task results
61 low_res_image_embeds = generate_returned_result.past_image_embeds
62 high_res_image_embeds = generate_returned_result.past_high_res_image_embeds
63 visual_pe = generate_returned_result.past_visual_pe
64 decoded_list = model.vl_decode(feats, low_res_image_embeds, high_res_image_embeds, prompt_inputs['image_grid_thw'], visual_pe)
65
66 print(f"\npred_bboxes: {decoded_list['pred_boxes']},\npred_scores: {decoded_list['pred_score'].sigmoid()}\n")| Model | Base VLM | Checkpoint | Task Type |
|---|---|---|---|
| PaDT_OVD_3B | Qwen2.5VL-3B | PaDT-MLLM/PaDT_OVD_3B | Open Vocabulary Detection |
| PaDT_REC_3B | Qwen2.5VL-3B | PaDT-MLLM/PaDT_REC_3B | Referring Expression Comprehension/Segmentation |
| PaDT_RIC_3B | Qwen2.5VL-3B | PaDT-MLLM/PaDT_RIC_3B | Referring Image Captioning |
| PaDT_Pro_3B | Qwen2.5VL-3B | PaDT-MLLM/PaDT_Pro_3B | ALL |
| PaDT_OVD_7B | Qwen2.5VL-7B | PaDT-MLLM/PaDT_OVD_7B | Open Vocabulary Detection |
| PaDT_REC_7B | Qwen2.5VL-7B | PaDT-MLLM/PaDT_REC_7B | Referring Expression Comprehension/Segmentation |
| PaDT_RIC_7B | Qwen2.5VL-7B | PaDT-MLLM/PaDT_RIC_7B | Referring Image Captioning |
| PaDT_Pro_7B | Qwen2.5VL-7B | PaDT-MLLM/PaDT_Pro_7B | ALL |



1wget https://web.archive.org/web/20220413011718/https://bvisionweb1.cs.unc.edu/licheng/referit/data/refcoco.zip
2wget https://web.archive.org/web/20220413011656/https://bvisionweb1.cs.unc.edu/licheng/referit/data/refcoco+.zip
3wget https://web.archive.org/web/20220413012904/https://bvisionweb1.cs.unc.edu/licheng/referit/data/refcocog.zipPaDT/
├── dataset/
│ ├── coco/
│ │ ├── annotations/
│ │ ├── train2014/
│ │ ├── train2017/
│ │ ├── val2014/
│ │ └── val2017/
│ └── RefCOCO/
│ ├── refcoco/
│ ├── refcoco+/
│ └── refcocog/1cd src/preprocess
2python process_coco.py
3python process_refcoco.py| Dataset | Dataset Path | Task Type |
|---|---|---|
| COCO | PaDT-MLLM/COCO | Open Vocabulary Detection |
| RefCOCO | PaDT-MLLM/RefCOCO | Referring Expression Comprehension/Segmentation |
| RIC | PaDT-MLLM/ReferringImageCaptioning | Referring Image Captioning |
run_scripts are ready to execute.bash ./run_scripts/padt_pro_3b_sft.sheval/test_demo.py. More evaluation scripts will be added soon.@misc{su2025patchasdecodabletokenunifiedmultimodalvision,
title={Patch-as-Decodable-Token: Towards Unified Multi-Modal Vision Tasks in MLLMs},
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},
year={2025},
eprint={2510.01954},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/2510.01954},
}