Image Feature Extraction
Transformers
Safetensors
mimo26_vision
feature-extraction
vision
mimo
custom_code
Instructions to use immanuelpeter/MiMoViT-2.6-Pro with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use immanuelpeter/MiMoViT-2.6-Pro with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-feature-extraction", model="immanuelpeter/MiMoViT-2.6-Pro", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("immanuelpeter/MiMoViT-2.6-Pro", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download examples/inference.py from immanuelpeter/MiMoViT-2.6-Pro: direct link, hf CLI and curl.
- Browser
- Download file 1.09 kB
-
https://huggingface.co/immanuelpeter/MiMoViT-2.6-Pro/resolve/main/examples/inference.py
- Command line
-
hf download hf://immanuelpeter/MiMoViT-2.6-Pro/examples/inference.py
-
curl -L -o inference.py https://huggingface.co/immanuelpeter/MiMoViT-2.6-Pro/resolve/main/examples/inference.py
1.09 kB
| import argparse | |
| from pathlib import Path | |
| from PIL import Image | |
| import torch | |
| from transformers import AutoImageProcessor, AutoModel | |
| MODEL_ID = "immanuelpeter/MiMoViT-2.6-Pro" | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description="Extract MiMo 2.6 Pro visual features.") | |
| parser.add_argument("image", type=Path) | |
| parser.add_argument("--model", default=MODEL_ID) | |
| args = parser.parse_args() | |
| device = torch.device("cuda" if torch.cuda.is_available() else "cpu") | |
| dtype = torch.bfloat16 if device.type == "cuda" else torch.float32 | |
| processor = AutoImageProcessor.from_pretrained(args.model) | |
| model = AutoModel.from_pretrained(args.model, trust_remote_code=True, dtype=dtype).to(device).eval() | |
| inputs = processor(images=Image.open(args.image).convert("RGB"), return_tensors="pt") | |
| with torch.inference_mode(): | |
| projected = model(inputs["pixel_values"].to(device, dtype), inputs["image_grid_thw"]) | |
| print("grid_thw", inputs["image_grid_thw"].tolist()) | |
| print("projected", tuple(projected.shape)) | |
| if __name__ == "__main__": | |
| main() | |