Image-Text-to-Text
Transformers
Safetensors
multilingual
internvl_chat
feature-extraction
internvl
custom_code
conversational
Instructions to use OpenGVLab/InternVL2-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenGVLab/InternVL2-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenGVLab/InternVL2-8B", 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("OpenGVLab/InternVL2-8B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OpenGVLab/InternVL2-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenGVLab/InternVL2-8B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "OpenGVLab/InternVL2-8B", "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/OpenGVLab/InternVL2-8B
- SGLang
How to use OpenGVLab/InternVL2-8B 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 "OpenGVLab/InternVL2-8B" \ --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": "OpenGVLab/InternVL2-8B", "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 "OpenGVLab/InternVL2-8B" \ --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": "OpenGVLab/InternVL2-8B", "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 OpenGVLab/InternVL2-8B with Docker Model Runner:
docker model run hf.co/OpenGVLab/InternVL2-8B
Upload folder using huggingface_hub
Browse files- README.md +5 -0
- configuration_intern_vit.py +1 -1
README.md
CHANGED
|
@@ -144,6 +144,7 @@ model = AutoModel.from_pretrained(
|
|
| 144 |
path,
|
| 145 |
torch_dtype=torch.bfloat16,
|
| 146 |
low_cpu_mem_usage=True,
|
|
|
|
| 147 |
trust_remote_code=True).eval().cuda()
|
| 148 |
```
|
| 149 |
|
|
@@ -158,6 +159,7 @@ model = AutoModel.from_pretrained(
|
|
| 158 |
torch_dtype=torch.bfloat16,
|
| 159 |
load_in_8bit=True,
|
| 160 |
low_cpu_mem_usage=True,
|
|
|
|
| 161 |
trust_remote_code=True).eval()
|
| 162 |
```
|
| 163 |
|
|
@@ -172,6 +174,7 @@ model = AutoModel.from_pretrained(
|
|
| 172 |
torch_dtype=torch.bfloat16,
|
| 173 |
load_in_4bit=True,
|
| 174 |
low_cpu_mem_usage=True,
|
|
|
|
| 175 |
trust_remote_code=True).eval()
|
| 176 |
```
|
| 177 |
|
|
@@ -216,6 +219,7 @@ model = AutoModel.from_pretrained(
|
|
| 216 |
path,
|
| 217 |
torch_dtype=torch.bfloat16,
|
| 218 |
low_cpu_mem_usage=True,
|
|
|
|
| 219 |
trust_remote_code=True,
|
| 220 |
device_map=device_map).eval()
|
| 221 |
```
|
|
@@ -311,6 +315,7 @@ model = AutoModel.from_pretrained(
|
|
| 311 |
path,
|
| 312 |
torch_dtype=torch.bfloat16,
|
| 313 |
low_cpu_mem_usage=True,
|
|
|
|
| 314 |
trust_remote_code=True).eval().cuda()
|
| 315 |
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True, use_fast=False)
|
| 316 |
|
|
|
|
| 144 |
path,
|
| 145 |
torch_dtype=torch.bfloat16,
|
| 146 |
low_cpu_mem_usage=True,
|
| 147 |
+
use_flash_attn=False,
|
| 148 |
trust_remote_code=True).eval().cuda()
|
| 149 |
```
|
| 150 |
|
|
|
|
| 159 |
torch_dtype=torch.bfloat16,
|
| 160 |
load_in_8bit=True,
|
| 161 |
low_cpu_mem_usage=True,
|
| 162 |
+
use_flash_attn=False,
|
| 163 |
trust_remote_code=True).eval()
|
| 164 |
```
|
| 165 |
|
|
|
|
| 174 |
torch_dtype=torch.bfloat16,
|
| 175 |
load_in_4bit=True,
|
| 176 |
low_cpu_mem_usage=True,
|
| 177 |
+
use_flash_attn=False,
|
| 178 |
trust_remote_code=True).eval()
|
| 179 |
```
|
| 180 |
|
|
|
|
| 219 |
path,
|
| 220 |
torch_dtype=torch.bfloat16,
|
| 221 |
low_cpu_mem_usage=True,
|
| 222 |
+
use_flash_attn=False,
|
| 223 |
trust_remote_code=True,
|
| 224 |
device_map=device_map).eval()
|
| 225 |
```
|
|
|
|
| 315 |
path,
|
| 316 |
torch_dtype=torch.bfloat16,
|
| 317 |
low_cpu_mem_usage=True,
|
| 318 |
+
use_flash_attn=False,
|
| 319 |
trust_remote_code=True).eval().cuda()
|
| 320 |
tokenizer = AutoTokenizer.from_pretrained(path, trust_remote_code=True, use_fast=False)
|
| 321 |
|
configuration_intern_vit.py
CHANGED
|
@@ -71,7 +71,7 @@ class InternVisionConfig(PretrainedConfig):
|
|
| 71 |
intermediate_size=12800,
|
| 72 |
qk_normalization=True,
|
| 73 |
num_hidden_layers=48,
|
| 74 |
-
use_flash_attn=
|
| 75 |
hidden_act='gelu',
|
| 76 |
norm_type='rms_norm',
|
| 77 |
layer_norm_eps=1e-6,
|
|
|
|
| 71 |
intermediate_size=12800,
|
| 72 |
qk_normalization=True,
|
| 73 |
num_hidden_layers=48,
|
| 74 |
+
use_flash_attn=False,
|
| 75 |
hidden_act='gelu',
|
| 76 |
norm_type='rms_norm',
|
| 77 |
layer_norm_eps=1e-6,
|