🚀 BLIP: 統一的なビジョン言語理解と生成のための言語画像事前学習のブートストラッピング
視覚的質問応答に対して学習されたBLIPのモデルカード - 基本アーキテクチャ(ViTベースのバックボーンを使用)。
このモデルは、条件付きおよび非条件付きの画像キャプショニングに使用できます。
 |
BLIPの公式リポジトリからの画像 |
🚀 クイックスタート
TL;DR
論文の著者は、概要で次のように書いています。
ビジョン言語事前学習(VLP)は、多くのビジョン言語タスクの性能を向上させてきました。しかし、既存のほとんどの事前学習モデルは、理解ベースのタスクまたは生成ベースのタスクのどちらか一方でのみ優れた性能を発揮します。さらに、性能向上は主に、ウェブから収集されたノイズの多い画像テキストペアを用いたデータセットの拡大によって達成されており、これは最適ではない監督ソースです。本論文では、ビジョン言語理解と生成タスクの両方に柔軟に適用できる新しいVLPフレームワークであるBLIPを提案します。BLIPは、キャプショナーが合成キャプションを生成し、フィルターがノイズの多いものを除去することで、ノイズの多いウェブデータを効果的に利用します。画像テキスト検索(平均recall@1で+2.7%)、画像キャプショニング(CIDErで+2.8%)、VQA(VQAスコアで+1.6%)など、幅広いビジョン言語タスクで最先端の結果を達成しています。また、BLIPは、ゼロショットでビデオ言語タスクに直接適用した場合にも、強い汎化能力を示します。コード、モデル、データセットが公開されています。
💻 使用例
基本的な使用法
このモデルを条件付きおよび非条件付きの画像キャプショニングに使用できます。
PyTorchモデルの使用
CPUでモデルを実行する
クリックして展開
import requests
from PIL import Image
from transformers import BlipProcessor, BlipForQuestionAnswering
processor = BlipProcessor.from_pretrained("Salesforce/blip-vqa-base")
model = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-base")
img_url = 'https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg'
raw_image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB')
question = "how many dogs are in the picture?"
inputs = processor(raw_image, question, return_tensors="pt")
out = model.generate(**inputs)
print(processor.decode(out[0], skip_special_tokens=True))
>>> 1
GPUでモデルを実行する
フル精度で実行
クリックして展開
import requests
from PIL import Image
from transformers import BlipProcessor, BlipForQuestionAnswering
processor = BlipProcessor.from_pretrained("Salesforce/blip-vqa-base")
model = BlipForQuestionAnswering.from_pretrained("Salesforce/blip-vqa-base").to("cuda")
img_url = 'https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg'
raw_image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB')
question = "how many dogs are in the picture?"
inputs = processor(raw_image, question, return_tensors="pt").to("cuda")
out = model.generate(**inputs)
print(processor.decode(out[0], skip_special_tokens=True))
>>> 1
半精度(float16
)で実行
クリックして展開
import torch
import requests
from PIL import Image
from transformers import BlipProcessor, BlipForQuestionAnswering
processor = BlipProcessor.from_pretrained("ybelkada/blip-vqa-base")
model = BlipForQuestionAnswering.from_pretrained("ybelkada/blip-vqa-base", torch_dtype=torch.float16).to("cuda")
img_url = 'https://storage.googleapis.com/sfr-vision-language-research/BLIP/demo.jpg'
raw_image = Image.open(requests.get(img_url, stream=True).raw).convert('RGB')
question = "how many dogs are in the picture?"
inputs = processor(raw_image, question, return_tensors="pt").to("cuda", torch.float16)
out = model.generate(**inputs)
print(processor.decode(out[0], skip_special_tokens=True))
>>> 1
🔧 技術的考察
このリリースは、学術論文のサポートのための研究目的のみを対象としています。当社のモデル、データセット、コードは、すべての下流の目的に特に設計または評価されていません。ユーザーは、このモデルを展開する前に、精度、安全性、公正性に関連する潜在的な懸念事項を評価し、対処することを強く推奨します。ユーザーは、AIの一般的な制限を考慮し、適用可能な法律を遵守し、特にエラーや誤用が人々の生活、権利、または安全に重大な影響を与える可能性のある高リスクシナリオの場合には、ベストプラクティスを活用することをお勧めします。ユースケースに関する詳細なガイダンスについては、当社のAUPおよびAI AUPを参照してください。
📄 ライセンス
このモデルはBSD 3条項ライセンスの下で提供されています。
BibTexと引用情報
@misc{https://doi.org/10.48550/arxiv.2201.12086,
doi = {10.48550/ARXIV.2201.12086},
url = {https://arxiv.org/abs/2201.12086},
author = {Li, Junnan and Li, Dongxu and Xiong, Caiming and Hoi, Steven},
keywords = {Computer Vision and Pattern Recognition (cs.CV), FOS: Computer and information sciences, FOS: Computer and information sciences},
title = {BLIP: Bootstrapping Language-Image Pre-training for Unified Vision-Language Understanding and Generation},
publisher = {arXiv},
year = {2022},
copyright = {Creative Commons Attribution 4.0 International}
}