cvnets.models.segmentation.heads package

Submodules

cvnets.models.segmentation.heads.base_seg_head module

class cvnets.models.segmentation.heads.base_seg_head.BaseSegHead(opts, enc_conf: dict, use_l5_exp: bool | None = False, *args, **kwargs)[source]

Bases: BaseAnyNNModel

Base class for segmentation heads

__init__(opts, enc_conf: dict, use_l5_exp: bool | None = False, *args, **kwargs)[source]

Initializes internal Module state, shared by both nn.Module and ScriptModule.

forward_aux_head(enc_out: Dict) Tensor[source]
forward_seg_head(enc_out: Dict) Tensor[source]
forward(enc_out: Dict, *args, **kwargs) Tensor[source]

Implement the model-specific forward function in sub-classes.

reset_head_parameters(opts) None[source]
classmethod add_arguments(parser: ArgumentParser) ArgumentParser[source]

Add segmentation head specific arguments

get_trainable_parameters(weight_decay: float = 0.0, no_decay_bn_filter_bias: bool = False, *args, **kwargs)[source]

Get parameters for training along with the learning rate.

Parameters:
  • weight_decay – weight decay

  • no_decay_bn_filter_bias – Do not decay BN and biases. Defaults to False.

Returns:

Returns a tuple of length 2. The first entry is a list of dictionary with three keys (params, weight_decay, param_names). The second entry is a list of floats containing learning rate for each parameter.

Note

Kwargs may contain module_name. To avoid multiple arguments with the same name, we pop it and concatenate with encoder or head name

update_classifier(opts, n_classes: int) None[source]

This function updates the classification layer in a model. Useful for finetuning purposes.

classmethod build_model(opts: Namespace, *args, **kwargs) BaseAnyNNModel[source]

Build a model from command-line arguments. Sub-classes must implement this method

Parameters:

opts – Command-line arguments

…note::

This function is typically implemented in the base class for each task and implementation is reused by all models in that task.

cvnets.models.segmentation.heads.deeplabv3 module

class cvnets.models.segmentation.heads.deeplabv3.DeeplabV3(opts, enc_conf: Dict, use_l5_exp: bool | None = False, *args, **kwargs)[source]

Bases: BaseSegHead

This class defines the segmentation head in DeepLabv3 architecture :param opts: command-line arguments :param enc_conf: Encoder input-output configuration at each spatial level :type enc_conf: Dict :param use_l5_exp: Use features from expansion layer in Level5 in the encoder :type use_l5_exp: Optional[bool]

__init__(opts, enc_conf: Dict, use_l5_exp: bool | None = False, *args, **kwargs) None[source]

Initializes internal Module state, shared by both nn.Module and ScriptModule.

update_classifier(opts, n_classes: int) None[source]

This function updates the classification layer in a model. Useful for finetuning purposes.

classmethod add_arguments(parser: ArgumentParser) ArgumentParser[source]

DeepLabv3 specific arguments

forward_seg_head(enc_out: Dict) Tensor[source]

cvnets.models.segmentation.heads.pspnet module

class cvnets.models.segmentation.heads.pspnet.PSPNet(opts, enc_conf: dict, use_l5_exp: bool | None = False, *args, **kwargs)[source]

Bases: BaseSegHead

This class defines the segmentation head in PSPNet architecture :param opts: command-line arguments :param enc_conf: Encoder input-output configuration at each spatial level :type enc_conf: Dict :param use_l5_exp: Use features from expansion layer in Level5 in the encoder :type use_l5_exp: Optional[bool]

__init__(opts, enc_conf: dict, use_l5_exp: bool | None = False, *args, **kwargs) None[source]

Initializes internal Module state, shared by both nn.Module and ScriptModule.

update_classifier(opts, n_classes: int) None[source]

This function updates the classification layer in a model. Useful for finetuning purposes.

classmethod add_arguments(parser: ArgumentParser) ArgumentParser[source]

Add segmentation head specific arguments

forward_seg_head(enc_out: Dict) Tensor[source]

cvnets.models.segmentation.heads.simple_seg_head module

class cvnets.models.segmentation.heads.simple_seg_head.SimpleSegHead(opts, enc_conf: Dict, use_l5_exp: bool | None = False, *args, **kwargs)[source]

Bases: BaseSegHead

This class defines the simple segmentation head with merely a classification layer. This is useful for performing linear probling on segmentation task. :param opts: command-line arguments :param enc_conf: Encoder input-output configuration at each spatial level :type enc_conf: Dict :param use_l5_exp: Use features from expansion layer in Level5 in the encoder :type use_l5_exp: Optional[bool]

__init__(opts, enc_conf: Dict, use_l5_exp: bool | None = False, *args, **kwargs) None[source]

Initializes internal Module state, shared by both nn.Module and ScriptModule.

classmethod add_arguments(parser: ArgumentParser) ArgumentParser[source]

Add segmentation head specific arguments

forward_seg_head(enc_out: Dict) Tensor[source]

Module contents