From: microsoft <huggingface.co/microsoft>Newsgroups: alt.freeweights.visionSubject:

Mage-ViT

Date: 2026-11-15Commit: de3bd80Signed: 2DC28CC7B26A283B ✓

Image feature extraction model with 316M parameters. Safetensors weights, 631 MB in all. Published by microsoft under MIT.

316M params631MBMage-ViTsafetensorspermissive
FactsParams316MSize631 MBFormatssafetensorsTaskimage feature extractionLicenseMITFrom sourcepermissive
$ fw get microsoft/Mage-ViT
# manifest sha256 65d7747d860e… · 631 MB · 8 files
$ fw verify ./Mage-ViT microsoft/Mage-ViT
From sourceHosted (signed)microsoft/Mage-ViTLast check: 2026-11-15 03:50 UTC

Get help: custom fine-tune or private deploy. We review your setup before we quote.

Works with

Runs with

Ranked by fit to this model (safetensors), then by GitHub stars.

Overview

Size
631 MB
Weights
631 MB (safetensors)
Parameters
316M
Formats
safetensors
Task
image feature extraction
License
MIT (permissive)
Files
8, each with a sha256
Publisher
microsoft
Added
2026-11-15
Section
alt.freeweights.vision
Lineage

Original release from the publisher.

Where these bytes come from
Publisher at the pinned commit→You

Sources are tried in order. A file counts only when its size and sha256 match the manifest. Sources are checked when you ask for them, not on a timer.

Sources
BadgeHostLast checkResult
From sourcehuggingface.co2026-11-15 03:50 UTCpassed

Model card

From the publisher at commit de3bd80. Shown as plain text with links; images open at the publisher.

Mage-ViT#

A Codec-Native Visual Encoder Trained from Scratch

Project Page GitHub Mage-VL Mage-ViT License: MIT


Mage-ViT is the visual encoder at the core of Mage-VL. It is a Codec-ViT built primarily for video, where a single image is simply the degenerate one-frame case. Mage-ViT follows a codec-aligned sparsity principle: visual tokens should be spent where a video codec spends bits, since codec bit-allocation is a natural proxy for spatio-temporal importance. On a shared 16×16 patch grid it keeps every anchor (I-frame) patch and only the motion-salient predicted (P-frame) patches, while a shared 3D rotary position encoding preserves spatio-temporal structure even after large fractions of the grid are dropped.

This repository is the ViT-pre-trained checkpoint only — it has not gone through the joint VLM training with the language model. Use it as a data-efficient, codec-native visual encoder, or as a drop-in ViT for your own multimodal training.

✨ Highlights#

  • Codec-driven patchifier. Patches are selected by a per-patch importance map derived from the codec — motion vectors + P-frame residual energy for HEVC/H.265, or the learned rate map of the neural codec DCVC-RT. For a 64-frame clip it keeps all I-frame patches plus the top-k P-frame patches within a 4096-token budget (~75% token reduction). Chunk-wise and collage patchification are also supported.
  • Codec-agnostic. The same interface accepts a traditional codec (HEVC/H.265) or a neural codec (DCVC-RT) with no architecture or retraining change.
  • Trained from scratch. No billion-scale image-text ViT initialization — Mage-ViT is optimized with a large-scale cluster-discrimination objective on ~100M unlabeled images/videos.

🏗️ Architecture#

A 24-layer pre-norm Vision Transformer trunk (hidden size 1024, 16 attention heads, GELU MLP at 4× expansion) processes the variable-length token sequence produced by the codec-driven patchifier, followed by a multi-head attention pooling head. The standalone encoder in this repo consumes pixel_values (and optional patch_positions); codec-driven patch selection is applied upstream in the Mage-VL data pipeline.

Pre-training is a two-stage, from-scratch recipe in bf16: (1) variable-resolution image pre-training (224–448), then (2) joint image + video pre-training (video at resolution 256, 64 frames per clip, 4096-token budget).

📦 Installation#

Mage-ViT follows the Mage-VL runtime:

pip install "transformers>=5.7" torch torchvision pillow
# optional, for the fastest GPU attention path:
# pip install flash-attn --no-build-isolation

Attention is dispatched internally to sdpa (default) → flash_attention_2 → eager, so flash-attn is optional and the model runs on CPU or GPU out of the box.

🚀 Encoding an image#

import torch
from PIL import Image
from transformers import AutoModel, AutoImageProcessor

model = AutoModel.from_pretrained(
    "microsoft/Mage-ViT", trust_remote_code=True
).to("cuda").eval()
processor = AutoImageProcessor.from_pretrained(
    "microsoft/Mage-ViT", trust_remote_code=True
)

image = Image.open("your_image.jpg")
pixel_values = processor(images=image, return_tensors="pt")["pixel_values"].to("cuda")

with torch.no_grad():
    out = model(pixel_values)              # pixel_values: [B, 3, H, W]

patch_features = out.last_hidden_state     # [B, num_patches, 1024]
pooled_feature = out.pooler_output         # [B, 1024]

Pass attn_implementation="flash_attention_2" (or "sdpa" / "eager") to from_pretrained to pick the attention backend.

🎞️ Encoding a video#

Stack the preprocessed frames into [B, C, T, H, W] and pass a patch_positions tensor of shape [B, T * tokens_per_frame, 3] giving the (t, h, w) grid coordinate of every patch:

import torch
from PIL import Image

PATCH = 16

def build_patch_positions(num_frames, target_frames, grid_h, grid_w, device="cuda"):
    # temporal index for each frame, spread across the target timeline
    t = torch.linspace(0, target_frames - 1, num_frames, device=device).long()
    t = t.repeat_interleave(grid_h * grid_w)                    # [T * H * W]
    h = torch.arange(grid_h, device=device).repeat_interleave(grid_w).repeat(num_frames)
    w = torch.arange(grid_w, device=device).repeat(grid_h).repeat(num_frames)
    return torch.stack([t, h, w], dim=-1).unsqueeze(0)          # [1, T*H*W, 3]

frames = [Image.open(f"frame_{i}.jpg") for i in range(16)]      # your sampled frames
pv = processor(images=frames, return_tensors="pt")["pixel_values"]   # [T, C, H, W]
video = pv.unsqueeze(0).permute(0, 2, 1, 3, 4).to("cuda")            # [1, C, T, H, W]

gh, gw = video.shape[-2] // PATCH, video.shape[-1] // PATCH
patch_positions = build_patch_positions(num_frames=16, target_frames=64,
                                        grid_h=gh, grid_w=gw)

with torch.no_grad():
    out = model(video, patch_positions=patch_positions)

📤 Outputs#

FieldShapeDescription
last_hidden_state[B, num_patches, 1024]per-patch features after the final layer norm
pooler_output[B, 1024]global feature from the multi-head attention pooling head

📋 Specifications#

ArchitectureCodec-ViT (pre-norm ViT, SigLIP-style MLP)
Parameters~316M
Hidden size / MLP1024 / 4096
Layers / heads24 / 16
Patch size16
Position encodingshared 3D rotary (4:6:6 split over T:H:W)
Poolinglearned-probe multi-head attention head
Pre-training resolutionimages 224–448 (variable), video 256
Weights dtypebfloat16
LicenseMIT

📄 License#

Released under the MIT License.

Files

8 files · 631 MBWeights 631 MB (safetensors). Sizes and sha256 from the signed manifest.
Hide all 8 files with their sha256
FileSizesha256
.gitattributes1.52 KB11ad7efa24975ee4b0c3c3a38ed18737f0658a5f75a0a96787b576a78a023361
README.md6.89 KBcefe2cedb3ffc7f22be10a761a05c5b1f4f69443faac3aa8a3f3fc57da1a4433
__init__.py94 B47736b0d518ef48e763c44c18ddf9e8ae768dda82167ea9e23070a9e0ad4021e
config.json649 B11afdaa18c370c074a7725c8106e4269438a0cafb42fe3544b77dbe688515811
configuration_mage_vit.py4.80 KB328929a97426169140b499a1762f907d8c40df965fa38bd2ae910bd84920e5a9
model.safetensors631 MB7848ad33832ef5a49c58c0d67a83d9269ace91349585e9a797364f8a0c535799
modeling_mage_vit.py23.4 KB6469add145732bb3ca931d822552f498b54a8dee169b868d4b82104ada104f3f
preprocessor_config.json466 Bc72258f294ccec4686ac58a7eb53fcb58f3ba5285e4caa122cbde5743edb8366
VersionsEach time the pinned upstream commit or file list changed in this repo. Newest first.
Upstream commitDateContents
de3bd807f0 pinned now2026-11-15 03:50 UTC8 files · 631 MB

Use it

$ fw get microsoft/Mage-ViT
# manifest sha256 65d7747d860e… · 631 MB · 8 files
$ fw verify ./Mage-ViT microsoft/Mage-ViT
fw.pyChecks the signature and every sha256, tries each source in order, resumes.
$ python3 fw.py get https://freeweights.allternit.com/manifests/microsoft/Mage-ViT.json --dir ./Mage-ViT $ python3 fw.py verify ./Mage-ViT ./microsoft__Mage-ViT.json
hfThe Hugging Face CLI with one setting. Same repo id.
$ HF_ENDPOINT=https://freeweights.allternit.com hf download microsoft/Mage-ViT --revision de3bd807f06fc9e8045540041dad3bf429a1eae7 --local-dir ./Mage-ViT

License

Name
MIT License
Id
MIT
Class
Permissive
Redistribution
yes
Listing
Hosted (signed)
Decided
License as declared by the publisher. No person read it. 2026-11-15
Text in
README.md
Text sha256
cefe2cedb3ffc7f22be10a761a05c5b1f4f69443faac3aa8a3f3fc57da1a4433
Terms gate
No extra terms beyond the license.

Read the license text

Licenses are checked against the license table. A custom license passes only after a person reads it.

Provenance

From: microsoft <huggingface.co/microsoft>Newsgroups: alt.freeweights.visionSubject: Mage-ViTDate: 2026-11-15Commit: de3bd80Signed: 2DC28CC7B26A283B ✓
Upstream
microsoft/Mage-ViT
Pinned commit
de3bd807f06fc9e8045540041dad3bf429a1eae7
Manifest
Mage-ViT.json · .minisig
Manifest sha256
65d7747d860efbc15e79816a8766ffafc8d10082e95289952e89227f067cb840
Signature
minisign, Ed25519, key 2DC28CC7B26A283B
Created
2026-11-15 03:50 UTC
Generator
freeweights-manifest/0.1.0
Takedowns
None.

How to verify

$ curl -O https://freeweights.allternit.com/manifests/microsoft/Mage-ViT.json $ curl -O https://freeweights.allternit.com/manifests/microsoft/Mage-ViT.json.minisig $ minisign -Vm Mage-ViT.json -P RWQ7KGqyx4zCLXtUFOqvfv8L3g+8fpKJ1FsuxPyOYMF+4KufbUxKq1Oq $ shasum -a 256 <file> # compare with the Files tab

A manifest whose signature fails must be rejected. A file whose size or sha256 does not match must be discarded. Verify a download

Model tree

No related models in this catalog.Nothing here lists this model as its parent, and it names no parent.
Get it
Download
$ HF_ENDPOINT=https://freeweights.allternit.com hf download microsoft/Mage-ViT
Open in Freeweights Studio

Pull, verify and run it in the Allternit app on Desktop, web or phone.

Signed manifest
minisign, key 2DC28CC7B26A283B. Mage-ViT.json. Provenance. Takedown history: none.
From: dima806 <huggingface.co/dima806>Subject: ai_vs_real_image_detection
From: legekka <huggingface.co/legekka>Subject: AI-Anime-Image-Detector-ViT
From: onnx-community <huggingface.co/onnx-community>Subject: AI-Anime-Image-Detector-ViT-ONNX
From: AICodexLab <huggingface.co/AICodexLab>Subject: answerdotai-ModernBERT-base-ai-detector
From: onnx-community <huggingface.co/onnx-community>Subject: answerdotai-ModernBERT-base-ai-detector-ONNX
From: onnx-community <huggingface.co/onnx-community>Subject: bart-large-cnn-ONNX