From de55c2052e84dc7df42e7f688ab4fafaccd0dfe8 Mon Sep 17 00:00:00 2001 From: taigw Date: Mon, 23 Feb 2026 13:21:13 +0800 Subject: [PATCH] update configure files update configure files --- seg_full_sup/2d_JSRT/README.md | 10 ++- seg_full_sup/2d_JSRT/bash.sh | 23 ++++-- seg_full_sup/2d_JSRT/config/unet.cfg | 3 +- .../2d_JSRT/config/unet_attention.cfg | 73 +++++++++++++++++++ seg_full_sup/2d_JSRT/config/unet_scse.cfg | 5 +- seg_full_sup/2d_JSRT/config/unetpp.cfg | 3 +- 6 files changed, 101 insertions(+), 16 deletions(-) create mode 100644 seg_full_sup/2d_JSRT/config/unet_attention.cfg diff --git a/seg_full_sup/2d_JSRT/README.md b/seg_full_sup/2d_JSRT/README.md index 5b6127e..fd7373b 100644 --- a/seg_full_sup/2d_JSRT/README.md +++ b/seg_full_sup/2d_JSRT/README.md @@ -7,8 +7,9 @@ In this example, we use different 2D networks to segment the lung from X-Ray ima |Network |Reference | Remarks| |---|---| ---| -|UNet2D | [Ronneberger et al., MICCAI 2015][unet_paper]| 2D Unet| -|UNet2D_ScSE |[Roy et al., TMI 2019][scse_paper]| 2D UNe with spatial and channel attention | +|UNet | [Ronneberger et al., MICCAI 2015][unet_paper]| 2D Unet| +|UNet_ScSE |[Roy et al., TMI 2019][scse_paper]| 2D UNet with spatial and channel attention | +|AttentionUNet |[Oktay et al., MIDL 2018][attunet_paper]| Attention UNet with spatial attention | |CANet| [Gu et al., TMI 2021][canet_paper]| Comprehensive Attentin Network| |COPLENet | [Wang et al., TMI 2020][coplenet]| Originally for Covid-19 lesion segmentation| |UNet++ | [Zhou et al., MICCAI Workshop 2018][unet++]| Nested 2D UNet | @@ -17,6 +18,7 @@ In this example, we use different 2D networks to segment the lung from X-Ray ima [unet_paper]:https://link.springer.com/chapter/10.1007/978-3-319-24574-4_28 [scse_paper]:https://ieeexplore.ieee.org/document/8447284 +[attunet_paper]:https://arxiv.org/abs/1804.03999 [canet_paper]:https://ieeexplore.ieee.org/abstract/document/9246575 [coplenet]:https://ieeexplore.ieee.org/document/9109297 [unet++]:https://link.springer.com/chapter/10.1007/978-3-030-00889-5_1 @@ -119,7 +121,7 @@ pymic_test config/coplenet.cfg 3. Use the following command to obtain quantitative evaluation results in terms of Dice. ```bash -pymic_eval_seg -cfg config/evaluation.cfg +pymic_eval_seg --cfg config/evaluation.cfg ``` The obtained average Dice score by default setting should be close to 98.04%. The Average Symmetric Surface Distance (ASSD) is also calculated. @@ -127,5 +129,5 @@ The obtained average Dice score by default setting should be close to 98.04%. Th ## 3. Training and testing with other networks -For the other networks, please replace `config/coplenet.cfg` by the corresponding configuration files during the training and prediction stages. See `config/***.cfg` for examples of other networks, such as UNet, CANet, UNet++, TransUNet and SwinUNet. +For the other networks, please replace `config/coplenet.cfg` by the corresponding configuration files during the training and prediction stages. See `config/***.cfg` for examples of other networks, such as UNet, CANet, AttentionUNet, UNet++, TransUNet and SwinUNet. diff --git a/seg_full_sup/2d_JSRT/bash.sh b/seg_full_sup/2d_JSRT/bash.sh index f53a124..e61a6ce 100644 --- a/seg_full_sup/2d_JSRT/bash.sh +++ b/seg_full_sup/2d_JSRT/bash.sh @@ -1,16 +1,23 @@ -# PyMICPATH=/home/disk4t/projects/PyMIC_project/PyMIC -PyMICPATH=/home/disk4t/projects/PyMIC_project/Pypi_test/PyMIC-dev +PyMICPATH=/home/disk4t/projects/PyMIC_project/PyMIC +# PyMICPATH=/home/disk4t/projects/PyMIC_project/Pypi_test/PyMIC-dev export PYTHONPATH=$PYTHONPATH:$PyMICPATH +# python $PyMICPATH/pymic/net_run/train.py config/canet.cfg +# python $PyMICPATH/pymic/net_run/train.py config/unet_attention.cfg +# python $PyMICPATH/pymic/net_run/train.py config/unetpp.cfg # python $PyMICPATH/pymic/net_run/train.py config/unet.cfg -# python $PyMICPATH/pymic/net_run/predict.py config/unet.cfg -# python $PyMICPATH/pymic/util/evaluation_seg.py -cfg config/evaluation.cfg +# python $PyMICPATH/pymic/net_run/train.py config/coplenet.cfg \ +# --ckpt_dir model_test/copplenet --iter_max 500 +# python $PyMICPATH/pymic/net_run/train.py config/swinunet.cfg +# python $PyMICPATH/pymic/net_run/train.py config/transunet.cfg +# python $PyMICPATH/pymic/net_run/train.py config/unet_scse.cfg +python $PyMICPATH/pymic/util/evaluation_seg.py --cfg config/evaluation.cfg -python $PyMICPATH/pymic/net_run/train.py config/unet.cfg \ --ckpt_dir model_test/unet -iter_max 500 +# python $PyMICPATH/pymic/net_run/train.py config/unet.cfg \ +# -ckpt_dir model_test/unet -iter_max 500 -python $PyMICPATH/pymic/net_run/train.py config/unet_scse.cfg \ --ckpt_dir model_test/unet -iter_max 500 +# python $PyMICPATH/pymic/net_run/train.py config/unet_scse.cfg \ +# -ckpt_dir model_test/unet -iter_max 500 #pymic_run train config/unet.cfg #pymic_run test config/unet.cfg diff --git a/seg_full_sup/2d_JSRT/config/unet.cfg b/seg_full_sup/2d_JSRT/config/unet.cfg index 4f23b1a..eb0aa81 100644 --- a/seg_full_sup/2d_JSRT/config/unet.cfg +++ b/seg_full_sup/2d_JSRT/config/unet.cfg @@ -23,9 +23,10 @@ LabelConvert_target_list = [0, 1] [network] # type of network -net_type = UNet2D +net_type = UNet # number of class, required for segmentation task +dimension = 2 class_num = 2 in_chns = 1 feature_chns = [16, 32, 64, 128, 256] diff --git a/seg_full_sup/2d_JSRT/config/unet_attention.cfg b/seg_full_sup/2d_JSRT/config/unet_attention.cfg new file mode 100644 index 0000000..02b8a0a --- /dev/null +++ b/seg_full_sup/2d_JSRT/config/unet_attention.cfg @@ -0,0 +1,73 @@ +[dataset] +# tensor type (float or double) +tensor_type = float + +task_type = seg +train_dir = ../../PyMIC_data/JSRT +train_csv = config/jsrt_train.csv +valid_csv = config/jsrt_valid.csv +test_csv = config/jsrt_test.csv + +train_batch_size = 4 + +# data transforms +train_transform = [NormalizeWithMeanStd, RandomCrop, LabelConvert, LabelToProbability] +valid_transform = [NormalizeWithMeanStd, LabelConvert, LabelToProbability] +test_transform = [NormalizeWithMeanStd] + +NormalizeWithMeanStd_channels = [0] +RandomCrop_output_size = [224, 224] + +LabelConvert_source_list = [0, 255] +LabelConvert_target_list = [0, 1] + +[network] +# type of network +net_type = AttentionUNet + +# number of class, required for segmentation task +dimension = 2 +class_num = 2 +in_chns = 1 +feature_chns = [16, 32, 64, 128, 256] +dropout = [0, 0, 0.3, 0.4, 0.5] + +[training] +# list of gpus +gpus = [0] + +loss_type = DiceLoss + +# for optimizers +optimizer = Adam +learning_rate = 1e-3 +momentum = 0.9 +weight_decay = 1e-5 + +# for lr scheduler (MultiStepLR) +lr_scheduler = MultiStepLR +lr_gamma = 0.5 +lr_milestones = [1500, 3000, 4500] + +ckpt_dir = model/unet_attention + +# start iter +iter_max = 6000 +iter_valid = 250 +iter_save = 6000 + +[testing] +# list of gpus +gpus = [2] + +# checkpoint mode can be [0-latest, 1-best, 2-specified] +ckpt_mode = 1 +output_dir = result/unet_attention + +sliding_window_enable = True +sliding_window_size = [224, 224] +sliding_window_stride = [224, 224] + +# convert the label of prediction output +label_source = [0, 1] +label_target = [0, 255] diff --git a/seg_full_sup/2d_JSRT/config/unet_scse.cfg b/seg_full_sup/2d_JSRT/config/unet_scse.cfg index cec464b..d0d83a7 100644 --- a/seg_full_sup/2d_JSRT/config/unet_scse.cfg +++ b/seg_full_sup/2d_JSRT/config/unet_scse.cfg @@ -23,10 +23,11 @@ LabelConvert_target_list = [0, 1] [network] # type of network -net_type = UNet2D_ScSE +net_type = UNet_ScSE # number of class, required for segmentation task -class_num = 2 +dimension = 2 +class_num = 2 in_chns = 1 feature_chns = [16, 32, 64, 128, 256] dropout = [0.0, 0.0, 0.3, 0.4, 0.5] diff --git a/seg_full_sup/2d_JSRT/config/unetpp.cfg b/seg_full_sup/2d_JSRT/config/unetpp.cfg index f57d6df..4487251 100644 --- a/seg_full_sup/2d_JSRT/config/unetpp.cfg +++ b/seg_full_sup/2d_JSRT/config/unetpp.cfg @@ -23,9 +23,10 @@ LabelConvert_target_list = [0, 1] [network] # type of network -net_type = UNet2Dpp +net_type = UNetpp # number of class, required for segmentation task +dimension = 2 class_num = 2 in_chns = 1 feature_chns = [16, 32, 64, 128, 256]