--- license: mit library_name: transformers pipeline_tag: image-feature-extraction tags: - motif - vision-transformer - self-supervised - image-feature-extraction - video - custom_code --- # Motif Vision Encoder Motif Vision Encoder is a unified image + video self-supervised vision encoder on a ViT backbone. A single 3D-convolutional tokenizer ingests both modalities — an image is a 1-frame clip (`T=1`), a video is `T>1` — so the same weights produce dense patch-level features and a language-aligned global (CLS) representation. Trained on **~1/3 the data of DINOv3** (0.5B vs 1.7B samples), it still reaches competitive performance across image and video benchmarks — and leads on DAVIS video tracking.
Point tracking on a video clip (top: Motif, bottom: V-JEPA 2.1) — a query point propagated across frames by patch-feature cosine similarity. Motif tracks the subject more reliably than V-JEPA 2.1.
- **Architecture**: ViT-7B (embed 4096 / depth 40 / heads 32), patch 16, 3D axial RoPE (`base=100`), SwiGLU FFN, LayerScale, per-head QK-norm, gated attention, 4 register tokens. - **Tokenizer**: `Conv3d(kernel=stride=(tubelet, patch, patch))` — image `(B,3,H,W)` → `T=1`, video `(B,T,3,H,W)`. Token layout `[CLS] + [register × 4] + [patch × N]`. ## Usage The model ships a self-contained `modeling_motif_vision_encoder.py`, so it loads with `trust_remote_code=True`. ### Image ```python import torch from transformers import AutoImageProcessor, AutoModel from transformers.image_utils import load_image url = "http://images.cocodataset.org/val2017/000000039769.jpg" image = load_image(url) repo = "Motif-Technologies/Motif-Vision-Encoder" processor = AutoImageProcessor.from_pretrained(repo) model = AutoModel.from_pretrained(repo, trust_remote_code=True, dtype=torch.bfloat16).to("cuda").eval() inputs = processor(images=image, return_tensors="pt").to(model.device, torch.bfloat16) with torch.inference_mode(): outputs = model(**inputs) outputs.last_hidden_state # (1, 1 + 4 + N, 4096) CLS + registers + patch tokens outputs.pooler_output # (1, 4096) global (CLS) representation patch_tokens = outputs.last_hidden_state[:, 5:, :] # (1, N, 4096), N = (H/16)*(W/16) ``` The processor resizes the shorter side to 512, center-crops to 512×512, and normalizes with ImageNet mean/std (BICUBIC). `H`/`W` must be multiples of 16. ### Video An image is a 1-frame clip; a video is the same call with a `(B, T, 3, H, W)` tensor. Apply the same per-frame transform (resize → center-crop → ImageNet norm) and stack over time: ```python import torch video = torch.randn(1, 8, 3, 256, 256, device="cuda", dtype=torch.bfloat16) # (B, T, 3, H, W) with torch.inference_mode(): outputs = model(pixel_values=video) ``` ## Model details
Dense features on a single image (768px). Columns: query point, CLS attention, query-point attention, patch-feature cosine similarity. Motif and DINOv3 keep attention and similarity tightly localized on the queried object, while V-JEPA 2.1 and SigLIP2 are noticeably noisier.
## License Released under the **MIT License** (see `LICENSE`). The model was trained on data governed by the respective dataset licenses; downstream users are responsible for compliance with those terms.