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 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Salesforce/blip2-opt-6.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-6.7b")# Load model directly from transformers import AutoProcessor, AutoModelForVisualQuestionAnswering processor = AutoProcessor.from_pretrained("Salesforce/blip2-opt-6.7b") model = AutoModelForVisualQuestionAnswering.from_pretrained("Salesforce/blip2-opt-6.7b") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Salesforce/blip2-opt-6.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-6.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-6.7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Salesforce/blip2-opt-6.7b
- SGLang
How to use Salesforce/blip2-opt-6.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-6.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-6.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-6.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-6.7b", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Salesforce/blip2-opt-6.7b with Docker Model Runner:
docker model run hf.co/Salesforce/blip2-opt-6.7b
Update README.md
Browse files
README.md
CHANGED
|
@@ -36,11 +36,25 @@ This allows the model to be used for tasks like:
|
|
| 36 |
- visual question answering (VQA)
|
| 37 |
- chat-like conversations by feeding the image and the previous conversation as prompt to the model
|
| 38 |
|
| 39 |
-
##
|
| 40 |
|
| 41 |
You can use the raw model for conditional text generation given an image and optional text. See the [model hub](https://huggingface.co/models?search=Salesforce/blip) to look for
|
| 42 |
fine-tuned versions on a task that interests you.
|
| 43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
### How to use
|
| 45 |
|
| 46 |
For code examples, we refer to the [documentation](https://huggingface.co/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2ForConditionalGeneration.forward.example).
|
|
|
|
| 36 |
- visual question answering (VQA)
|
| 37 |
- chat-like conversations by feeding the image and the previous conversation as prompt to the model
|
| 38 |
|
| 39 |
+
## Direct Use and Downstream Use
|
| 40 |
|
| 41 |
You can use the raw model for conditional text generation given an image and optional text. See the [model hub](https://huggingface.co/models?search=Salesforce/blip) to look for
|
| 42 |
fine-tuned versions on a task that interests you.
|
| 43 |
|
| 44 |
+
## Bias, Risks, Limitations, and Ethical Considerations
|
| 45 |
+
|
| 46 |
+
BLIP2-OPT uses off-the-shelf OPT as the language model. It inherits the same risks and limitations as mentioned in Meta's model card.
|
| 47 |
+
|
| 48 |
+
> Like other large language models for which the diversity (or lack thereof) of training
|
| 49 |
+
> data induces downstream impact on the quality of our model, OPT-175B has limitations in terms
|
| 50 |
+
> of bias and safety. OPT-175B can also have quality issues in terms of generation diversity and
|
| 51 |
+
> hallucination. In general, OPT-175B is not immune from the plethora of issues that plague modern
|
| 52 |
+
> large language models.
|
| 53 |
+
>
|
| 54 |
+
BLIP2 is fine-tuned on image-text datasets (e.g. [LAION](https://laion.ai/blog/laion-400-open-dataset/) ) collected from the internet. As a result the model itself is potentially vulnerable to generating equivalently inappropriate content or replicating inherent biases in the underlying data.
|
| 55 |
+
|
| 56 |
+
BLIP2 has not been tested in real world applications. It should not be directly deployed in any applications. Researchers should first carefully assess the safety and fairness of the model in relation to the specific context they’re being deployed within.
|
| 57 |
+
|
| 58 |
### How to use
|
| 59 |
|
| 60 |
For code examples, we refer to the [documentation](https://huggingface.co/docs/transformers/main/en/model_doc/blip-2#transformers.Blip2ForConditionalGeneration.forward.example).
|