Image-Text-to-Text
Transformers
Safetensors
NemotronH_Nano_VL_V2
feature-extraction
conversational
custom_code
modelopt
Instructions to use pcuenq/nvidia-nano-clone with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pcuenq/nvidia-nano-clone with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="pcuenq/nvidia-nano-clone", 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("pcuenq/nvidia-nano-clone", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use pcuenq/nvidia-nano-clone with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pcuenq/nvidia-nano-clone" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pcuenq/nvidia-nano-clone", "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/pcuenq/nvidia-nano-clone
- SGLang
How to use pcuenq/nvidia-nano-clone 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 "pcuenq/nvidia-nano-clone" \ --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": "pcuenq/nvidia-nano-clone", "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 "pcuenq/nvidia-nano-clone" \ --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": "pcuenq/nvidia-nano-clone", "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 pcuenq/nvidia-nano-clone with Docker Model Runner:
docker model run hf.co/pcuenq/nvidia-nano-clone
| # -------------------------------------------------------- | |
| # Adapted from https://huggingface.co/OpenGVLab/InternVL2-Llama3-76B under MIT License | |
| # LICENSE is in incl_licenses directory. | |
| # -------------------------------------------------------- | |
| from transformers.configuration_utils import PretrainedConfig | |
| from transformers.utils import logging | |
| from .configuration_nemotron_h import NemotronHConfig | |
| from .configuration_radio import RADIOConfig | |
| logger = logging.get_logger(__name__) | |
| class NemotronH_Nano_VL_V2_Config(PretrainedConfig): | |
| model_type = 'NemotronH_Nano_VL_V2' | |
| is_composition = True | |
| def __init__( | |
| self, | |
| vision_config=None, | |
| llm_config=None, | |
| force_image_size=None, | |
| downsample_ratio=0.5, | |
| template=None, | |
| ps_version='v1', | |
| image_tag_type="internvl", | |
| projector_hidden_size=4096, | |
| vit_hidden_size=1280, | |
| attn_implementation="flash_attention_2", | |
| video_pruning_rate: float = 0.0, | |
| **kwargs | |
| ): | |
| super().__init__(**kwargs) | |
| if vision_config is not None: | |
| self.vision_config = RADIOConfig(**vision_config) | |
| else: | |
| self.vision_config = RADIOConfig() | |
| # Handle both cases: when loading from JSON (llm_config is dict) and when called internally by transformers (llm_config is None) | |
| if llm_config is not None: | |
| self.llm_config = NemotronHConfig(**llm_config) | |
| else: | |
| self.llm_config = NemotronHConfig() | |
| # Assign configuration values | |
| self.force_image_size = force_image_size | |
| self.downsample_ratio = downsample_ratio | |
| self.template = template # TODO move out of here and into the tokenizer | |
| self.ps_version = ps_version # Pixel shuffle version | |
| self.image_tag_type = image_tag_type # TODO: into the tokenizer too? | |
| self.projector_hidden_size = projector_hidden_size | |
| self.vit_hidden_size = vit_hidden_size | |
| self.video_pruning_rate = video_pruning_rate | |
| self._attn_implementation = attn_implementation | |
| self.vision_config.use_flash_attn = self._attn_implementation is not None and "flash_attention" in self._attn_implementation | |
| self.llm_config._attn_implementation = self._attn_implementation | |