Radialog Interactive Radiology Report Generation
マルチモーダルTransformerベースの放射線学レポート生成および医療対話システムで、胸部X線画像を分析し関連レポートを生成または医学的質問に回答できます。
ダウンロード数 171
リリース時間 : 4/25/2024
モデル概要
このモデルは視覚と言語処理能力を統合し、医療画像分析分野に特化しており、胸部X線画像に基づいて診断レポートを生成したり関連する医療対話を行えます。
モデル特徴
マルチモーダル医療画像理解
医療画像とテキスト入力を同時に処理し、X線画像中の医学的特徴を理解可能
インタラクティブ放射線学レポート生成
X線画像に基づき構造化された放射線学診断レポートを自動生成
医療質問応答能力
画像関連の医学的質問に回答し、専門的な説明を提供可能
ドメイン特化
胸部X線画像分析に特化して最適化され、医学分野の専門知識を有する
モデル能力
医療画像分析
放射線学レポート生成
医療QA
マルチモーダル理解
使用事例
医療診断補助
自動放射線学レポート生成
入力された胸部X線画像に基づき予備診断レポートを自動生成
放射線科医の負担軽減とレポート効率向上
医学教育補助
医学生がX線画像の特徴と診断要点を理解するのを支援
インタラクティブな学習体験を提供
遠隔医療
予備スクリーニング補助
資源が限られた地域で予備的な画像分析サポートを提供
医療サービスのアクセシビリティ拡大
🚀 RaDialog
RaDialogは、放射線学レポート生成と会話支援に特化した大規模ビジョン言語モデルです。医療分野における画像とテキストの情報を活用し、放射線科医の支援や患者への情報提供に役立ちます。
Property | Details |
---|---|
Dataset | mimic - cxr |
Library Name | transformers |
License | apache - 2.0 |
Tags | medical, radiology report generation, medical chatbot |
Inference | false |
Pipeline Tag | image - text - to - text |
📝 論文 • 🖥️ Github • 🗂️データセット • 🌐️プロジェクトページ
🚀 クイックスタート
リポジトリのクローン
git clone https://huggingface.co/ChantalPellegrini/RaDialog-interactive-radiology-report-generation
必要なライブラリのインストール
conda create -n llava_hf python=3.10
conda activate llava_hf
pip install pip==24.0
conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia
pip install -r requirements.txt
💻 使用例
基本的な使用法
from pathlib import Path
import io
import requests
import torch
from PIL import Image
import numpy as np
from huggingface_hub import snapshot_download
from LLAVA_Biovil.llava.mm_utils import tokenizer_image_token, get_model_name_from_path, KeywordsStoppingCriteria, remap_to_uint8
from LLAVA_Biovil.llava.model.builder import load_pretrained_model
from LLAVA_Biovil.llava.conversation import SeparatorStyle, conv_vicuna_v1
from LLAVA_Biovil.llava.constants import IMAGE_TOKEN_INDEX
from utils import create_chest_xray_transform_for_inference, init_chexpert_predictor
def load_model_from_huggingface(repo_id):
# Download model files
model_path = snapshot_download(repo_id=repo_id, revision="main")
model_path = Path(model_path)
tokenizer, model, image_processor, context_len = load_pretrained_model(model_path, model_base='liuhaotian/llava-v1.5-7b',
model_name="llava-v1.5-7b-task-lora_radialog_instruct_llava_biovil_unfrozen_2e-5_5epochs_v5_checkpoint-21000", load_8bit=False, load_4bit=False)
return tokenizer, model, image_processor, context_len
if __name__ == '__main__':
sample_img_path = "https://openi.nlm.nih.gov/imgs/512/294/3502/CXR3502_IM-1707-1001.png?keywords=Surgical%20Instruments,Cardiomegaly,Pulmonary%20Congestion,Diaphragm"
response = requests.get(sample_img_path)
image = Image.open(io.BytesIO(response.content))
image = remap_to_uint8(np.array(image))
image = Image.fromarray(image).convert("L")
tokenizer, model, image_processor, context_len = load_model_from_huggingface(repo_id="Chantal/RaDialog-interactive-radiology-report-generation")
cp_model, cp_class_names, cp_transforms = init_chexpert_predictor()
model.config.tokenizer_padding_side = "left"
cp_image = cp_transforms(image)
logits = cp_model(cp_image[None].half().cuda())
preds_probs = torch.sigmoid(logits)
preds = preds_probs > 0.5
pred = preds[0].cpu().numpy()
findings = cp_class_names[pred].tolist()
findings = ', '.join(findings).lower().strip()
conv = conv_vicuna_v1.copy()
REPORT_GEN_PROMPT = f"<image>. Predicted Findings: {findings}. You are to act as a radiologist and write the finding section of a chest x-ray radiology report for this X-ray image and the given predicted findings. Write in the style of a radiologist, write one fluent text without enumeration, be concise and don't provide explanations or reasons."
print("USER: ", REPORT_GEN_PROMPT)
conv.append_message("USER", REPORT_GEN_PROMPT)
conv.append_message("ASSISTANT", None)
text_input = conv.get_prompt()
# get the image
vis_transforms_biovil = create_chest_xray_transform_for_inference(512, center_crop_size=448)
image_tensor = vis_transforms_biovil(image).unsqueeze(0)
image_tensor = image_tensor.to(model.device, dtype=torch.bfloat16)
input_ids = tokenizer_image_token(text_input, tokenizer, IMAGE_TOKEN_INDEX, return_tensors='pt').unsqueeze(0).to(model.device)
stop_str = conv.sep if conv.sep_style != SeparatorStyle.TWO else conv.sep2
stopping_criteria = KeywordsStoppingCriteria([stop_str], tokenizer, input_ids)
# generate a report
with torch.inference_mode():
output_ids = model.generate(
input_ids,
images=image_tensor,
do_sample=False,
use_cache=True,
max_new_tokens=300,
stopping_criteria=[stopping_criteria],
pad_token_id=tokenizer.pad_token_id
)
pred = tokenizer.decode(output_ids[0, input_ids.shape[1]:]).strip().replace("</s>", "")
print("ASSISTANT: ", pred)
# add prediction to conversation
conv.messages.pop()
conv.append_message("ASSISTANT", pred)
stop_str = conv.sep if conv.sep_style != SeparatorStyle.TWO else conv.sep2
stopping_criteria = KeywordsStoppingCriteria([stop_str], tokenizer, input_ids)
# generate a report
with torch.inference_mode():
output_ids = model.generate(
input_ids,
images=image_tensor,
do_sample=False,
use_cache=True,
max_new_tokens=300,
stopping_criteria=[stopping_criteria],
pad_token_id=tokenizer.pad_token_id
)
pred = tokenizer.decode(output_ids[0, input_ids.shape[1]:]).strip().replace("</s>", "")
print("ASSISTANT: ", pred)
# add prediction to conversation
conv.messages.pop()
conv.append_message("ASSISTANT", pred)
conv.append_message("USER", "Translate this report to easy language for a patient to understand.")
conv.append_message("ASSISTANT", None)
text_input = conv.get_prompt()
print("USER: ", "Translate this report to easy language for a patient to understand.")
# generate easy language report
input_ids = tokenizer_image_token(text_input, tokenizer, IMAGE_TOKEN_INDEX, return_tensors='pt').unsqueeze(0).to(model.device)
with torch.inference_mode():
output_ids = model.generate(
input_ids,
images=image_tensor,
do_sample=False,
use_cache=True,
max_new_tokens=300,
stopping_criteria=[stopping_criteria],
pad_token_id=tokenizer.pad_token_id
)
pred = tokenizer.decode(output_ids[0, input_ids.shape[1]:]).strip().replace("</s>", "")
print("ASSISTANT: ", pred)
✏️ 引用
@article{pellegrini2023radialog,
title={RaDialog: A Large Vision-Language Model for Radiology Report Generation and Conversational Assistance},
author={Pellegrini, Chantal and {\"O}zsoy, Ege and Busam, Benjamin and Navab, Nassir and Keicher, Matthias},
journal={arXiv preprint arXiv:2311.18681},
year={2023}
}
Clip Vit Large Patch14
CLIPはOpenAIによって開発された視覚-言語モデルで、コントラスティブラーニングを通じて画像とテキストを共有の埋め込み空間にマッピングし、ゼロショット画像分類をサポートします
画像生成テキスト
C
openai
44.7M
1,710
Clip Vit Base Patch32
CLIPはOpenAIが開発したマルチモーダルモデルで、画像とテキストの関係を理解し、ゼロショット画像分類タスクをサポートします。
画像生成テキスト
C
openai
14.0M
666
Siglip So400m Patch14 384
Apache-2.0
SigLIPはWebLiデータセットで事前学習された視覚言語モデルで、改良されたシグモイド損失関数を採用し、画像-テキストマッチングタスクを最適化しています。
画像生成テキスト
Transformers

S
google
6.1M
526
Clip Vit Base Patch16
CLIPはOpenAIが開発したマルチモーダルモデルで、コントラスティブラーニングにより画像とテキストを共有の埋め込み空間にマッピングし、ゼロショット画像分類能力を実現します。
画像生成テキスト
C
openai
4.6M
119
Blip Image Captioning Base
Bsd-3-clause
BLIPは先進的な視覚-言語事前学習モデルで、画像キャプション生成タスクに優れており、条件付きおよび無条件のテキスト生成をサポートします。
画像生成テキスト
Transformers

B
Salesforce
2.8M
688
Blip Image Captioning Large
Bsd-3-clause
BLIPは統一された視覚-言語事前学習フレームワークで、画像キャプション生成タスクに優れており、条件付きおよび無条件の画像キャプション生成をサポートします。
画像生成テキスト
Transformers

B
Salesforce
2.5M
1,312
Openvla 7b
MIT
OpenVLA 7BはOpen X-Embodimentデータセットでトレーニングされたオープンソースの視覚-言語-動作モデルで、言語命令とカメラ画像に基づいてロボットの動作を生成できます。
画像生成テキスト
Transformers 英語

O
openvla
1.7M
108
Llava V1.5 7b
LLaVAはオープンソースのマルチモーダルチャットボットで、LLaMA/Vicunaをファインチューニングし、画像とテキストのインタラクションをサポートします。
画像生成テキスト
Transformers

L
liuhaotian
1.4M
448
Vit Gpt2 Image Captioning
Apache-2.0
これはViTとGPT2アーキテクチャに基づく画像記述生成モデルで、入力画像に対して自然言語の記述を生成することができます。
画像生成テキスト
Transformers

V
nlpconnect
939.88k
887
Blip2 Opt 2.7b
MIT
BLIP-2は画像エンコーダーと大規模言語モデルを組み合わせた視覚言語モデルで、画像からテキストを生成するタスクに使用されます。
画像生成テキスト
Transformers 英語

B
Salesforce
867.78k
359
おすすめAIモデル
Llama 3 Typhoon V1.5x 8b Instruct
タイ語専用に設計された80億パラメータの命令モデルで、GPT-3.5-turboに匹敵する性能を持ち、アプリケーションシナリオ、検索拡張生成、制限付き生成、推論タスクを最適化
大規模言語モデル
Transformers 複数言語対応

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-TinyはSODAデータセットでトレーニングされた超小型対話モデルで、エッジデバイス推論向けに設計されており、体積はCosmo-3Bモデルの約2%です。
対話システム
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
RoBERTaアーキテクチャに基づく中国語抽出型QAモデルで、与えられたテキストから回答を抽出するタスクに適しています。
質問応答システム 中国語
R
uer
2,694
98