DiffMIC is a project to adapt Diffusion Probabilistic Models to general medical image classification by dual-granularity conditional guidance. The method is elaborated in the paper DiffMIC: Dual-Guidance Diffusion Network for Medical Image Classification.
conda env create -f environment.yml
or you can simply create your own env and
either use your own env if the libraries are added
- Download HAM10000 or APTOS2019 dataset or any dataset you want but you should create a pkl file and customize the database based on the infos .we added a custome loader dataset on the root for this situation. Your dataset folder under "your_data_path" should be like:
dataset/isic2018/
images/...
ISIC2018_Task3_Training_GroundTruth.csv
isic2018_train.pkl
isic2018_test.pkl
.pkl file contains the list of data whose element is a dictionary with the format as {'img_root':image_path,'label':label}
-
For Training! run:
bash training_scripts/run_isic.sh
where the first command line is usedpython main.py --device ${DEVICE_ID} --thread ${N_THREADS} --loss ${LOSS} --config configs/${TASK}.yml --exp $EXP_DIR/${MODEL_VERSION_DIR} --doc ${TASK} --n_splits ${N_SPLITS}
-
For Testing! run:
bash training_scripts/run_isic.sh
where the second command line is usedpython main.py --device ${DEVICE_ID} --thread ${N_THREADS} --loss ${LOSS} --config $EXP_DIR/${MODEL_VERSION_DIR}/logs/ --exp $EXP_DIR/${MODEL_VERSION_DIR} --doc ${TASK} --n_splits ${N_SPLITS} --test --eval_best
The configuration for each of the above-listed tasks (including data file location, training log and evaluation result directory settings, neural network architecture, optimization hyperparameters, etc.) are provided in the corresponding files in the configs
directory
Code is largely based on XzwHan/CARD, CompVis/stable-diffusion, MedSegDiff, nyukat/GMIC