Views
No views yet
video / image (T, 3, 224, 224)
│
↓
DINOv3-small ConvNeXt → patch features F (T·56·56, D=512)
│
↓
PerceiverResampler (K=128 learnable trajectory queries, depth=2)
│
↓
soft-mask assignment: M[k, p] = softmax_k(q_k · F_p) (paper Eq. 1)
│
↓
trajectory tokens: z_k = Σ_p M[k, p] · F_p (paper Eq. 2)1import torch, yaml
2from easydict import EasyDict as edict
3from trajtok_segmenter.model.segmenter import SimpleSegmenter
4
5# Load the released checkpoint
6state = torch.load("path/to/latest.pth", map_location="cpu", weights_only=False)
7sd = state["model"]
8# Strip outer SegmentWrapper prefix (the training script wraps SimpleSegmenter)
9sd = {k[len("vision_encoder."):] if k.startswith("vision_encoder.") else k: v for k, v in sd.items()}
10
11# Build matching architecture
12cfg = yaml.safe_load(open("trajtokv2/segmenter/configs/pretrain.yaml"))
13model = SimpleSegmenter(
14 config=edict(cfg["traj_model"]),
15 backbone_config=edict(cfg["backbone"]),
16 perceiver_config=edict(cfg["perceiver"]),
17 high_res=False,
18).cuda().eval()
19model.load_state_dict(sd, strict=False)
20
21# Run forward on a clip
22video = torch.randn(1, 8, 3, 224, 224).cuda() # (B, T, 3, H, W); T=1 for images
23with torch.no_grad():
24 logits = model(video) # (B, N=T·56·56, K=128)
25traj_id = logits.argmax(-1) # per-patch trajectory ID
26soft_mask = logits.softmax(-1) # per-patch trajectory weightsegmenter/scripts/demo_image.py), evaluation drivers
(DAVIS / MOSE / YT-VIS), and training code.filteredmixdata_all mixture:| Source | Samples | Type |
|---|---|---|
big_image_new | ~300 K | filtered image-caption pairs with auto-generated trajectory masks |
big_video_new | ~1 M | filtered video-caption pairs with auto-generated per-frame trajectory masks |
| SA-1B (Meta AI) | ~11 M | original SA-1B images + instance masks |
| SA-V (Meta AI) | ~48 K | SA-V videos + per-frame instance masks |
| Knob | Value |
|---|---|
| Trajectory tokens K | 128 |
| Embedding dim | 512 |
| Backbone | DINOv3-small ConvNeXt |
| Perceiver depth | 2 |
| Input resolution | 224×224 |
| Latent grid | 56×56 |
| Loss | dice + focal (per-patch class loss) + per-patch pixel loss |
| Optimizer | AdamW (lr=1e-4, wd=0.02) |
| Schedule | cosine, 1-epoch warmup |
| Epochs | 3 |
| Per-modality batch size | image=64, video=8, sa1b=64, sav=8 |
| Hardware | 2 nodes × 8 × H100 (80 GB) |
merge_tracklets from
trajtok_segmenter.eval.eval_segmenter to stitch IDs across windows.1@article{zheng2026trajtokv2,
2 title = {TrajTok-v2: Trajectory-aware visual tokenization for vision-language models},
3 author = {Zheng, Chenhao and others},
4 journal = {arXiv preprint arXiv:2602.22779},
5 year = {2026},
6}