Instructions to use KamilaMila/FastVLM-0.5B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use KamilaMila/FastVLM-0.5B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="KamilaMila/FastVLM-0.5B") 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 AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("KamilaMila/FastVLM-0.5B") model = AutoModelForMultimodalLM.from_pretrained("KamilaMila/FastVLM-0.5B", device_map="auto") 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?"} ] }, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use KamilaMila/FastVLM-0.5B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "KamilaMila/FastVLM-0.5B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "KamilaMila/FastVLM-0.5B", "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/KamilaMila/FastVLM-0.5B
- SGLang
How to use KamilaMila/FastVLM-0.5B 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 "KamilaMila/FastVLM-0.5B" \ --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": "KamilaMila/FastVLM-0.5B", "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 "KamilaMila/FastVLM-0.5B" \ --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": "KamilaMila/FastVLM-0.5B", "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 KamilaMila/FastVLM-0.5B with Docker Model Runner:
docker model run hf.co/KamilaMila/FastVLM-0.5B
| { | |
| "architectures": [ | |
| "FastVlmForConditionalGeneration" | |
| ], | |
| "dtype": "bfloat16", | |
| "image_seq_length": 256, | |
| "image_token_index": 151646, | |
| "model_type": "fast_vlm", | |
| "multimodal_projector_bias": true, | |
| "projector_hidden_act": "gelu", | |
| "text_config": { | |
| "_name_or_path": "Qwen/Qwen2-0.5B", | |
| "architectures": [ | |
| "Qwen2ForCausalLM" | |
| ], | |
| "attention_dropout": 0.0, | |
| "bos_token_id": 151643, | |
| "dtype": "bfloat16", | |
| "eos_token_id": 151643, | |
| "hidden_act": "silu", | |
| "hidden_size": 896, | |
| "initializer_range": 0.02, | |
| "intermediate_size": 4864, | |
| "layer_types": [ | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention", | |
| "full_attention" | |
| ], | |
| "max_position_embeddings": 131072, | |
| "max_window_layers": 24, | |
| "model_type": "qwen2", | |
| "num_attention_heads": 14, | |
| "num_hidden_layers": 24, | |
| "num_key_value_heads": 2, | |
| "rms_norm_eps": 1e-06, | |
| "rope_scaling": null, | |
| "rope_theta": 1000000.0, | |
| "sliding_window": null, | |
| "tie_word_embeddings": true, | |
| "use_cache": true, | |
| "use_sliding_window": false, | |
| "vocab_size": 152000 | |
| }, | |
| "transformers_version": "4.56.0.dev0", | |
| "vision_config": { | |
| "_name_or_path": "timm/fastvit_mci3.apple_mclip2_dfndr2b", | |
| "architecture": "fastvit_mci3", | |
| "do_pooling": true, | |
| "global_pool": "avg", | |
| "hidden_size": 3072, | |
| "initializer_range": 0.02, | |
| "label_names": [], | |
| "model_args": { | |
| "inference_mode": true | |
| }, | |
| "model_type": "timm_wrapper", | |
| "num_classes": 0, | |
| "num_features": 3072, | |
| "pretrained_cfg": { | |
| "classifier": "head.fc", | |
| "crop_mode": "center", | |
| "crop_pct": 0.95, | |
| "custom_load": false, | |
| "first_conv": [ | |
| "stem.0.conv_kxk.0.conv", | |
| "stem.0.conv_scale.conv" | |
| ], | |
| "fixed_input_size": false, | |
| "input_size": [ | |
| 3, | |
| 256, | |
| 256 | |
| ], | |
| "interpolation": "bicubic", | |
| "license": "apple-amlr", | |
| "mean": [ | |
| 0.48145466, | |
| 0.4578275, | |
| 0.40821073 | |
| ], | |
| "pool_size": [ | |
| 8, | |
| 8 | |
| ], | |
| "std": [ | |
| 0.26862954, | |
| 0.26130258, | |
| 0.27577711 | |
| ], | |
| "tag": "apple_mclip2_dfndr2b" | |
| } | |
| }, | |
| "vision_feature_layer": -1, | |
| "vision_feature_select_strategy": "full" | |
| } | |