A Weakly Supervised Adaptive Densenet for Classifying Thoracic Diseases and Identifying Abnormalities
Bo Zhou, Yuemeng Li, Jiangcong Wang
[Paper]
This repository contains the PyTorch implementation of adaptive densenet for chest x-ray's weakly supervised learning.
If you use this code for your research or project, please cite:
@article{zhou2018weakly,
title={A weakly supervised adaptive densenet for classifying thoracic diseases and identifying abnormalities},
author={Zhou, Bo and Li, Yuemeng and Wang, Jiangcong},
journal={arXiv preprint arXiv:1807.01257},
year={2018}
}
Requirements:
- Python 3.7
- Pytorch 0.4.1
- scipy
- scikit-image
- opencv-python
- tqdm
Our code has been tested with Python 3.7, Pytorch 0.4.1, CUDA 10.0 on Ubuntu 18.04.
../
Data/
ChestXray14
├── images # contain all the 1024x1024 imaging data in .png format
│ ├── 00000001_000.png
│ ├── 00000001_001.png
│ ├── ...
│ └── 00030805_000.png
│
├── labels # contain train / val / test .txt label splitted files
│ ├── train_list.txt
│ ├── val_list.txt
│ └── test_list.txt
│
└── ...
Each .png is an image data with intensity ranged between 0~255.
Please download the ChestXray14 dataset from LINK.
- Train the model
python train.py --experiment_name 'train_ChestXray14_densenetADA' --model_type 'model_wsl' --dataset 'ChestXray14' --data_root '../Data/ChestXray14/' --net_G 'densenetADA' --n_class 14 --batch_size 36 --lr 1e-4 --eval_epochs 4 --save_epochs 4 --snapshot_epochs 4 --AUG --gpu_ids 0
where
--experiment_name
provides the experiment name for the current run, and save all the corresponding results under the experiment_name's folder.
--data_root
provides the data folder directory (with structure illustrated above).
--AUG
adds for using data augmentation option (rotation, random cropping, scaling).
Other hyperparameters can be adjusted in the code as well.
- Test the model
python test.py --resume './outputs/train_ChestXray14_densenetADA/checkpoints/model_best.pt' --experiment_name 'test_ChestXray14_densenetADA' --model_type 'model_wsl' --data_root '../Data/ChestXray14/' --net_G 'densenetADA' --gpu_ids 0
where
--resume
defines which checkpoint for testing and evaluation. The 'model_best.pt' can be generated by training the model.
The test will output an eval.mat containing model's prediction and weakly supervised heatmaps for evaluation in the '--experiment_name' folder.
Sample training/test scripts are provided under './scripts/' and can be directly executed.
If you have any question, please file an issue or contact the author:
Bo Zhou: [email protected]