Image-Text-to-Text
Transformers
Safetensors
multilingual
internvl_chat
feature-extraction
internvl
custom_code
conversational
Instructions to use OpenGVLab/InternVL2-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use OpenGVLab/InternVL2-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="OpenGVLab/InternVL2-4B", 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-4B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use OpenGVLab/InternVL2-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "OpenGVLab/InternVL2-4B" # 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-4B", "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-4B
- SGLang
How to use OpenGVLab/InternVL2-4B 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-4B" \ --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-4B", "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-4B" \ --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-4B", "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-4B with Docker Model Runner:
docker model run hf.co/OpenGVLab/InternVL2-4B
Commit History
-
Add supports_gradient_checkpointing
Verified signature6eb21ec -
Add supports_gradient_checkpointing
Verified signature7bcc1ca
-
fix for compatibility with transformers 4.49 (#7)
Verified signature- fix for compatibility with transformers 4.49 (4dab4f2c1a015df64cd459b91e01d411611d7e06) Co-authored-by: Ekaterina Aidova <[email protected]>4bfb8f1
-
Fix device_map
Verified signaturee475567
-
Update README.md
Verified signaturee5a72e2
-
Update README.md
Verified signature5a190f3
-
Apply Github PR #127 to all HF models
Verified signature4a1ae71 -
Update README.md
Verified signaturebb93a16
-
Update README.md
Verified signaturef97ad9f
-
fix compatibility issue for transformers 4.46+
Verified signaturece34d1a
-
Update README.md
Verified signatured218b77 -
Update README.md
Verified signature8fa442c
-
fix compatibility issue for transformers 4.46+
Verified signature275b70e -
fix compatibility issue for transformers 4.46+
Verified signature2a90414 -
fix compatibility issue for transformers 4.46+
Verified signaturee3ef4b5
-
Upload folder using huggingface_hub
Verified signature50b4a2c -
Upload folder using huggingface_hub
Verified signaturea3a6b90
-
Upload folder using huggingface_hub
Verified signature7f49802 -
Upload folder using huggingface_hub
Verified signature81c1b14 -
Upload folder using huggingface_hub
Verified signatureb770b7d -
Upload folder using huggingface_hub
Verified signaturea2d8a79 -
Upload folder using huggingface_hub
Verified signatured9c0aee -
Upload folder using huggingface_hub
Verified signature02fcfe6
-
Upload folder using huggingface_hub
Verified signature634d4df -
Upload folder using huggingface_hub
Verified signature5bc3cf5 -
Upload folder using huggingface_hub
Verified signaturecf1cb63
-
Delete internvl_v2.zip
Verified signatureb50544d -
Upload folder using huggingface_hub
Verified signature08a2b8f
-
Upload internvl_v2.zip with huggingface_hub
Verified signature91b57f9
-
Upload folder using huggingface_hub
Verified signature5b52d5a
-
Upload folder using huggingface_hub
Verified signatured52b372 -
Upload folder using huggingface_hub
Verified signature9f7c091 -
Update tokenizer_config.json
Verified signatureeedb1e9
-
Upload folder using huggingface_hub
Verified signaturecea415a -
Upload folder using huggingface_hub
Verified signaturecec24c8
-
Upload folder using huggingface_hub
Verified signature6479cfb
-
Upload folder using huggingface_hub
Verified signature1511ed6
-
Upload folder using huggingface_hub
Verified signature56f90e9 -
Upload folder using huggingface_hub
Verified signature29513ea
-
Upload folder using huggingface_hub
Verified signature74eea57
-
Upload folder using huggingface_hub
Verified signature7a81a1e
-
Upload folder using huggingface_hub
Verified signaturec28b6bf -
Upload folder using huggingface_hub
Verified signature6aa3183 -
Upload folder using huggingface_hub
Verified signaturebdad101 -
Upload folder using huggingface_hub
Verified signatureda9a3f1 -
Upload folder using huggingface_hub
Verified signature37c6496 -
Upload folder using huggingface_hub
Verified signature839139d
-
Upload folder using huggingface_hub
Verified signature65abe2e
-
Upload folder using huggingface_hub
Verified signaturebcc0556
-
Upload folder using huggingface_hub
Verified signatureb18310a