Image-Text-to-Text
Transformers
Safetensors
multilingual
internvl_chat
feature-extraction
internvl
custom_code
conversational
Instructions to use OpenGVLab/InternVL2-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenGVLab/InternVL2-2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenGVLab/InternVL2-2B", 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/InternVL2-2B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OpenGVLab/InternVL2-2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenGVLab/InternVL2-2B" # 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-2B", "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-2B
- SGLang
How to use OpenGVLab/InternVL2-2B 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-2B" \ --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-2B", "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-2B" \ --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-2B", "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-2B with Docker Model Runner:
docker model run hf.co/OpenGVLab/InternVL2-2B
Commit History
-
Add supports_gradient_checkpointing
Verified signaturee4f6747
-
Fix device_map
Verified signature632d49c
-
Update README.md
Verified signatureaec61df
-
Update README.md
Verified signaturec838422
-
Apply Github PR #127 to all HF models
Verified signaturea5662f7 -
Update README.md
Verified signaturef9ff786
-
Update README.md
Verified signature58f1bb8
-
Delete 20241205_033944
Verified signature23ac785 -
fix compatibility issue for transformers 4.46+
Verified signaturea5038f9
-
Update README.md
Verified signature80c32a4 -
Update README.md
Verified signature8f67269
-
fix compatibility issue for transformers 4.46+
Verified signature02e3b79 -
fix compatibility issue for transformers 4.46+
Verified signature48a8a83 -
fix compatibility issue for transformers 4.46+
Verified signature3c7837b -
Delete test_long_niah.sh
Verified signature54ef5b6 -
fix compatibility issue for transformers 4.46+
Verified signaturefaa8fea -
Delete retrieval-image-test-long-subset
Verified signature45c0015 -
Delete retrieval-image-test-long-128k
Verified signature6a85940 -
Delete eval_mm_niah_ring_attn_256
Verified signature32fa812 -
fix compatibility issue for transformers 4.46+
Verified signature644e0b6
-
Upload folder using huggingface_hub
Verified signature783b806
-
Upload folder using huggingface_hub
Verified signature7463c82 -
Upload folder using huggingface_hub
Verified signaturec28273a -
Upload folder using huggingface_hub
Verified signature1ef7c7f -
Upload folder using huggingface_hub
Verified signature2baab50 -
Upload folder using huggingface_hub
Verified signatureaddb5d4 -
Upload folder using huggingface_hub
Verified signature1d3e38d
-
Upload folder using huggingface_hub
Verified signaturecd86688 -
Upload folder using huggingface_hub
Verified signaturefa2d59d -
Upload folder using huggingface_hub
Verified signature60d03d8
-
Delete vqa-docvqa-val.log
Verified signature422ad7c -
Delete caption-coco.log
Verified signature078c095 -
Delete scienceqa.log
Verified signaturef44fe84 -
Delete mmbench-test-en.log
Verified signature614ef3d -
Delete pope.log
Verified signature3fd9266 -
Delete mmmu-val.log
Verified signaturecabca04 -
Delete vqa-ai2d-test.log
Verified signaturea1968b7 -
Delete internvl_v2.zip
Verified signature2d0c52f -
Delete eval_mm_niah
Verified signature82fce5f -
Delete eval_milebench
Verified signaturecffc5b7 -
Upload folder using huggingface_hub
Verified signatureb537a0f
-
Upload internvl_v2.zip with huggingface_hub
Verified signaturef245b6d
-
Upload folder using huggingface_hub
Verified signature53b54cd
-
Upload folder using huggingface_hub
Verified signaturead4b36d -
Upload folder using huggingface_hub
Verified signature6a08965
-
Upload folder using huggingface_hub
Verified signature26287f7 -
Upload folder using huggingface_hub
Verified signature2561d8d
-
Upload folder using huggingface_hub
Verified signaturef1cdd8f
-
Upload folder using huggingface_hub
Verified signature345d4d3
-
Upload folder using huggingface_hub
Verified signature674e33b