README.md 5.7 KB
Newer Older
MPU王荣胜's avatar
MPU王荣胜 committed
1
2
# XrayGLM

MPU王荣胜's avatar
MPU王荣胜 committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 <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://github.com/WangRongsheng/XrayGLM'>
            <img src='https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-Spaces-blue'>
      </a>
      <a href="https://github.com/WangRongsheng/XrayGLM">
        <img alt="GitHub Contributors" src="https://colab.research.google.com/assets/colab-badge.svg" />
      </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>
      </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/kaixindelele/XrayGLM/stargazers">
        <img src="https://img.shields.io/github/stars/WangRongsheng/XrayGLM?color=ccf">
      </a>
  </p>
MPU王荣胜's avatar
MPU王荣胜 committed
33
  
MPU王荣胜's avatar
MPU王荣胜 committed
34
35
36
# 本文贡献

![](./assets/images/xrayglm.png)
MPU王荣胜's avatar
MPU王荣胜 committed
37

MPU王荣胜's avatar
MPU王荣胜 committed
38
- 借助ChatGPT以及公开的数据集,我们构造了一个`X光影像-诊断报告`对的医学多模态数据集;
MPU王荣胜's avatar
MPU王荣胜 committed
39
  
MPU王荣胜's avatar
MPU王荣胜 committed
40
41
# 数据集

MPU王荣胜's avatar
MPU王荣胜 committed
42
43
- [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个报告。
MPU王荣胜's avatar
MPU王荣胜 committed
44

MPU王荣胜's avatar
MPU王荣胜 committed
45
46
47
48
49
在上述工作中,报告信息都为非结构化的,不利于科学研究。为了生成合理的医学报告,我们对两个数据集进行了预处理,并最终得到了可以用于训练的**英文报告**。除此之外,为了更好的支持中文社区发展,借助ChatGPT的能力,我们将英文报告进行了中文翻译,并最终形成了可用于训练的数据集。

|数据集|数量|下载链接|
|:-|:-|:-|
|MIMIC-CXR-zh|-|-|
MPU王荣胜's avatar
MPU王荣胜 committed
50
|OpenI-zh|6,423|[诊疗报告](./data/Xray/openi-zh.json)[X光影像](https://pan.baidu.com/s/13GBsDMKf6xBZBSHpoWH_EA?pwd=k9sh)|
MPU王荣胜's avatar
MPU王荣胜 committed
51

MPU王荣胜's avatar
MPU王荣胜 committed
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# 快速上手

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. 模型推理


MPU王荣胜's avatar
MPU王荣胜 committed
71
# 项目致谢
MPU王荣胜's avatar
MPU王荣胜 committed
72

MPU王荣胜's avatar
MPU王荣胜 committed
73
1. [VisualGLM-6B](https://github.com/THUDM/VisualGLM-6B)为我们提供了基础的代码参考和实现;
MPU王荣胜's avatar
MPU王荣胜 committed
74
2. [MiniGPT-4](https://github.com/Vision-CAIR/MiniGPT-4)为我们这个项目提供了研发思路;
MPU王荣胜's avatar
MPU王荣胜 committed
75
3. ChatGPT生成了高质量的中文版X光检查报告以支持XrayGLM训练;
MPU王荣胜's avatar
MPU王荣胜 committed
76
4. [gpt_academic](https://github.com/binary-husky/gpt_academic)为文档翻译提供了多线程加速;
MPU王荣胜's avatar
MPU王荣胜 committed
77
5. [MedCLIP](https://github.com/RyanWangZf/MedCLIP)[BLIP2](https://huggingface.co/docs/transformers/main/model_doc/blip-2)[XrayGPT](https://github.com/mbzuai-oryx/XrayGPT) 等工作也有重大的参考意义;
MPU王荣胜's avatar
MPU王荣胜 committed
78

MPU王荣胜's avatar
MPU王荣胜 committed
79
80
![](./assets/images/mpu.png)

MPU王荣胜's avatar
MPU王荣胜 committed
81
82
这项工作由[澳门理工大学应用科学学院](https://www.mpu.edu.mo/esca/zh/index.php)硕士生[王荣胜](https://github.com/WangRongsheng)[段耀菲](https://github.com/IsBaSO4)[李俊蓉](https://github.com/lijunrong0815)完成,同时这项工作受到[檀韬](https://scholar.google.com/citations?hl=zh-CN&user=lLg3WRkAAAAJ)副教授、[彭祥佑](http://www.patrickpang.net/)老师的帮助支持。

MPU王荣胜's avatar
MPU王荣胜 committed
83
*特别鸣谢:[USTC-PhD Yongle Luo](https://github.com/kaixindelele) 提供了有3000美金的OpenAI账号,帮助我们完成大量的X光报告翻译工作
MPU王荣胜's avatar
MPU王荣胜 committed
84

MPU王荣胜's avatar
MPU王荣胜 committed
85
86
87
# 免责声明

本项目相关资源仅供学术研究之用,严禁用于商业用途。使用涉及第三方代码的部分时,请严格遵循相应的开源协议。模型生成的内容受模型计算、随机性和量化精度损失等因素影响,本项目无法对其准确性作出保证。即使本项目模型输出符合医学事实,也不能被用作实际医学诊断的依据。对于模型输出的任何内容,本项目不承担任何法律责任,亦不对因使用相关资源和输出结果而可能产生的任何损失承担责任。
MPU王荣胜's avatar
MPU王荣胜 committed
88
89
90
91
92
93
94

# 项目引用

如果你使用了本项目的模型,数据或者代码,请声明引用:

```bash
@misc{wang2023XrayGLM,
MPU王荣胜's avatar
MPU王荣胜 committed
95
      title={XrayGLM: The first Chinese Medical Multimodal Model that Chest Radiographs Summarization}, 
MPU王荣胜's avatar
MPU王荣胜 committed
96
97
98
99
100
101
102
      author={Rongsheng Wang, Yaofei Duan, Junrong Li, Patrick Pang and Tao Tan},
      year={2023},
      publisher = {GitHub},
      journal = {GitHub repository},
      howpublished = {\url{https://github.com/WangRongsheng/XrayGLM}},
}
```
MPU王荣胜's avatar
MPU王荣胜 committed
103

MPU王荣胜's avatar
MPU王荣胜 committed
104
105
106
# 使用许可

此存储库遵循[CC BY-NC-SA](https://creativecommons.org/licenses/by-nc-sa/4.0/) ,请参阅许可条款。
MPU王荣胜's avatar
MPU王荣胜 committed
107