训练测试代码主入口:
main_basic.py: basic model
main_conditional.py: 使用一个condition的model
main_multi_conditional.py: 使用多个condition的model
所有代码运行所需参数已经在config文件中设置好
运行命令只需指定配置文件和所需使用的gpu id
示例:
python main<model>.py --cfg config/iu_con_1.yml --gpu 0
Python >= 3.6Pytorch >= 1.7torchvison- Microsoft COCO Caption Evaluation Tools
- CheXpert
Download IU and MIMIC-CXR datasets, and place them in data folder.
- config : setup training arguments and data path
- data : store IU and MIMIC dataset
- Models: basic model and all our models
- the layer define of our model
- loss function
- metrics
- some utils
- data_loader.py: dataloader
- build_vocab.py: tokenizer
- preprocessing: data preprocess
- pycocoevalcap: Microsoft COCO Caption Evaluation Tools
-
data- Download and unzip IU dataset to here
-
preprocess_data.py- Create dataset split for IU dataset.
- Preprocess report for normalizion, such as lower-case, replacing nonsense tokens(e.g., 'xxxx-a-xxxx').
- Build vocabulary file.
-
extract_feature.py- Extract visual feature for retrieve conditional image.
-
retieve_conditional_pair.py- Retrieve conditional image using cosine similarity.
- dataset: iu / mimic
-
main_<model>.py- The model will be trained using command
python main_<model>.py --cfg config/<dataset_N> --expe_name <experiment name> --gpu <GPU_ID> - More options can be found in
config/opts.pyfile.
- The model will be trained using command
-
ModelsBasic.py: Basic ModelConditional.py: DeltaNet condition generation modelMultiConditional.py: DeltaNet multiple conditional generation modelGenerator.pyandBeam.py: Generate report using beam searchModules.py: Implement of scaled dot-product attentionSubLayers.py: Implement of multi-head attentionmisc.pyandutils.py: Utils function
test.py: Generate report from trained model using command python test.py --pretrained <path to the checkpoint file>
-
metrics.py- Evaluate the generated report.
-
pycocoevalcap- Microsoft COCO Caption Evaluation Tools
- Need clone from GitHub and modified the code to work with Python 3
Xian Wu, Shuxin Yang, Zhaopeng Qiu, Shen Ge, Yangtian Yan, Xingwang Wu, S.Kevin Zhou, Li Xiao. DeltaNet: Conditional Medical Report Generation for COVID-19 Diagnosis. Coling, 2022
If you have any problem with the code, please contact Xian Wu(kevinxwu@tencent.com), Shuxin Yang(aspenstarss@gmail.com) or Li Xiao(andrew.lxiao@gmail.com).
Joseph Paul Cohen, Joseph D. Viviano, Paul Bertin, Paul Morrison, Parsa Torabian, Matteo Guarrera, Matthew P Lungren, Akshay Chaudhari, Rupert Brooks, Mohammad Hashir, Hadrien Bertrand. TorchXRayVision: A library of chest X-ray datasets and models. Medical Imaging with Deep Learning. https://github.com/mlmed/torchxrayvision, 2020