> **Note**
>
> **欢迎关注我们最新的工作:CareLlama (关怀羊驼),它是一个医疗大语言模型,同时它集合了数十个公开可用的医疗微调数据集和开放可用的医疗大语言模型以促进医疗LLM快速发展:https://github.com/WangRongsheng/CareLlama**
>
> 在开始看这个项目之前,您应该是保持以学术研究的态度,切不可以实际医疗行为作为评价该项目的标准。我们相信很多事情正是因为有了一步一步的积累才会最终走向成功!
>
> 为了更好助力中文社区的医学多模态大模型发展,我们特意在该Repo开设了[💬Discussions](https://github.com/WangRongsheng/XrayGLM/discussions) ,帮助大家互相学习。
## 介绍
最近,通用领域的大语言模型 (LLM),例如 ChatGPT,在遵循指令和产生类似人类响应方面取得了显著的成功,这种成功间接促进了多模态大模型的研究和发展,如通用领域的多模态大模型[MiniGPT-4](https://github.com/Vision-CAIR/MiniGPT-4)、[mPLUG-Owl](https://github.com/X-PLUG/mPLUG-Owl)、[Multimodal-GPT](https://github.com/open-mmlab/Multimodal-GPT)和[LLaVA](https://github.com/haotian-liu/LLaVA) ,然而,此类多模态大模型却很少出现在医学领域的研究中,阻碍了相关研究发展。[visual-med-alpaca](https://github.com/cambridgeltl/visual-med-alpaca)虽然在医学多模态大模型方面做出了一些很有成效的工作,然而其数据为英文诊断报告,不利于促进中文领域医学多模态大模型的研究发展。为此,我们开发了`XrayGLM`以解决上述问题。`XrayGLM`在医学影像诊断和多轮交互对话上显示出了非凡的潜力。
![](./assets/images/hx.png)
<p align="center">
<a href='https://github.com/WangRongsheng/XrayGLM'>
<img src='https://img.shields.io/badge/Project-Page-Green'>
</a>
<a href='https://github.com/WangRongsheng/XrayGLM'>
<img src='https://img.shields.io/badge/Paper-Arxiv-red'>
</a>
<a href="https://colab.research.google.com/drive/1aR8SSaseyprsxnor-gDyMo96V9jD7iGP?usp=sharing">
<img alt="GitHub Contributors" src="https://colab.research.google.com/assets/colab-badge.svg" />
</a>
<a href='https://huggingface.co/wangrongsheng'>
<img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue'>
</a>
</br>
<a href="https://github.com/WangRongsheng/XrayGLM/graphs/contributors">
<img alt="GitHub Contributors" src="https://img.shields.io/github/contributors/WangRongsheng/XrayGLM" />
</a>
<a href="https://github.com/WangRongsheng/XrayGLM/issues">
<img alt="Issues" src="https://img.shields.io/github/issues/WangRongsheng/XrayGLM?color=0088ff" />
</a>
<a href="https://github.com/WangRongsheng/XrayGLM/pulls">
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/WangRongsheng/XrayGLM?color=0088ff" />
</a>
<a href=href="https://github.com/WangRongsheng/XrayGLM/stargazers">
<img src="https://img.shields.io/github/stars/WangRongsheng/XrayGLM?color=ccf">
</a>
<a href=href="https://github.com/WangRongsheng/XrayGLM">
<img src="https://img.shields.io/github/repo-size/WangRongsheng/XrayGLM.svg?style=flat-square">
</a>
</br>
<a href=href="https://github.com/WangRongsheng/XrayGLM">
<img src="https://visitor-badge.laobi.icu/badge?page_id=https://github.com/WangRongsheng/XrayGLM">
</a>
<a href=href="https://github.com/WangRongsheng/XrayGLM">
<img src="https://img.shields.io/github/last-commit/WangRongsheng/XrayGLM">
</a>
<a href="https://github.com/WangRongsheng/XrayGLM/blob/main/LICENSE">
<img alt="GitHub Contributors" src="https://img.shields.io/badge/License-CC%20BY--NC--SA%204.0-lightgrey.svg" />
</a>
</p>
||||
|:-|:-|:-|
|🌟[【官方视频教程】ChatGLM-6B 微调:P-Tuning,LoRA,Full parameter](https://www.bilibili.com/video/BV1fd4y1Z7Y5/)|🌟[【官方视频教程】VisualGLM技术讲解](https://www.bilibili.com/video/BV14L411q7fk/)|🌟[【官方视频教程】XrayGLM微调实践](https://www.bilibili.com/video/BV1Yh4y147gx/)|
## 本文贡献
![](./assets/images/xrayglm.png)
- 借助ChatGPT以及公开的数据集,我们构造了一个`X光影像-诊断报告`对的医学多模态数据集;
- 我们将构建的中文胸部X光片诊断数据集在[VisualGLM-6B](https://github.com/THUDM/VisualGLM-6B)进行微调训练,并开放了部分训练权重用于学术研究;
## 数据集
- [MIMIC-CXR](https://physionet.org/content/mimic-cxr-jpg/2.0.0/)是一个公开可用的胸部X光片数据集,包括377,110张图像和227,827个相关报告。
- [OpenI](https://openi.nlm.nih.gov/faq#collection)是一个来自印第安纳大学医院的胸部X光片数据集,包括6,459张图像和3,955个报告。
在上述工作中,报告信息都为非结构化的,不利于科学研究。为了生成合理的医学报告,我们对两个数据集进行了预处理,并最终得到了可以用于训练的**英文报告**。除此之外,为了更好的支持中文社区发展,借助ChatGPT的能力,我们将英文报告进行了中文翻译,并最终形成了可用于训练的数据集。
|数据集|数量|下载链接|质量|
|:-|:-|:-|:-|
|MIMIC-CXR-zh|-|-|-|
|OpenI-zh|6,423|[诊疗报告(英文)](./data/openi-en.json)、[诊疗报告(中文)](./data/Xray/openi-zh.json) 、[X光影像](https://pan.baidu.com/s/13GBsDMKf6xBZBSHpoWH_EA?pwd=k9sh)|低|
|OpenI-zh-plus|6,423|-|高|
## 快速上手
### 1.安装环境
```bash
# 安装依赖
pip install -r requirements.txt
# 国内换源安装依赖
pip install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements.txt
```
此时默认会安装`deepspeed`库(支持`sat`库训练),此库对于模型推理并非必要,同时部分`Windows`环境安装此库时会遇到问题。 如果想绕过`deepspeed`安装,我们可以将命令改为:
```bash
# 安装依赖
pip install -i https://mirrors.aliyun.com/pypi/simple/ -r requirements_wo_ds.txt
# 安装SwissArmyTransformer
pip install -i https://mirrors.aliyun.com/pypi/simple/ --no-deps "SwissArmyTransformer>=0.3.6"
```
### 2.模型推理
|模型权重|下载链接|质量|微调方法|
|:-|:-|:-|:-|
|checkpoints-XrayGLM-300|<a href='https://huggingface.co/wangrongsheng/XrayGLM-300'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue'></a>|低|LoRA|
|checkpoints-XrayGLM-3000|<a href='https://huggingface.co/wangrongsheng/XrayGLM-3000'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue'></a>|低|LoRA|
|checkpoints-XrayGLM-xxx-plus|-|高|-|
#### CLI推理
```python
python cli_demo.py --from_pretrained checkpoints/checkpoints-XrayGLM-3000 --prompt_zh '详细描述这张胸部X光片的诊断结果'
```
更多[参数](https://github.com/WangRongsheng/XrayGLM/blob/main/cli_demo.py#L16)
如果您是**Google Colab Pro**会员,请可以直接在Colab中运行XrayGLM:<a href="https://colab.research.google.com/drive/1aR8SSaseyprsxnor-gDyMo96V9jD7iGP?usp=sharing"><img alt="GitHub Contributors" src="https://colab.research.google.com/assets/colab-badge.svg" /></a>
#### WebUI运行
```python
python web_demo.py --from_pretrained checkpoints/checkpoints-XrayGLM-3000
```
此时访问`http://127.0.0.1:7860`即可
![](./assets/images/web_demo.png)
### 3.模型训练(复现XrayGLM)
<details>
<summary>硬件资源</summary>
<p>* 实验在A100 (4X, 80GB)上进行</p>
</details>
- (1)准备[诊疗报告(中文)](./data/Xray/openi-zh.json)和[X光影像](https://pan.baidu.com/s/13GBsDMKf6xBZBSHpoWH_EA?pwd=k9sh)在`data/Xray`文件夹下;
- (2)开始训练:
```bash
# 设置CUDA变量,主要是为了解决有时候直接训练而出现无法正确加载到显卡问题
export CUDA_VISIBLE_DEVICES
没有合适的资源?快使用搜索试试~ 我知道了~
XrayGLM-main.zip
共58个文件
png:26个
py:16个
json:4个
需积分: 5 0 下载量 84 浏览量
2024-03-24
12:33:34
上传
评论
收藏 9.35MB ZIP 举报
温馨提示
XrayGLM-main
资源推荐
资源详情
资源评论
收起资源包目录
XrayGLM-main.zip (58个子文件)
XrayGLM-main
assets
images
mpu.png 911KB
xrayglm.png 204KB
hx.png 21KB
web_demo.png 97KB
train_cli.txt 1KB
XrayGLM_inference.ipynb 43KB
data
merge_ch2json.py 611B
openi-en.json 2.65MB
openi-ch-random.json 4.4MB
translation_en2zh.py 1KB
demo
katong.png 212KB
pig.png 191KB
music.png 277KB
woman.png 375KB
dataset.json 3KB
tower.png 463KB
tianye.png 747KB
pattern.png 140KB
titan.png 682KB
traf.png 136KB
2p.png 234KB
panda.jpg 5KB
passport.png 250KB
kobe.png 162KB
rou.png 776KB
man.jpg 61KB
ghost.jpg 58KB
rub.png 300KB
meme.png 137KB
justice.png 1.18MB
push.png 117KB
from_xml_get_images_id.py 788B
json2md.py 476B
Xray
2_1.png 191KB
2882_1.png 131KB
2577_1.png 117KB
861_1.png 206KB
2_2.png 153KB
openi-zh.json 3.79MB
build_ch_prompt-random.py 1015B
build_ch_prompt.py 609B
build_images_data.py 437B
LICENSE 20KB
cli_demo.py 4KB
lora_mixin.py 13KB
CITATION.cff 505B
web_demo.py 7KB
finetune_XrayGLM.sh 1KB
model
__init__.py 91B
visualglm.py 2KB
chat.py 7KB
infer_util.py 2KB
blip2.py 4KB
requirements.txt 113B
finetune_XrayGLM.py 8KB
checkpoints
README.md 30B
README.md 14KB
requirements_wo_ds.txt 118B
共 58 条
- 1
资源评论
电子小白的每一天
- 粉丝: 164
- 资源: 37
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功