🚀 InstructBLIP模型
InstructBLIP模型使用Flan - T5 - xxl作为语言模型。InstructBLIP由Dai等人在论文InstructBLIP: Towards General - purpose Vision - Language Models with Instruction Tuning中提出。
声明:发布InstructBLIP的团队并未为该模型撰写模型卡片,此模型卡片由Hugging Face团队撰写。
🚀 快速开始
模型描述
InstructBLIP是BLIP - 2的视觉指令调优版本。详细信息请参考相关论文。

预期用途和限制
使用方法如下:
from transformers import InstructBlipProcessor, InstructBlipForConditionalGeneration
import torch
from PIL import Image
import requests
model = InstructBlipForConditionalGeneration.from_pretrained("Salesforce/instructblip-flan-t5-xxl")
processor = InstructBlipProcessor.from_pretrained("Salesforce/instructblip-flan-t5-xxl")
device = "cuda" if torch.cuda.is_available() else "cpu"
model.to(device)
url = "https://raw.githubusercontent.com/salesforce/LAVIS/main/docs/_static/Confusing-Pictures.jpg"
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
prompt = "What is unusual about this image?"
inputs = processor(images=image, text=prompt, return_tensors="pt").to(device)
outputs = model.generate(
**inputs,
do_sample=False,
num_beams=5,
max_length=256,
min_length=1,
top_p=0.9,
repetition_penalty=1.5,
length_penalty=1.0,
temperature=1,
)
generated_text = processor.batch_decode(outputs, skip_special_tokens=True)[0].strip()
print(generated_text)
道德考量
本次发布仅用于支持学术论文的研究目的。我们的模型、数据集和代码并非专门为所有下游用途而设计或评估。我们强烈建议用户在部署此模型之前,评估并解决与准确性、安全性和公平性相关的潜在问题。我们鼓励用户考虑人工智能的常见局限性,遵守适用法律,并在选择用例时采用最佳实践,特别是在错误或滥用可能对人们的生活、权利或安全产生重大影响的高风险场景中。有关用例的进一步指导,请参考我们的使用协议和人工智能使用协议。
如何使用
有关代码示例,请参考文档。
📄 许可证
本项目采用MIT许可证。