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-6.7b-coco with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Salesforce/blip2-opt-6.7b-coco with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="Salesforce/blip2-opt-6.7b-coco")# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("Salesforce/blip2-opt-6.7b-coco") model = AutoModelForMultimodalLM.from_pretrained("Salesforce/blip2-opt-6.7b-coco", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Salesforce/blip2-opt-6.7b-coco with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Salesforce/blip2-opt-6.7b-coco" # 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-6.7b-coco", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Salesforce/blip2-opt-6.7b-coco
- SGLang
How to use Salesforce/blip2-opt-6.7b-coco 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-6.7b-coco" \ --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-6.7b-coco", "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-6.7b-coco" \ --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-6.7b-coco", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Salesforce/blip2-opt-6.7b-coco with Docker Model Runner:
docker model run hf.co/Salesforce/blip2-opt-6.7b-coco
| { | |
| "architectures": [ | |
| "Blip2ForConditionalGeneration" | |
| ], | |
| "image_text_hidden_size": 256, | |
| "image_token_index": 50265, | |
| "initializer_factor": 1.0, | |
| "initializer_range": 0.02, | |
| "model_type": "blip-2", | |
| "num_query_tokens": 32, | |
| "qformer_config": { | |
| "classifier_dropout": null, | |
| "model_type": "blip_2_qformer" | |
| }, | |
| "text_config": { | |
| "activation_dropout": 0.0, | |
| "architectures": [ | |
| "OPTForCausalLM" | |
| ], | |
| "eos_token_id": 50118, | |
| "ffn_dim": 16384, | |
| "hidden_size": 4096, | |
| "model_type": "opt", | |
| "num_attention_heads": 32, | |
| "num_hidden_layers": 32, | |
| "prefix": "</s>", | |
| "torch_dtype": "float16", | |
| "vocab_size": 50304, | |
| "word_embed_proj_dim": 4096 | |
| }, | |
| "torch_dtype": "float32", | |
| "transformers_version": "4.47.0.dev0", | |
| "use_decoder_only_language_model": true, | |
| "vision_config": { | |
| "dropout": 0.0, | |
| "image_size": 364, | |
| "initializer_factor": 1.0, | |
| "model_type": "blip_2_vision_model", | |
| "num_channels": 3, | |
| "projection_dim": 512 | |
| } | |
| } | |