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)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("OpenGVLab/InternVL-Chat-V1-2-Plus", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- 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
Upload folder using huggingface_hub
Browse files- README.md +14 -3
- configuration_internvl_chat.py +2 -2
- modeling_intern_vit.py +1 -0
README.md
CHANGED
|
@@ -5,6 +5,7 @@ library_name: transformers
|
|
| 5 |
base_model:
|
| 6 |
- OpenGVLab/InternViT-6B-448px-V1-2
|
| 7 |
- NousResearch/Nous-Hermes-2-Yi-34B
|
|
|
|
| 8 |
base_model_relation: merge
|
| 9 |
language:
|
| 10 |
- multilingual
|
|
@@ -19,10 +20,14 @@ tags:
|
|
| 19 |
|
| 20 |
# InternVL-Chat-V1-2-Plus
|
| 21 |
|
| 22 |
-
[\[π GitHub\]](https://github.com/OpenGVLab/InternVL) [\[π Blog\]](https://internvl.github.io/blog/) [\[π InternVL 1.0
|
| 23 |
|
| 24 |
[\[π¨οΈ Chat Demo\]](https://internvl.opengvlab.com/) [\[π€ HF Demo\]](https://huggingface.co/spaces/OpenGVLab/InternVL) [\[π Quick Start\]](#quick-start) [\[π δΈζθ§£θ―»\]](https://zhuanlan.zhihu.com/p/706547971) [\[π Documents\]](https://internvl.readthedocs.io/en/latest/)
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
## Introduction
|
| 27 |
|
| 28 |
InternVL-Chat-V1-2-Plus uses the same model architecture as [InternVL-Chat-V1-2](https://huggingface.co/OpenGVLab/InternVL-Chat-V1-2), but the difference lies in the SFT dataset. InternVL-Chat-V1-2 only utilizes an SFT dataset with 1.2M samples, while **our plus version employs an SFT dataset with 12M samples**.
|
|
@@ -77,7 +82,7 @@ We provide an example code to run InternVL-Chat-V1-2-Plus using `transformers`.
|
|
| 77 |
|
| 78 |
We also welcome you to experience the InternVL2 series models in our [online demo](https://internvl.opengvlab.com/).
|
| 79 |
|
| 80 |
-
> Please use transformers=
|
| 81 |
|
| 82 |
### Model Loading
|
| 83 |
|
|
@@ -432,7 +437,7 @@ print(f'User: {question}')
|
|
| 432 |
print(f'Assistant: {response}')
|
| 433 |
```
|
| 434 |
|
| 435 |
-
#### Streaming
|
| 436 |
|
| 437 |
Besides this method, you can also use the following code to get streamed output.
|
| 438 |
|
|
@@ -470,6 +475,12 @@ This project is released under the MIT license. Parts of this project contain co
|
|
| 470 |
If you find this project useful in your research, please consider citing:
|
| 471 |
|
| 472 |
```BibTeX
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 473 |
@article{chen2023internvl,
|
| 474 |
title={InternVL: Scaling up Vision Foundation Models and Aligning for Generic Visual-Linguistic Tasks},
|
| 475 |
author={Chen, Zhe and Wu, Jiannan and Wang, Wenhai and Su, Weijie and Chen, Guo and Xing, Sen and Zhong, Muyan and Zhang, Qinglong and Zhu, Xizhou and Lu, Lewei and Li, Bin and Luo, Ping and Lu, Tong and Qiao, Yu and Dai, Jifeng},
|
|
|
|
| 5 |
base_model:
|
| 6 |
- OpenGVLab/InternViT-6B-448px-V1-2
|
| 7 |
- NousResearch/Nous-Hermes-2-Yi-34B
|
| 8 |
+
new_version: OpenGVLab/InternVL2_5-38B
|
| 9 |
base_model_relation: merge
|
| 10 |
language:
|
| 11 |
- multilingual
|
|
|
|
| 20 |
|
| 21 |
# InternVL-Chat-V1-2-Plus
|
| 22 |
|
| 23 |
+
[\[π GitHub\]](https://github.com/OpenGVLab/InternVL) [\[π Blog\]](https://internvl.github.io/blog/) [\[π InternVL 1.0\]](https://arxiv.org/abs/2312.14238) [\[π InternVL 1.5\]](https://arxiv.org/abs/2404.16821) [\[π Mini-InternVL\]](https://arxiv.org/abs/2410.16261)
|
| 24 |
|
| 25 |
[\[π¨οΈ Chat Demo\]](https://internvl.opengvlab.com/) [\[π€ HF Demo\]](https://huggingface.co/spaces/OpenGVLab/InternVL) [\[π Quick Start\]](#quick-start) [\[π δΈζθ§£θ―»\]](https://zhuanlan.zhihu.com/p/706547971) [\[π Documents\]](https://internvl.readthedocs.io/en/latest/)
|
| 26 |
|
| 27 |
+
<div align="center">
|
| 28 |
+
<img width="500" alt="image" src="https://cdn-uploads.huggingface.co/production/uploads/64006c09330a45b03605bba3/zJsd2hqd3EevgXo6fNgC-.png">
|
| 29 |
+
</div>
|
| 30 |
+
|
| 31 |
## Introduction
|
| 32 |
|
| 33 |
InternVL-Chat-V1-2-Plus uses the same model architecture as [InternVL-Chat-V1-2](https://huggingface.co/OpenGVLab/InternVL-Chat-V1-2), but the difference lies in the SFT dataset. InternVL-Chat-V1-2 only utilizes an SFT dataset with 1.2M samples, while **our plus version employs an SFT dataset with 12M samples**.
|
|
|
|
| 82 |
|
| 83 |
We also welcome you to experience the InternVL2 series models in our [online demo](https://internvl.opengvlab.com/).
|
| 84 |
|
| 85 |
+
> Please use transformers>=4.37.2 to ensure the model works normally.
|
| 86 |
|
| 87 |
### Model Loading
|
| 88 |
|
|
|
|
| 437 |
print(f'Assistant: {response}')
|
| 438 |
```
|
| 439 |
|
| 440 |
+
#### Streaming Output
|
| 441 |
|
| 442 |
Besides this method, you can also use the following code to get streamed output.
|
| 443 |
|
|
|
|
| 475 |
If you find this project useful in your research, please consider citing:
|
| 476 |
|
| 477 |
```BibTeX
|
| 478 |
+
@article{gao2024mini,
|
| 479 |
+
title={Mini-internvl: A flexible-transfer pocket multimodal model with 5\% parameters and 90\% performance},
|
| 480 |
+
author={Gao, Zhangwei and Chen, Zhe and Cui, Erfei and Ren, Yiming and Wang, Weiyun and Zhu, Jinguo and Tian, Hao and Ye, Shenglong and He, Junjun and Zhu, Xizhou and others},
|
| 481 |
+
journal={arXiv preprint arXiv:2410.16261},
|
| 482 |
+
year={2024}
|
| 483 |
+
}
|
| 484 |
@article{chen2023internvl,
|
| 485 |
title={InternVL: Scaling up Vision Foundation Models and Aligning for Generic Visual-Linguistic Tasks},
|
| 486 |
author={Chen, Zhe and Wu, Jiannan and Wang, Wenhai and Su, Weijie and Chen, Guo and Xing, Sen and Zhong, Muyan and Zhang, Qinglong and Zhu, Xizhou and Lu, Lewei and Li, Bin and Luo, Ping and Lu, Tong and Qiao, Yu and Dai, Jifeng},
|
configuration_internvl_chat.py
CHANGED
|
@@ -38,11 +38,11 @@ class InternVLChatConfig(PretrainedConfig):
|
|
| 38 |
super().__init__(**kwargs)
|
| 39 |
|
| 40 |
if vision_config is None:
|
| 41 |
-
vision_config = {}
|
| 42 |
logger.info('vision_config is None. Initializing the InternVisionConfig with default values.')
|
| 43 |
|
| 44 |
if llm_config is None:
|
| 45 |
-
llm_config = {}
|
| 46 |
logger.info('llm_config is None. Initializing the LlamaConfig config with default values (`LlamaConfig`).')
|
| 47 |
|
| 48 |
self.vision_config = InternVisionConfig(**vision_config)
|
|
|
|
| 38 |
super().__init__(**kwargs)
|
| 39 |
|
| 40 |
if vision_config is None:
|
| 41 |
+
vision_config = {'architectures': ['InternVisionModel']}
|
| 42 |
logger.info('vision_config is None. Initializing the InternVisionConfig with default values.')
|
| 43 |
|
| 44 |
if llm_config is None:
|
| 45 |
+
llm_config = {'architectures': ['LlamaForCausalLM']}
|
| 46 |
logger.info('llm_config is None. Initializing the LlamaConfig config with default values (`LlamaConfig`).')
|
| 47 |
|
| 48 |
self.vision_config = InternVisionConfig(**vision_config)
|
modeling_intern_vit.py
CHANGED
|
@@ -3,6 +3,7 @@
|
|
| 3 |
# Copyright (c) 2024 OpenGVLab
|
| 4 |
# Licensed under The MIT License [see LICENSE for details]
|
| 5 |
# --------------------------------------------------------
|
|
|
|
| 6 |
from typing import Optional, Tuple, Union
|
| 7 |
|
| 8 |
import torch
|
|
|
|
| 3 |
# Copyright (c) 2024 OpenGVLab
|
| 4 |
# Licensed under The MIT License [see LICENSE for details]
|
| 5 |
# --------------------------------------------------------
|
| 6 |
+
|
| 7 |
from typing import Optional, Tuple, Union
|
| 8 |
|
| 9 |
import torch
|