pymic.net_run.semi_sup package

Submodules

pymic.net_run.semi_sup.ssl_abstract module

class pymic.net_run.semi_sup.ssl_abstract.SSLSegAgent(config, stage='train')

Bases: SegmentationAgent

Abstract class for semi-supervised segmentation.

Parameters:
  • config – (dict) A dictionary containing the configuration.

  • stage – (str) One of the stage in train (default), inference or test.

Note

In the configuration dictionary, in addition to the four sections (dataset, network, training and inference) used in fully supervised learning, an extra section semi_supervised_learning is needed. See Semi-Supervised Learning for details.

create_dataset()

Create datasets for training, validation or testing based on configuraiton.

get_unlabeled_dataset_from_config()

Create a dataset for the unlabeled images based on configuration.

train_valid()

Train and valid.

write_scalars(train_scalars, valid_scalars, lr_value, glob_it)

Write scalars using SummaryWriter.

Parameters:
  • train_scalars – (dictionary) Scalars for training set.

  • valid_scalars – (dictionary) Scalars for validation set.

  • lr_value – (float) Current learning rate.

  • glob_it – (int) Current iteration number.

pymic.net_run.semi_sup.ssl_cct module

class pymic.net_run.semi_sup.ssl_cct.SSLCCT(config, stage='train')

Bases: SSLSegAgent

Cross-Consistency Training for semi-supervised segmentation. It requires a network with multiple decoders for learning, such as pymic.net.net2d.unet2d_cct.UNet2D_CCT.

  • Reference: Yassine Ouali, Celine Hudelot and Myriam Tami: Semi-Supervised Semantic Segmentation With Cross-Consistency Training. CVPR 2020.

The Code is adapted from Github

Parameters:
  • config – (dict) A dictionary containing the configuration.

  • stage – (str) One of the stage in train (default), inference or test.

Note

In the configuration dictionary, in addition to the four sections (dataset, network, training and inference) used in fully supervised learning, an extra section semi_supervised_learning is needed. See Semi-Supervised Learning for details.

training()

Train the network

pymic.net_run.semi_sup.ssl_cct.softmax_js_loss(inputs, targets, **_)
pymic.net_run.semi_sup.ssl_cct.softmax_kl_loss(inputs, targets, conf_mask=False, threshold=None, use_softmax=False)
pymic.net_run.semi_sup.ssl_cct.softmax_mse_loss(inputs, targets, conf_mask=False, threshold=None, use_softmax=False)

pymic.net_run.semi_sup.ssl_cps module

class pymic.net_run.semi_sup.ssl_cps.BiNet(params)

Bases: Module

forward(x)

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool
class pymic.net_run.semi_sup.ssl_cps.SSLCPS(config, stage='train')

Bases: SSLSegAgent

Using cross pseudo supervision for semi-supervised segmentation.

  • Reference: Xiaokang Chen, Yuhui Yuan, Gang Zeng, Jingdong Wang, Semi-Supervised Semantic Segmentation with Cross Pseudo Supervision, CVPR 2021, pp. 2613-2022.

Parameters:
  • config – (dict) A dictionary containing the configuration.

  • stage – (str) One of the stage in train (default), inference or test.

Note

In the configuration dictionary, in addition to the four sections (dataset, network, training and inference) used in fully supervised learning, an extra section semi_supervised_learning is needed. See Semi-Supervised Learning for details.

create_network()

Create network based on configuration.

training()

Train the network

write_scalars(train_scalars, valid_scalars, lr_value, glob_it)

Write scalars using SummaryWriter.

Parameters:
  • train_scalars – (dictionary) Scalars for training set.

  • valid_scalars – (dictionary) Scalars for validation set.

  • lr_value – (float) Current learning rate.

  • glob_it – (int) Current iteration number.

pymic.net_run.semi_sup.ssl_em module

class pymic.net_run.semi_sup.ssl_em.SSLEntropyMinimization(config, stage='train')

Bases: SSLSegAgent

Using Entropy Minimization for semi-supervised segmentation.

  • Reference: Yves Grandvalet and Yoshua Bengio: Semi-supervised Learningby Entropy Minimization. NeurIPS, 2005.

Parameters:
  • config – (dict) A dictionary containing the configuration.

  • stage – (str) One of the stage in train (default), inference or test.

Note

In the configuration dictionary, in addition to the four sections (dataset, network, training and inference) used in fully supervised learning, an extra section semi_supervised_learning is needed. See Semi-Supervised Learning for details.

training()

Train the network

pymic.net_run.semi_sup.ssl_mt module

class pymic.net_run.semi_sup.ssl_mt.SSLMeanTeacher(config, stage='train')

Bases: SSLSegAgent

Mean Teacher for semi-supervised segmentation.

  • Reference: Antti Tarvainen, Harri Valpola: Mean teachers are better role models: Weight-averaged consistency targets improve semi-supervised deep learning results. NeurIPS 2017.

Parameters:
  • config – (dict) A dictionary containing the configuration.

  • stage – (str) One of the stage in train (default), inference or test.

Note

In the configuration dictionary, in addition to the four sections (dataset, network, training and inference) used in fully supervised learning, an extra section semi_supervised_learning is needed. See Semi-Supervised Learning for details.

create_network()

Create network based on configuration.

training()

Train the network

pymic.net_run.semi_sup.ssl_uamt module

class pymic.net_run.semi_sup.ssl_uamt.SSLUncertaintyAwareMeanTeacher(config, stage='train')

Bases: SSLMeanTeacher

Uncertainty Aware Mean Teacher for semi-supervised segmentation.

  • Reference: Lequan Yu, Shujun Wang, Xiaomeng Li, Chi-Wing Fu, and Pheng-Ann Heng. Uncertainty-aware Self-ensembling Model for Semi-supervised 3D Left Atrium Segmentation, MICCAI 2019.

Parameters:
  • config – (dict) A dictionary containing the configuration.

  • stage – (str) One of the stage in train (default), inference or test.

Note

In the configuration dictionary, in addition to the four sections (dataset, network, training and inference) used in fully supervised learning, an extra section semi_supervised_learning is needed. See Semi-Supervised Learning for details.

training()

Train the network

pymic.net_run.semi_sup.ssl_urpc module

class pymic.net_run.semi_sup.ssl_urpc.SSLURPC(config, stage='train')

Bases: SSLSegAgent

Uncertainty-Rectified Pyramid Consistency for semi-supervised segmentation.

  • Reference: Xiangde Luo, Guotai Wang*, Wenjun Liao, Jieneng Chen, Tao Song, Yinan Chen, Shichuan Zhang, Dimitris N. Metaxas, Shaoting Zhang. Semi-Supervised Medical Image Segmentation via Uncertainty Rectified Pyramid Consistency . Medical Image Analysis 2022.

Parameters:
  • config – (dict) A dictionary containing the configuration.

  • stage – (str) One of the stage in train (default), inference or test.

Note

In the configuration dictionary, in addition to the four sections (dataset, network, training and inference) used in fully supervised learning, an extra section semi_supervised_learning is needed. See Semi-Supervised Learning for details.

training()

Train the network

Module contents