Initial release
Browse filesCo-authored-by: meta-bot <meta-bot@users.noreply.huggingface.co>
- .gitattributes +35 -0
- MoEViE-H14-448.pt +3 -0
- README.md +108 -0
- config.yaml +24 -0
.gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
MoEViE-H14-448.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:43ed30ed9e53c981a5a67157e0b34a1449ed70912a143fec3f8ac28d0e1d328c
|
| 3 |
+
size 17520115545
|
README.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-4.0
|
| 3 |
+
library_name: moe_vie
|
| 4 |
+
pipeline_tag: zero-shot-image-classification
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# Model Details
|
| 8 |
+
|
| 9 |
+
[\[๐ Paper\]](https://arxiv.org/abs/2608.17402)
|
| 10 |
+
[\[๐ GitHub\]](https://github.com/facebookresearch/moe_vie)
|
| 11 |
+
|
| 12 |
+
MoE-ViE is a family of **Mixture-of-Experts vision encoders** for image and video
|
| 13 |
+
understanding, trained with a contrastive vision-language recipe. Each MoE block keeps a
|
| 14 |
+
shared always-on expert alongside a routed pool, so only a small fraction of the weights is
|
| 15 |
+
used for any given token.
|
| 16 |
+
|
| 17 |
+
**Model Developer**: Meta
|
| 18 |
+
|
| 19 |
+
**This checkpoint**: `MoEViE-H14-448` โ H/14 at 448px.
|
| 20 |
+
|
| 21 |
+
## Model Configurations
|
| 22 |
+
|
| 23 |
+
MoE-ViE comes in three sizes. Only `active` experts run per token, so the activated
|
| 24 |
+
parameter count is far below the total.
|
| 25 |
+
|
| 26 |
+
| Scale | Width | Depth | Experts (active/total) | Total params | Activated params | Resolution |
|
| 27 |
+
|:--:|:--:|:--:|:--:|:--:|:--:|:--:|
|
| 28 |
+
| **B/16** | 768 | 12 | 4 / 32 | 0.5B | 0.1B | 224px |
|
| 29 |
+
| **L/16** | 1024 | 24 | 4 / 32 | 1.7B | 0.3B | 384px |
|
| 30 |
+
| **H/14** | 1280 | 32 | 8 / 32 | 3.5B | 1.1B | 448px |
|
| 31 |
+
|
| 32 |
+
Every MoE block has **1 shared expert that is always active** plus a routed pool; the
|
| 33 |
+
`active/total` column counts the shared expert. Routing is per-token top-k on a sigmoid gate.
|
| 34 |
+
|
| 35 |
+
## Model Performance
|
| 36 |
+
|
| 37 |
+
Zero-shot results. Top-1 accuracy (%) for classification, recall@1 (%) for retrieval.
|
| 38 |
+
|
| 39 |
+
| Model | Checkpoint | IN-1k | ObjectNet | COCO-T2I | Kinetics-400 | MSR-VTT-T2V |
|
| 40 |
+
|:--:|:--:|:--:|:--:|:--:|:--:|:--:|
|
| 41 |
+
| **B/16** 224px | [MoEViE-B16-224](https://huggingface.co/facebook/MoEViE-B16-224) | 79.3 | 74.4 | 52.1 | 68.3 | 47.9 |
|
| 42 |
+
| **L/16** 384px | [MoEViE-L16-384](https://huggingface.co/facebook/MoEViE-L16-384) | 83.6 | 85.0 | 57.2 | 74.5 | 50.5 |
|
| 43 |
+
| **H/14** 448px | [MoEViE-H14-448](https://huggingface.co/facebook/MoEViE-H14-448) | 85.1 | 87.0 | 56.8 | 76.9 | 51.6 |
|
| 44 |
+
|
| 45 |
+
# How to use
|
| 46 |
+
|
| 47 |
+
## Install
|
| 48 |
+
|
| 49 |
+
```bash
|
| 50 |
+
git clone https://github.com/facebookresearch/moe_vie
|
| 51 |
+
cd moe_vie
|
| 52 |
+
pip install -r requirements.txt
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
Requires a **CUDA GPU** โ the Mixture-of-Experts kernels are compiled with Triton at runtime.
|
| 56 |
+
|
| 57 |
+
## Image and text feature extraction
|
| 58 |
+
|
| 59 |
+
```python
|
| 60 |
+
import torch
|
| 61 |
+
from PIL import Image
|
| 62 |
+
from open_clip import create_model_and_transforms, get_tokenizer, image_to_device
|
| 63 |
+
|
| 64 |
+
MEAN, STD = (0.5, 0.5, 0.5), (0.5, 0.5, 0.5)
|
| 65 |
+
|
| 66 |
+
model, _, preprocess = create_model_and_transforms(
|
| 67 |
+
"MoEViE-H14-448",
|
| 68 |
+
pretrained=True, # downloads from the Hub
|
| 69 |
+
force_preprocess_cfg=dict(
|
| 70 |
+
patch_size=14, size_range=(448, 448), center_crop=True, window_size=1
|
| 71 |
+
),
|
| 72 |
+
image_mean=MEAN, image_std=STD,
|
| 73 |
+
)
|
| 74 |
+
model = model.cuda().eval()
|
| 75 |
+
tokenizer = get_tokenizer("MoEViE-H14-448")
|
| 76 |
+
|
| 77 |
+
labels = ["a diagram", "a dog", "a cat"]
|
| 78 |
+
packed, _ = preprocess.collate_fn([(preprocess(Image.open("cat.png").convert("RGB")), 0)])
|
| 79 |
+
packed = image_to_device(packed, "cuda", torch.float32, mean=MEAN, std=STD)
|
| 80 |
+
text = tokenizer(labels).cuda()
|
| 81 |
+
|
| 82 |
+
with torch.no_grad(), torch.autocast("cuda"):
|
| 83 |
+
image_features = model.encode_image(packed, normalize=True)
|
| 84 |
+
text_features = model.encode_text(text, normalize=True)
|
| 85 |
+
probs = (model.logit_scale.exp() * image_features @ text_features.T).softmax(dim=-1)
|
| 86 |
+
|
| 87 |
+
print("Label probs:", probs)
|
| 88 |
+
```
|
| 89 |
+
|
| 90 |
+
See [`demo/demo.py`](https://github.com/facebookresearch/moe_vie/blob/main/demo/demo.py) and the repository README for the
|
| 91 |
+
zero-shot evaluation suite.
|
| 92 |
+
|
| 93 |
+
# License
|
| 94 |
+
|
| 95 |
+
Released under **CC BY-NC 4.0** โ non-commercial research use.
|
| 96 |
+
|
| 97 |
+
# Citation
|
| 98 |
+
|
| 99 |
+
If you find this work useful, please cite:
|
| 100 |
+
|
| 101 |
+
```bibtex
|
| 102 |
+
@article{zhang2026moevie,
|
| 103 |
+
title={MoE-ViE: Mixture of Experts Vision Encoder for Efficient Image and Video Understanding},
|
| 104 |
+
author={Bonan Zhang and Shiyu Dong and Quan Hung Tran and Katharina Gschwind and Shuqi Yang and Sijia Chen and Adel Ahmadyan and Seungwhan Moon and Lu Zhang and Ahmed Kirmani and Babak Damavandi and Anuj Kumar},
|
| 105 |
+
journal={arXiv preprint arXiv:2608.17402},
|
| 106 |
+
year={2026}
|
| 107 |
+
}
|
| 108 |
+
```
|
config.yaml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
embed_dim: 1024
|
| 2 |
+
quick_gelu: false
|
| 3 |
+
vision_cfg:
|
| 4 |
+
global_layers: -1
|
| 5 |
+
relative_pos_embed_type: rope_2d
|
| 6 |
+
attn_pooler_heads: 16
|
| 7 |
+
use_ln_post: false
|
| 8 |
+
layers: 32
|
| 9 |
+
width: 1280
|
| 10 |
+
head_width: 80
|
| 11 |
+
patch_size: 14
|
| 12 |
+
mixture_of_expert: true
|
| 13 |
+
num_of_expert: 8
|
| 14 |
+
split: 4
|
| 15 |
+
k: 2
|
| 16 |
+
moe_layers: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]
|
| 17 |
+
text_cfg:
|
| 18 |
+
context_length: 144
|
| 19 |
+
vocab_size: 49408
|
| 20 |
+
width: 1408
|
| 21 |
+
mlp_ratio: 4
|
| 22 |
+
heads: 16
|
| 23 |
+
layers: 34
|
| 24 |
+
use_ln_post: false
|