Image-Text-to-Text
Transformers
TensorBoard
Safetensors
multilingual
internvl_chat
feature-extraction
internvl
custom_code
conversational
Instructions to use OpenGVLab/InternVL-Chat-V1-2-Plus with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenGVLab/InternVL-Chat-V1-2-Plus with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenGVLab/InternVL-Chat-V1-2-Plus", 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/InternVL-Chat-V1-2-Plus", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use OpenGVLab/InternVL-Chat-V1-2-Plus with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenGVLab/InternVL-Chat-V1-2-Plus" # 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/InternVL-Chat-V1-2-Plus", "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/InternVL-Chat-V1-2-Plus
- SGLang
How to use OpenGVLab/InternVL-Chat-V1-2-Plus 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/InternVL-Chat-V1-2-Plus" \ --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/InternVL-Chat-V1-2-Plus", "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/InternVL-Chat-V1-2-Plus" \ --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/InternVL-Chat-V1-2-Plus", "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/InternVL-Chat-V1-2-Plus with Docker Model Runner:
docker model run hf.co/OpenGVLab/InternVL-Chat-V1-2-Plus
Update conversation.py
Browse files- conversation.py +0 -43
conversation.py
CHANGED
|
@@ -1241,46 +1241,3 @@ register_conv_template(
|
|
| 1241 |
stop_str='<|endoftext|>',
|
| 1242 |
)
|
| 1243 |
)
|
| 1244 |
-
|
| 1245 |
-
|
| 1246 |
-
if __name__ == '__main__':
|
| 1247 |
-
from fastchat.conversation import get_conv_template
|
| 1248 |
-
|
| 1249 |
-
print('-- Vicuna template --')
|
| 1250 |
-
conv = get_conv_template('vicuna_v1.1')
|
| 1251 |
-
conv.append_message(conv.roles[0], 'Hello!')
|
| 1252 |
-
conv.append_message(conv.roles[1], 'Hi!')
|
| 1253 |
-
conv.append_message(conv.roles[0], 'How are you?')
|
| 1254 |
-
conv.append_message(conv.roles[1], None)
|
| 1255 |
-
print(conv.get_prompt())
|
| 1256 |
-
|
| 1257 |
-
print('\n')
|
| 1258 |
-
|
| 1259 |
-
print('-- Llama-2 template --')
|
| 1260 |
-
conv = get_conv_template('llama-2')
|
| 1261 |
-
conv.set_system_message('You are a helpful, respectful and honest assistant.')
|
| 1262 |
-
conv.append_message(conv.roles[0], 'Hello!')
|
| 1263 |
-
conv.append_message(conv.roles[1], 'Hi!')
|
| 1264 |
-
conv.append_message(conv.roles[0], 'How are you?')
|
| 1265 |
-
conv.append_message(conv.roles[1], None)
|
| 1266 |
-
print(conv.get_prompt())
|
| 1267 |
-
|
| 1268 |
-
print('\n')
|
| 1269 |
-
|
| 1270 |
-
print('-- ChatGPT template --')
|
| 1271 |
-
conv = get_conv_template('chatgpt')
|
| 1272 |
-
conv.append_message(conv.roles[0], 'Hello!')
|
| 1273 |
-
conv.append_message(conv.roles[1], 'Hi!')
|
| 1274 |
-
conv.append_message(conv.roles[0], 'How are you?')
|
| 1275 |
-
conv.append_message(conv.roles[1], None)
|
| 1276 |
-
print(conv.to_openai_api_messages())
|
| 1277 |
-
|
| 1278 |
-
print('\n')
|
| 1279 |
-
|
| 1280 |
-
print('-- Claude template --')
|
| 1281 |
-
conv = get_conv_template('claude')
|
| 1282 |
-
conv.append_message(conv.roles[0], 'Hello!')
|
| 1283 |
-
conv.append_message(conv.roles[1], 'Hi!')
|
| 1284 |
-
conv.append_message(conv.roles[0], 'How are you?')
|
| 1285 |
-
conv.append_message(conv.roles[1], None)
|
| 1286 |
-
print(conv.get_prompt())
|
|
|
|
| 1241 |
stop_str='<|endoftext|>',
|
| 1242 |
)
|
| 1243 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|