Image-Text-to-Text
Transformers
Safetensors
English
visionpsynano
feature-extraction
vision-language-model
multimodal
edge
on-device
efficient
low-latency
flash
nanovlm
vqa
conversational
custom_code
Instructions to use qvac/VisionPsy-Nano-460M-Flash with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use qvac/VisionPsy-Nano-460M-Flash with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="qvac/VisionPsy-Nano-460M-Flash", 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 AutoModel model = AutoModel.from_pretrained("qvac/VisionPsy-Nano-460M-Flash", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use qvac/VisionPsy-Nano-460M-Flash with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "qvac/VisionPsy-Nano-460M-Flash" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "qvac/VisionPsy-Nano-460M-Flash", "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/qvac/VisionPsy-Nano-460M-Flash
- SGLang
How to use qvac/VisionPsy-Nano-460M-Flash 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 "qvac/VisionPsy-Nano-460M-Flash" \ --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": "qvac/VisionPsy-Nano-460M-Flash", "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 "qvac/VisionPsy-Nano-460M-Flash" \ --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": "qvac/VisionPsy-Nano-460M-Flash", "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 qvac/VisionPsy-Nano-460M-Flash with Docker Model Runner:
docker model run hf.co/qvac/VisionPsy-Nano-460M-Flash
| import torch.nn as nn | |
| class ModalityProjector(nn.Module): | |
| def __init__(self, cfg): | |
| super().__init__() | |
| self.cfg = cfg | |
| self.input_dim = cfg.vit_hidden_dim * (cfg.mp_pixel_shuffle_factor**2) | |
| self.output_dim = cfg.lm_hidden_dim | |
| self.scale_factor = cfg.mp_pixel_shuffle_factor | |
| self.proj = nn.Linear(self.input_dim, self.output_dim, bias=False) | |
| self.apply(self._init_weights) | |
| def _init_weights(self, module): | |
| if isinstance(module, nn.Linear): | |
| nn.init.normal_(self.proj.weight, mean=0.0, std=0.02) | |
| if module.bias is not None: | |
| nn.init.zeros_(module.bias) | |
| def pixel_shuffle(self, x): | |
| bsz, seq, embed_dim = x.size() | |
| seq_root = int(seq**0.5) | |
| assert seq_root**2 == seq | |
| assert seq_root % self.scale_factor == 0 | |
| height = width = seq_root | |
| x = x.view(bsz, height, width, embed_dim) | |
| h_out = height // self.scale_factor | |
| w_out = width // self.scale_factor | |
| x = x.reshape(bsz, h_out, self.scale_factor, w_out, self.scale_factor, embed_dim) | |
| x = x.permute(0, 1, 3, 2, 4, 5).contiguous() | |
| x = x.reshape(bsz, h_out * w_out, embed_dim * self.scale_factor**2) | |
| return x | |
| def forward(self, x): | |
| x = self.pixel_shuffle(x) | |
| x = self.proj(x) | |
| return x | |