Instructions to use apple/FastVLM-0.5B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use apple/FastVLM-0.5B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="apple/FastVLM-0.5B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("apple/FastVLM-0.5B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use apple/FastVLM-0.5B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "apple/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": "apple/FastVLM-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/apple/FastVLM-0.5B
- SGLang
How to use apple/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 "apple/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": "apple/FastVLM-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "apple/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": "apple/FastVLM-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use apple/FastVLM-0.5B with Docker Model Runner:
docker model run hf.co/apple/FastVLM-0.5B
Explicit vision_config
Browse files- config.json +20 -1
config.json
CHANGED
|
@@ -45,5 +45,24 @@
|
|
| 45 |
"use_cache": true,
|
| 46 |
"use_mm_proj": true,
|
| 47 |
"use_sliding_window": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
"vocab_size": 151936
|
| 49 |
-
}
|
|
|
|
| 45 |
"use_cache": true,
|
| 46 |
"use_mm_proj": true,
|
| 47 |
"use_sliding_window": false,
|
| 48 |
+
"vision_config": {
|
| 49 |
+
"cls_ratio": 2.0,
|
| 50 |
+
"down_patch_size": 7,
|
| 51 |
+
"down_stride": 2,
|
| 52 |
+
"downsamples": [true, true, true, true, true],
|
| 53 |
+
"embed_dims": [96, 192, 384, 768, 1536],
|
| 54 |
+
"hidden_size": 1024,
|
| 55 |
+
"image_size": 1024,
|
| 56 |
+
"intermediate_size": 3072,
|
| 57 |
+
"layer_scale_init_value": 1e-5,
|
| 58 |
+
"layers": [2, 12, 24, 4, 2],
|
| 59 |
+
"mlp_ratios": [4, 4, 4, 4, 4],
|
| 60 |
+
"num_classes": 1000,
|
| 61 |
+
"patch_size": 64,
|
| 62 |
+
"pos_embs_shapes": [null, null, null, [7, 7], [7, 7]],
|
| 63 |
+
"projection_dim": 768,
|
| 64 |
+
"repmixer_kernel_size": 3,
|
| 65 |
+
"token_mixers": ["repmixer", "repmixer", "repmixer", "attention", "attention"]
|
| 66 |
+
},
|
| 67 |
"vocab_size": 151936
|
| 68 |
+
}
|