Image-Text-to-Text
Transformers
Safetensors
English
Korean
llava_onevision
multimodal
conversational
ncsoft
ncai
varco
Instructions to use NCSOFT/VARCO-VISION-2.0-14B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NCSOFT/VARCO-VISION-2.0-14B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="NCSOFT/VARCO-VISION-2.0-14B") 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 AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("NCSOFT/VARCO-VISION-2.0-14B") model = AutoModelForMultimodalLM.from_pretrained("NCSOFT/VARCO-VISION-2.0-14B", 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 = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use NCSOFT/VARCO-VISION-2.0-14B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NCSOFT/VARCO-VISION-2.0-14B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NCSOFT/VARCO-VISION-2.0-14B", "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/NCSOFT/VARCO-VISION-2.0-14B
- SGLang
How to use NCSOFT/VARCO-VISION-2.0-14B 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 "NCSOFT/VARCO-VISION-2.0-14B" \ --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": "NCSOFT/VARCO-VISION-2.0-14B", "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 "NCSOFT/VARCO-VISION-2.0-14B" \ --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": "NCSOFT/VARCO-VISION-2.0-14B", "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 NCSOFT/VARCO-VISION-2.0-14B with Docker Model Runner:
docker model run hf.co/NCSOFT/VARCO-VISION-2.0-14B
Update README.md
Browse files
README.md
CHANGED
|
@@ -121,8 +121,8 @@ conversation = [
|
|
| 121 |
{
|
| 122 |
"role": "user",
|
| 123 |
"content": [
|
| 124 |
-
{"type": "image", "url": "https://huggingface.co/
|
| 125 |
-
{"type": "text", "text": "์ด ์ด๋ฏธ์ง์
|
| 126 |
],
|
| 127 |
},
|
| 128 |
]
|
|
@@ -135,45 +135,86 @@ inputs = processor.apply_chat_template(
|
|
| 135 |
return_tensors="pt"
|
| 136 |
).to(model.device, torch.float16)
|
| 137 |
|
| 138 |
-
generate_ids = model.generate(**inputs, max_new_tokens=1024
|
| 139 |
-
|
| 140 |
-
|
|
|
|
|
|
|
|
|
|
| 141 |
```
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
| 143 |
```python
|
| 144 |
-
# INPUT
|
| 145 |
-
image_file = "./assets/ocr.jpg"
|
| 146 |
-
raw_image = Image.open(image_file)
|
| 147 |
conversation = [
|
| 148 |
{
|
| 149 |
"role": "user",
|
| 150 |
"content": [
|
| 151 |
-
{"type": "
|
| 152 |
-
{"type": "image"},
|
|
|
|
| 153 |
],
|
| 154 |
},
|
| 155 |
]
|
| 156 |
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
<char>์ธ์ฒ๋๊ณต์</char><bbox>0.43, 0.621, 0.609, 0.684</bbox>
|
| 172 |
-
<char>๋ชจ๋๋ด์์ฅ์ญ</char><bbox>0.651, 0.59, 0.873, 0.665</bbox>
|
| 173 |
-
<char>IncheonGrand</char><bbox>0.432, 0.681, 0.561, 0.723</bbox>
|
| 174 |
-
<char>Park</char><bbox>0.564, 0.681, 0.611, 0.723</bbox>
|
| 175 |
-
"""
|
| 176 |
```
|
| 177 |
-
<
|
| 178 |
-
|
| 179 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
{
|
| 122 |
"role": "user",
|
| 123 |
"content": [
|
| 124 |
+
{"type": "image", "url": "https://huggingface.co/NCSOFT/VARCO-VISION-2.0-14B/resolve/main/demo.jpg"},
|
| 125 |
+
{"type": "text", "text": "์ด ์ด๋ฏธ์ง์ ํ์๋ ๊ฒ์ ๋ฌด์์ธ๊ฐ์?"},
|
| 126 |
],
|
| 127 |
},
|
| 128 |
]
|
|
|
|
| 135 |
return_tensors="pt"
|
| 136 |
).to(model.device, torch.float16)
|
| 137 |
|
| 138 |
+
generate_ids = model.generate(**inputs, max_new_tokens=1024)
|
| 139 |
+
generate_ids_trimmed = [
|
| 140 |
+
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generate_ids)
|
| 141 |
+
]
|
| 142 |
+
output = processor.decode(generate_ids_trimmed[0], skip_special_tokens=True)
|
| 143 |
+
print(output)
|
| 144 |
```
|
| 145 |
+
|
| 146 |
+
<details>
|
| 147 |
+
<summary>Multi image inference</summary>
|
| 148 |
+
|
| 149 |
```python
|
|
|
|
|
|
|
|
|
|
| 150 |
conversation = [
|
| 151 |
{
|
| 152 |
"role": "user",
|
| 153 |
"content": [
|
| 154 |
+
{"type": "image", "image": "file:///path/to/image1.jpg"},
|
| 155 |
+
{"type": "image", "image": "file:///path/to/image2.jpg"},
|
| 156 |
+
{"type": "text", "text": "์ด๋ฏธ์ง ๊ฐ์ ์ ์ฌ์ ์ ํ์
ํ์ธ์."},
|
| 157 |
],
|
| 158 |
},
|
| 159 |
]
|
| 160 |
|
| 161 |
+
inputs = processor.apply_chat_template(
|
| 162 |
+
conversation,
|
| 163 |
+
add_generation_prompt=True,
|
| 164 |
+
tokenize=True,
|
| 165 |
+
return_dict=True,
|
| 166 |
+
return_tensors="pt"
|
| 167 |
+
).to(model.device, torch.float16)
|
| 168 |
+
|
| 169 |
+
generate_ids = model.generate(**inputs, max_new_tokens=1024)
|
| 170 |
+
generate_ids_trimmed = [
|
| 171 |
+
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generate_ids)
|
| 172 |
+
]
|
| 173 |
+
output = processor.decode(generate_ids_trimmed[0], skip_special_tokens=True)
|
| 174 |
+
print(output)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
```
|
| 176 |
+
</details>
|
| 177 |
+
|
| 178 |
+
<details>
|
| 179 |
+
<summary>OCR inference</summary>
|
| 180 |
+
|
| 181 |
+
```python
|
| 182 |
+
from PIL import Image
|
| 183 |
+
|
| 184 |
+
image = Image.open("file:///path/to/image.jpg")
|
| 185 |
+
|
| 186 |
+
# Image upscaling for OCR performance boost
|
| 187 |
+
w, h = image.size
|
| 188 |
+
target_size = 2304
|
| 189 |
+
if max(w, h) < target_size:
|
| 190 |
+
scaling_factor = target_size / max(w, h)
|
| 191 |
+
new_w = int(w * scaling_factor)
|
| 192 |
+
new_h = int(h * scaling_factor)
|
| 193 |
+
image = image.resize((new_w, new_h))
|
| 194 |
+
|
| 195 |
+
conversation = [
|
| 196 |
+
{
|
| 197 |
+
"role": "user",
|
| 198 |
+
"content": [
|
| 199 |
+
{"type": "image", "image": image},
|
| 200 |
+
{"type": "text", "text": "<ocr>"},
|
| 201 |
+
],
|
| 202 |
+
},
|
| 203 |
+
]
|
| 204 |
+
|
| 205 |
+
inputs = processor.apply_chat_template(
|
| 206 |
+
conversation,
|
| 207 |
+
add_generation_prompt=True,
|
| 208 |
+
tokenize=True,
|
| 209 |
+
return_dict=True,
|
| 210 |
+
return_tensors="pt"
|
| 211 |
+
).to(model.device, torch.float16)
|
| 212 |
+
|
| 213 |
+
generate_ids = model.generate(**inputs, max_new_tokens=1024)
|
| 214 |
+
generate_ids_trimmed = [
|
| 215 |
+
out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generate_ids)
|
| 216 |
+
]
|
| 217 |
+
output = processor.decode(generate_ids_trimmed[0], skip_special_tokens=False)
|
| 218 |
+
print(output)
|
| 219 |
+
```
|
| 220 |
+
</details>
|