hsiangyuzhao / RCPS

official implementation of rectified contrastive pseudo supervision
MIT License
57 stars 3 forks source link

关于半监督训练 #15

Closed yyyyy-aa closed 4 months ago

yyyyy-aa commented 4 months ago

您好,我在前10个epoch的训练中,阶段性的得到了这样的结果,这是全监督还是半监督呢? wandb: Run summary: wandb: train/train_contrastive_l_loss_mean 0.98026 wandb: train/train_contrastive_u_loss_mean 1.18749 wandb: train/train_cosine_l_loss_mean 0.36995 wandb: train/train_cosine_u_loss_mean 0.49217 wandb: train/train_cps_l_loss_mean 1.59464 wandb: train/train_cps_u_loss_mean 2.29451 wandb: train/train_seg_loss_mean 5.00324 wandb: val/val_loss_mean 1.86493 wandb: val/val_metric_mean 0.6811

终端的部分输出如下: Semi-Supervised Medical Image Segmentation Training Mixed Precision - True; CUDNN Benchmark - True; Num GPU - 1; Num Worker - 8 successfully loaded config file: {'MODEL': {'PROJECT_DIM': 64, 'LEAKY': True, 'NORM': 'BATCH'}, 'TRAIN': {'LR': 0.01, 'MOMENTUM': 0.9, 'DECAY': 0.0001, 'BURN_IN': 5, 'BURN': 0, 'RAMPUP': 100, 'EPOCHS': 100, 'BATCHSIZE': 1, 'SEED': 42, 'RATIO': 0.1, 'LOSS_TYPE': 1, 'SAMPLE_NUM': 400, 'BUFFER_SIZE': 1, 'CPS_RATIO': 0.1, 'CON_RATIO': 0.1}, 'TEST': {'BATCHSIZE': 4}} Task la prepared. Num labeled subjects: 8; Num unlabeled subjects: 72; Num validation subjects: 20 这里我把ratio设置为0.1,但我的数据文件夹是按照训练和验证,图像和标签,分为四个子文件夹的,且我没有将您在readme文档半监督训练需要进行替换的代码放进train.py文件,那么理论上应当按照全监督去训练。不过运行结果里显示还是有Num unlabeled subjects: 72。请问在全监督训练中是如何保证有标注图像中ratio以外的数据没有参与到训练中的呢?

期待您百忙之中的回答,祝您工作顺利,生活愉快。

hsiangyuzhao commented 4 months ago

In models/segmentation_model.py, please refer to set_input function, the segmentation mask of unlabeled image remains untouched during data loading.
Thus, the model would not have access to the actual segmentation mask of unlabeled image, as long as it is viewed as unlabeled.

hsiangyuzhao commented 4 months ago

In Training in Real Semi-Supervision Scenario, the labels of certain image are not available. Thus we need different loaders to handle them.
In the paper, the "unlabeled" images are actually "labeled", but we view them as "unlabeled", since we do not use their segmentation masks for supervision.