🚀 LLaVA-Med v1.5 Mistral for Chest X-Ray Analysis
このモデルは、LLaVA-Med v1.5 Mistral-7B をベースにファインチューニングされたマルチモーダル基礎モデルです。Kaggleの Chest X-Ray Images (Pneumonia) データセット を使用して、胸部X線画像の分析と肺炎の検出に最適化されています。
プロジェクトページ: SelfSynthX
arXiv上の論文: Enhancing Cognition and Explainability of Multimodal Foundation Models with Self-Synthesized Data
🚀 クイックスタート
このモデルは、胸部X線画像の分析と肺炎の検出に最適化されたマルチモーダル基礎モデルです。以下の手順で使用できます。
✨ 主な機能
- ベースモデル: LLaVA-Med v1.5 Mistral-7B
- データセット: Chest X-Ray Images (Pneumonia)
- 革新的な点:
- 自己合成データ: 人間が理解できる診断洞察を生成することで、解釈可能性を向上させます。
- ドメイン固有のファインチューニング: 正確な肺炎分類のために医用画像に最適化されています。
- 反復的なトレーニング: 棄却サンプリングを利用して、診断精度と説明品質を向上させます。
- 用途: 胸部X線画像からの肺炎診断を支援し、詳細で説明可能な出力を提供します。
📦 インストール
このモデルを使用するには、必要なライブラリをインストールする必要があります。以下のコードで必要なライブラリをインストールできます。
import requests
from PIL import Image
import torch
from transformers import AutoProcessor, LlavaForConditionalGeneration
💻 使用例
基本的な使用法
import requests
from PIL import Image
import torch
from transformers import AutoProcessor, LlavaForConditionalGeneration
model_id = "YuchengShi/llava-med-v1.5-mistral-7b-chest-xray"
model = LlavaForConditionalGeneration.from_pretrained(
model_id,
torch_dtype=torch.float16,
low_cpu_mem_usage=True,
).to("cuda")
processor = AutoProcessor.from_pretrained(model_id)
conversation = [
{
"role": "user",
"content": [
{"type": "text", "text": "Can you analyze this chest X-ray?"},
{"type": "image"},
],
},
]
prompt = processor.apply_chat_template(conversation, add_generation_prompt=True)
image_file = "chest-xray/test1.png"
raw_image = Image.open(requests.get(image_file, stream=True).raw)
inputs = processor(images=raw_image, text=prompt, return_tensors='pt').to("cuda", torch.float16)
output = model.generate(**inputs, max_new_tokens=200, do_sample=False)
print(processor.decode(output[0][2:], skip_special_tokens=True))
📚 ドキュメント
トレーニングと評価
- トレーニング: 胸部X線画像 (肺炎データセット) を使用してLoRAを用いてファインチューニングされ、反復的な棄却サンプリングが行われます。
- 評価: 解釈可能な診断説明を伴う、堅牢な肺炎分類を達成します。
📄 ライセンス
このプロジェクトはMITライセンスの下で公開されています。
🔖 引用
このモデルを使用する場合は、以下のように引用してください。
@inproceedings{
shi2025enhancing,
title={Enhancing Cognition and Explainability of Multimodal Foundation Models with Self-Synthesized Data},
author={Yucheng Shi and Quanzheng Li and Jin Sun and Xiang Li and Ninghao Liu},
booktitle={The Thirteenth International Conference on Learning Representations},
year={2025},
url={https://openreview.net/forum?id=lHbLpwbEyt}
}