🚀 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許可證。