Image-Text-to-Text
Transformers
PyTorch
Safetensors
English
blip-2
visual-question-answering
vision
image-to-text
image-captioning
Instructions to use Salesforce/blip2-opt-2.7b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Salesforce/blip2-opt-2.7b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Salesforce/blip2-opt-2.7b")# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Salesforce/blip2-opt-2.7b") model = AutoModelForMultimodalLM.from_pretrained("Salesforce/blip2-opt-2.7b", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Salesforce/blip2-opt-2.7b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Salesforce/blip2-opt-2.7b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Salesforce/blip2-opt-2.7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Salesforce/blip2-opt-2.7b
- SGLang
How to use Salesforce/blip2-opt-2.7b 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 "Salesforce/blip2-opt-2.7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Salesforce/blip2-opt-2.7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "Salesforce/blip2-opt-2.7b" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Salesforce/blip2-opt-2.7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Salesforce/blip2-opt-2.7b with Docker Model Runner:
docker model run hf.co/Salesforce/blip2-opt-2.7b
Commit History
-
Update README.md
Verified signature59a1ef6
-
Update for `transformers` (#38)
Verified signature- update (c7d6c9f37354a91481abf26893b22ffcb6d10878) - add pipeline (e21d3a5fdb3258c8a8b0d429ff659193a2eb388f) Co-authored-by: Raushan Turganbay <RaushanTurganbay@users.noreply.huggingface.co>ec3c346
-
Adding `safetensors` variant of this model (#32)
Verified signature- Adding `safetensors` variant of this model (e8f2de94fbbd3fc4d59dfcc67aa9fe448c6d48c1) Co-authored-by: Safetensors convertbot <SFconvertbot@users.noreply.huggingface.co>5157266
-
Update README.md (#31)
Verified signature- Update README.md (00ccb31b042b205bd8d2dbdd501003138af90ce4) Co-authored-by: Niels Rogge <nielsr@users.noreply.huggingface.co>505d34e
-
Update README.md (#18)
Verified signature- Update README.md (482f69651497a402d12e1883c3ed36a31c643c20) Co-authored-by: Niels Rogge <nielsr@users.noreply.huggingface.co>235c75e
-
Update layer norm eps (#14)
- Update layer norm eps (7aee615866a5b44e034e3483320946a04f90d80f)6e723d9 -
Update README.md
8ccdaf1
-
fix cpu example (#6)
- fix cpu example (c85fb03937975a684ef001ca1b32480e9486b079) Co-authored-by: Shinji Yamada <devneko@users.noreply.huggingface.co>1ef7f63
-
Update README.md
56e1fe8
-
Update README.md
ca9e6c2 -
Update README.md
c3a5f8c
-
Update README.md
a712fe6 -
Update README.md
2fc6e3f
-
Upload Blip2ForConditionalGeneration
4565816 -
Upload processor
34f5d87
-
Create README.md
21bcce5
-
Upload Blip2ForConditionalGeneration
ee95c28 -
Upload processor
69cfab4 -
initial commit
fec6286