Image-Text-to-Text
Transformers
Safetensors
mage_vl
multimodal
vision-language-model
mage-vl
video-understanding
streaming
conversational
custom_code
Instructions to use microsoft/Mage-VL with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use microsoft/Mage-VL with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="microsoft/Mage-VL", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoModelForImageTextToText model = AutoModelForImageTextToText.from_pretrained("microsoft/Mage-VL", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use microsoft/Mage-VL with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "microsoft/Mage-VL" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/Mage-VL", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/microsoft/Mage-VL
- SGLang
How to use microsoft/Mage-VL with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "microsoft/Mage-VL" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/Mage-VL", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "microsoft/Mage-VL" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "microsoft/Mage-VL", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use microsoft/Mage-VL with Docker Model Runner:
docker model run hf.co/microsoft/Mage-VL
| // Copyright (c) Microsoft Corporation. | |
| // Licensed under the MIT License. | |
| PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) | |
| { | |
| m.def("process_with_mask_cuda", &process_with_mask_cuda); | |
| m.def("combine_for_reading_2x_cuda", &combine_for_reading_2x_cuda); | |
| m.def("restore_y_2x_cuda", &restore_y_2x_cuda); | |
| m.def("restore_y_4x_cuda", &restore_y_4x_cuda); | |
| m.def("build_index_dec_cuda", &build_index_dec_cuda); | |
| m.def("build_index_enc_cuda", &build_index_enc_cuda); | |
| m.def("bias_quant_cuda", &bias_quant_cuda); | |
| m.def("round_and_to_int8_cuda", &round_and_to_int8_cuda); | |
| m.def("clamp_reciprocal_with_quant_cuda", &clamp_reciprocal_with_quant_cuda); | |
| m.def("add_and_multiply_cuda", &add_and_multiply_cuda); | |
| m.def("bias_pixel_shuffle_8_cuda", &bias_pixel_shuffle_8_cuda); | |
| m.def("replicate_pad_cuda", &replicate_pad_cuda); | |
| m.def("bias_wsilu_depthwise_conv2d_cuda", &bias_wsilu_depthwise_conv2d_cuda); | |
| py::class_<DepthConvProxy>(m, "DepthConvProxy") | |
| .def(py::init<>()) | |
| .def("set_param", &DepthConvProxy::set_param) | |
| .def("set_param_with_adaptor", &DepthConvProxy::set_param_with_adaptor) | |
| .def("forward", &DepthConvProxy::forward) | |
| .def("forward_with_quant_step", &DepthConvProxy::forward_with_quant_step) | |
| .def("forward_with_cat", &DepthConvProxy::forward_with_cat); | |
| py::class_<SubpelConv2xProxy>(m, "SubpelConv2xProxy") | |
| .def(py::init<>()) | |
| .def("set_param", &SubpelConv2xProxy::set_param) | |
| .def("forward", &SubpelConv2xProxy::forward) | |
| .def("forward_with_cat", &SubpelConv2xProxy::forward_with_cat); | |
| } | |