🚀 InstructBLIP模型
InstructBLIP模型使用[Flan - T5 - xl](https://huggingface.co/google/flan - t5 - xl)作为语言模型。InstructBLIP由Dai等人在论文InstructBLIP: Towards General - purpose Vision - Language Models with Instruction Tuning中提出。
免责声明:发布InstructBLIP的团队并未为该模型撰写模型卡片,此模型卡片由Hugging Face团队撰写。
🚀 快速开始
InstructBLIP模型在图像文本处理方面表现出色,它结合了视觉和语言能力,可用于图像描述等多种任务。下面是一个简单的使用示例,展示了如何使用该模型进行图像分析:
from transformers import InstructBlipProcessor, InstructBlipForConditionalGeneration
import torch
from PIL import Image
import requests
model = InstructBlipForConditionalGeneration.from_pretrained("Salesforce/instructblip-flan-t5-xl")
processor = InstructBlipProcessor.from_pretrained("Salesforce/instructblip-flan-t5-xl")
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)
更多代码示例,请参考文档。
✨ 主要特性
- InstructBLIP是[BLIP - 2](https://huggingface.co/docs/transformers/main/model_doc/blip - 2)的视觉指令调优版本,具备更强大的视觉语言处理能力。
- 该模型可处理图像文本到文本的任务,如根据图像生成描述等。
📚 详细文档
模型描述
InstructBLIP是[BLIP - 2](https://huggingface.co/docs/transformers/main/model_doc/blip - 2)的视觉指令调优版本。详细信息请参考相关论文。

预期用途与限制
使用方法如下:
如何使用
关于代码示例,请参考文档。
伦理考量
本次发布仅用于支持学术论文的研究目的。我们的模型、数据集和代码并非专门为所有下游用途而设计或评估。我们强烈建议用户在部署此模型之前,评估并解决与准确性、安全性和公平性相关的潜在问题。我们鼓励用户考虑人工智能的常见局限性,遵守适用法律,并在选择用例时采用最佳实践,特别是在错误或滥用可能对人们的生活、权利或安全产生重大影响的高风险场景中。有关用例的更多指导,请参考我们的AUP和AI AUP。
📄 许可证
本项目采用MIT许可证。