Views
No views yet
| Attribute | Specification |
|---|---|
| Parameters | ~0.4B |
| Architecture | 27-layer ViT · 1024 hidden · 12 heads · 1536 QKV dim |
| Patch Size | 14 × 14 |
| Token Compression | 2×2 pixel-shuffle + temporal pooling |
| Max Resolution | ~3584 × 3584 |
| Initialization | From scratch (not SigLIP) |
| Source Model | moonshotai/Kimi-K3 |
| Technical Report | Kimi K3 (arXiv:2607.24653) |
1import torch
2from transformers import AutoModel, AutoImageProcessor
3
4model_id = "AI4Industry/MoonViT-V2"
5
6model = AutoModel.from_pretrained(
7 model_id,
8 dtype=torch.bfloat16,
9 trust_remote_code=True,
10)
11processor = AutoImageProcessor.from_pretrained(model_id, trust_remote_code=True)
12
13device = "cuda" if torch.cuda.is_available() else "cpu"
14model = model.to(device)1from PIL import Image
2
3image = Image.open("your_image.png").convert("RGB")
4inputs = processor(image, return_tensors="pt") # T=1
5pixel_values = inputs["pixel_values"].to(device=device, dtype=model.dtype)
6grid_thws = inputs["grid_thws"].to(device=device)
7
8with torch.no_grad():
9 image_features = model(pixel_values, grid_thws)
10
11print(image_features[0].dtype, image_features[0].shape)
12# e.g. torch.bfloat16, torch.Size([N, 4, 1024])T must be ≤ max_num_frames (default 4, matching temporal position embedding).1from PIL import Image
2
3frames = [
4 Image.open("frame_0.png").convert("RGB"),
5 Image.open("frame_1.png").convert("RGB"),
6 Image.open("frame_2.png").convert("RGB"),
7 Image.open("frame_3.png").convert("RGB"),
8]
9inputs = processor.preprocess_video(frames, return_tensors="pt") # T=len(frames)
10pixel_values = inputs["pixel_values"].to(device=device, dtype=model.dtype)
11grid_thws = inputs["grid_thws"].to(device=device) # [[T, H_patches, W_patches]]
12
13with torch.no_grad():
14 video_features = model(pixel_values, grid_thws)
15
16print(grid_thws.tolist(), video_features[0].shape)
17# e.g. [[4, H, W]], torch.Size([N, 4, 1024]) # N after temporal pool + 2×2 mergepixel_values: packed patches (num_patches, 3, 14, 14)grid_thws: (batch, 3) = (T, H_patches, W_patches); images use T=1(0.5, 0.5, 0.5)attn_implementation="flash_attention_2" if FlashAttention-2 is installed (default is SDPA)bfloat16) are taken from model-00096-of-000096.safetensors in moonshotai/Kimi-K3.| Original Kimi K3 Prefix | This Repo |
|---|---|
vision_tower.* | * (prefix stripped) |
mm_projector.* | omitted |
language_model.* | omitted |