Views
No views yet



| Checkpoints |
|---|
pip install -r requirements.txt1import torch
2from PIL import Image
3from torchvision import transforms
4
5from vtp.models.vtp_hf import VTPConfig, VTPModel
6from vtp.tokenizers import get_tokenizer
7
8model = VTPModel.from_pretrained("/path/to/MiniMaxAI/VTP-Large-f16d64")
9model.eval()
10
11# print model parameters
12def count_params(m): return sum(p.numel() for p in m.parameters()) / 1e6
13print(f"Vision Encoder: {count_params(model.trunk):.1f}M")
14print(f"Pixel Decoder: {count_params(model.pixel_decoder):.1f}M")
15print(f"Text Encoder: {count_params(model.text_transformer):.1f}M")
16
17preprocess = transforms.Compose([
18 transforms.Resize((256, 256)),
19 transforms.ToTensor(),
20 transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
21])
22image = preprocess(Image.open("figures/dog.png")).unsqueeze(0)
23
24# ---------------------------------------------------------------------------------------
25# use it as auto-encoder; rFID=0.36
26# ---------------------------------------------------------------------------------------
27denormalize = transforms.Normalize(
28 mean=[-0.485/0.229, -0.456/0.224, -0.406/0.225],
29 std=[1/0.229, 1/0.224, 1/0.225]
30)
31with torch.no_grad(), torch.autocast("cuda"):
32 latents = model.get_reconstruction_latents(image) # encode
33 recon = model.get_latents_decoded_images(latents) # decode
34recon_image = denormalize(recon[0]).clamp(0, 1).permute(1, 2, 0).cpu().numpy()
35Image.fromarray((recon_image * 255).astype("uint8")).save("output/reconstructed.png")
36
37
38# ---------------------------------------------------------------------------------------
39# use it as clip; zero-shot 78.2
40# ---------------------------------------------------------------------------------------
41tokenizer = get_tokenizer('ViT-B-32', context_length=model.config.text_context_length)
42text = tokenizer(["a diagram", "a dog", "a cat", "a person"])
43with torch.no_grad(), torch.autocast("cuda"):
44 image_features = model.get_clip_image_feature(image, normalize=True)
45 text_features = model.get_clip_text_feature(text, normalize=True)
46 text_probs = (100.0 * image_features @ text_features.T).softmax(dim=-1)
47print("Label probs:", [f"{p:.4f}" for p in text_probs[0].tolist()])
48
49# ---------------------------------------------------------------------------------------
50# use it as ssl feature extractor; linear probing 85.7
51# ---------------------------------------------------------------------------------------
52with torch.no_grad(), torch.autocast("cuda"):
53 # get last layer features (cls token + patch tokens)
54 features = model.get_last_layer_feature(image)
55 cls_token = features['cls_token'] # (B, 1024)
56 patch_tokens = features['patch_tokens'] # (B, 256, 1024) for 256x256 image
57
58 # or get intermediate layer features for linear probing
59 intermediate = model.get_intermediate_layers_feature(
60 image, n=4, return_class_token=True
61 ) # returns 4 x (patch_tokens, cls_token), each cls_token is (B, 1024)
62 for i in range(1, 5):
63 print('Last %d layers:' % i)
64 print('Patch tokens shape:', intermediate[-i][0].shape)
65 print('Cls token shape:', intermediate[-i][1].shape)| Model | Understanding | Reconstruction | Generation | |
|---|---|---|---|---|
| Zero-shot Acc. | Linear Probing | rFID | LightningDiT-XL 80ep nocfg FID-50K | |
| OpenCLIP | 74.0 | - | - | - |
| CLIP | 75.5 | - | - | - |
| SigLIP | 80.5 | - | - | - |
| MAE | - | 85.9 | - | - |
| DINOv2 | - | 86.7 | - | - |
| UniTok | 70.8 | - | 0.41 | - |
| VILA-U | 73.3 | - | 1.80 | - |
| VA-VAE-f16d32 | - | - | 0.28 | 4.29 |
| VA-VAE-f16d64 | - | - | 0.15 | - |
| RAE-f16d768 | - | 84.5 | 0.57 | 4.28 |
| VTP-S-f16d64 (ours) | 66.7 | 77.5 | 0.98 | 5.46 |
| VTP-B-f16d64 (ours) | 73.2 | 81.0 | 0.74 | 3.88 |
| VTP-L-f16d64 (ours) | 78.2 | 85.7 | 0.36 | 2.81 |

1conda create -n vtp python=3.10
2conda activate vtp
3git submodule update --init --recursive
4pip install -r requirements.txtscripts/test_zero_shot_hf.sh. Run:bash scripts/test_zero_shot_hf.sh scripts/test_linear_probing_hf.sh. Run:bash scripts/test_linear_probing_hf.shscripts/test_reconstruction_hf.sh. Run:bash scripts/test_reconstruction_hf.shbash generation/scripts/extract_features_vtp.sh generation/configs/train_vtp_l_dit_xl.yamlbash generation/scripts/train_lightningdit_vtp.sh generation/configs/train_vtp_l_dit_xl.yamlbash generation/scripts/inference_lightningdit_vtp.sh generation/configs/train_vtp_l_dit_xl.yaml1@article{vtp,
2 title={Towards Scalable Pre-training of Visual Tokenizers for Generation},
3 author={Yao, Jingfeng and Song, Yuda and Zhou, Yucong and Wang, Xinggang},
4 journal={arXiv preprint arXiv:2512.13687},
5 year={2025}
6}