cvnets.models.classification.config package

Submodules

cvnets.models.classification.config.byteformer module

cvnets.models.classification.config.byteformer.get_configuration(opts: Namespace) Dict[source]

Get configuration parameters associated with ByteFormer.

These parameters are similar to those of DeIT (https://arxiv.org/pdf/2012.12877.pdf).

Parameters:

opts – The options configuration.

Returns:

A dict with keys specifying the parameters needed for ByteFormer.

cvnets.models.classification.config.efficientnet module

class cvnets.models.classification.config.efficientnet.CompoundScalingConfig(width_mult: float, depth_mult: float, train_resolution: int)[source]

Bases: object

This class stores the compound scaling configuration

width_mult: float
depth_mult: float
train_resolution: int
__init__(width_mult: float, depth_mult: float, train_resolution: int) None
class cvnets.models.classification.config.efficientnet.EfficientNetBlockConfig(expand_ratio: float, kernel: int, stride: int, in_channels: int, out_channels: int, num_layers: int, width_mult: float, depth_mult: float)[source]

Bases: object

This class stores the config for each block in EfficientNet i.e. MBConv layers in Table 1 of EfficientNet paper Notably, this class takes width_mult and depth_mult as input too and adjusts layers’ depth and width, as is required in different modes of EfficientNet.

__init__(expand_ratio: float, kernel: int, stride: int, in_channels: int, out_channels: int, num_layers: int, width_mult: float, depth_mult: float)[source]
cvnets.models.classification.config.efficientnet.get_configuration(opts) Dict[source]

cvnets.models.classification.config.fastvit module

cvnets.models.classification.config.fastvit.get_configuration(opts: Namespace) Dict[source]

Get configuration of FastViT models.

cvnets.models.classification.config.mobilenetv1 module

cvnets.models.classification.config.mobilenetv1.get_configuration(opts) Dict[source]

cvnets.models.classification.config.mobilenetv2 module

cvnets.models.classification.config.mobilenetv2.get_configuration(opts) Dict[source]

cvnets.models.classification.config.mobilenetv3 module

cvnets.models.classification.config.mobilenetv3.get_configuration(opts) Dict[source]

cvnets.models.classification.config.mobileone module

cvnets.models.classification.config.mobileone.get_configuration(opts: Namespace) Dict[source]

Get configuration of MobileOne models.

cvnets.models.classification.config.mobilevit module

cvnets.models.classification.config.mobilevit.get_configuration(opts) Dict[source]

cvnets.models.classification.config.mobilevit_v2 module

cvnets.models.classification.config.mobilevit_v2.get_configuration(opts) Dict[source]

cvnets.models.classification.config.regnet module

class cvnets.models.classification.config.regnet.BlockParamsConfig(depth: int, w_0: int, w_a: float, w_m: float, groups: int, se_ratio: float = 0.0, bottleneck_multiplier: float = 1.0, quant: int = 8, stride: int = 2)[source]

Bases: object

This class stores the quantized linear block params. It is adapted from torchvision.models.regnet:

https://github.com/pytorch/vision/blob/c06d52b1c5f6aee36802661c3ebc6347b97cc59e/torchvision/models/regnet.py#L203

Parameters:
  • depth – The total number of XBlocks in the network

  • w_0 – Initial width

  • w_a – Width slope

  • w_m – Width slope in the log space

  • groups – The number of groups to use in the XBlock. Referred to

  • se_ratio – The squeeze-excitation ratio. The number of channels in the SE module will be the input channels scaled by this ratio.

  • bottleneck_multiplier – The number of output channels in the intermediate conv layers in bottleneck/Xblock block will be scaled by this value.

  • quant – Block widths will be divisible by this value

  • stride – The stride of the 3x3 conv of the XBlocks

__init__(depth: int, w_0: int, w_a: float, w_m: float, groups: int, se_ratio: float = 0.0, bottleneck_multiplier: float = 1.0, quant: int = 8, stride: int = 2) None[source]
extra_repr() str[source]
cvnets.models.classification.config.regnet.get_configuration(opts: Namespace) Dict[str, Dict[str, int | float]][source]

Gets the RegNet model configuration for the specified RegNet mode.

Parameters:

opts – command-line arguments

Returns:

  • A dictionary containing the configuration for each layer. Each key is of the form
    layer<i> and the corresponding value is another dictionary with the following keys:

    depth: The depth of the stage at layer<i> width: The width of the blocks at this stage groups: The convolution groups of each block at this stage stride: The stride of the convolutions in each block at this stage bottleneck_multiplier: The multiplier for the bottleneck conv in each of this stage’s blocks se_ratio: The squeeze-excitation ratio for each block in this stage

cvnets.models.classification.config.resnet module

cvnets.models.classification.config.resnet.add_squeeze_channels(config_dict: Dict, per_layer_squeeze_channels: List[int]) None[source]

Given the config_dict for the specified ResNet model, for each layer, adds a new key (‘squeeze_channels’) with the corresponding channels for the squeeze-excitation module.

Parameters:
  • config_dict – The dict constructed by the get_configuration function.

  • per_layer_squeeze_channels – A list of length 4 where the ith element specifies the number of channels for squeeze-excitation module of layer i.

cvnets.models.classification.config.resnet.get_configuration(opts) Dict[source]

cvnets.models.classification.config.swin_transformer module

cvnets.models.classification.config.swin_transformer.get_configuration(opts) Dict[source]

cvnets.models.classification.config.vit module

cvnets.models.classification.config.vit.get_configuration(opts: Namespace) Dict[source]

Gets the ViT model configuration.

The ‘tiny’ and ‘small’ model configurations were used in the “Training data-efficient image transformers & distillation through attention” paper.

The ‘base’, ‘large’, and ‘huge’ variants were used in the “An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale” paper.

Parameters:

opts – Command line options.

Returns:

The ViT model configuration dict.

Return type:

vit_config

Module contents