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")# Load model directly from transformers import AutoProcessor, AutoModelForVisualQuestionAnswering processor = AutoProcessor.from_pretrained("Salesforce/blip2-opt-2.7b") model = AutoModelForVisualQuestionAnswering.from_pretrained("Salesforce/blip2-opt-2.7b") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- 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 ·
e21d3a5
1
Parent(s): c7d6c9f
add pipeline
Browse files- README.md +1 -1
- config.json +0 -3
README.md
CHANGED
|
@@ -6,7 +6,7 @@ tags:
|
|
| 6 |
- image-to-text
|
| 7 |
- image-captioning
|
| 8 |
- visual-question-answering
|
| 9 |
-
pipeline_tag: image-to-text
|
| 10 |
---
|
| 11 |
|
| 12 |
# BLIP-2, OPT-2.7b, pre-trained only
|
|
|
|
| 6 |
- image-to-text
|
| 7 |
- image-captioning
|
| 8 |
- visual-question-answering
|
| 9 |
+
pipeline_tag: image-text-to-text
|
| 10 |
---
|
| 11 |
|
| 12 |
# BLIP-2, OPT-2.7b, pre-trained only
|
config.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
{
|
| 2 |
-
"_name_or_path": "/raid/raushan/blip2-opt-2.7b/",
|
| 3 |
"architectures": [
|
| 4 |
"Blip2ForConditionalGeneration"
|
| 5 |
],
|
|
@@ -10,7 +9,6 @@
|
|
| 10 |
"model_type": "blip-2",
|
| 11 |
"num_query_tokens": 32,
|
| 12 |
"qformer_config": {
|
| 13 |
-
"_attn_implementation_autoset": true,
|
| 14 |
"classifier_dropout": null,
|
| 15 |
"model_type": "blip_2_qformer"
|
| 16 |
},
|
|
@@ -35,7 +33,6 @@
|
|
| 35 |
"transformers_version": "4.47.0.dev0",
|
| 36 |
"use_decoder_only_language_model": true,
|
| 37 |
"vision_config": {
|
| 38 |
-
"_attn_implementation_autoset": true,
|
| 39 |
"dropout": 0.0,
|
| 40 |
"initializer_factor": 1.0,
|
| 41 |
"model_type": "blip_2_vision_model",
|
|
|
|
| 1 |
{
|
|
|
|
| 2 |
"architectures": [
|
| 3 |
"Blip2ForConditionalGeneration"
|
| 4 |
],
|
|
|
|
| 9 |
"model_type": "blip-2",
|
| 10 |
"num_query_tokens": 32,
|
| 11 |
"qformer_config": {
|
|
|
|
| 12 |
"classifier_dropout": null,
|
| 13 |
"model_type": "blip_2_qformer"
|
| 14 |
},
|
|
|
|
| 33 |
"transformers_version": "4.47.0.dev0",
|
| 34 |
"use_decoder_only_language_model": true,
|
| 35 |
"vision_config": {
|
|
|
|
| 36 |
"dropout": 0.0,
|
| 37 |
"initializer_factor": 1.0,
|
| 38 |
"model_type": "blip_2_vision_model",
|