anomalib.models.reverse_distillation.components.bottleneck

Torch model defining the bottleneck layer.

Module Contents

Classes

OCBE

One-Class Bottleneck Embedding module.

Functions

conv3x3(in_planes: int, out_planes: int, stride: int = 1, groups: int = 1, dilation: int = 1) → torch.nn.Conv2d

3x3 convolution with padding.

conv1x1(in_planes: int, out_planes: int, stride: int = 1) → torch.nn.Conv2d

1x1 convolution.

get_bottleneck_layer(backbone: str, **kwargs) → OCBE

Get appropriate bottleneck layer based on the name of the backbone.

anomalib.models.reverse_distillation.components.bottleneck.conv3x3(in_planes: int, out_planes: int, stride: int = 1, groups: int = 1, dilation: int = 1) torch.nn.Conv2d[source]

3x3 convolution with padding.

anomalib.models.reverse_distillation.components.bottleneck.conv1x1(in_planes: int, out_planes: int, stride: int = 1) torch.nn.Conv2d[source]

1x1 convolution.

class anomalib.models.reverse_distillation.components.bottleneck.OCBE(block: Type[Union[torchvision.models.resnet.Bottleneck, torchvision.models.resnet.BasicBlock]], layers: int, groups: int = 1, width_per_group: int = 64, norm_layer: Optional[Callable[Ellipsis, torch.nn.Module]] = None)[source]

Bases: torch.nn.Module

One-Class Bottleneck Embedding module.

Parameters
  • block (Bottleneck) – Expansion value is extracted from this block.

  • layers (int) – Numbers of OCE layers to create after multiscale feature fusion.

  • groups (int, optional) – Number of blocked connections from input channels to output channels. Defaults to 1.

  • width_per_group (int, optional) – Number of layers in each intermediate convolution layer. Defaults to 64.

  • norm_layer (Optional[Callable[..., nn.Module]], optional) – Batch norm layer to use. Defaults to None.

_make_layer(self, block: Type[Union[torchvision.models.resnet.Bottleneck, torchvision.models.resnet.BasicBlock]], planes: int, blocks: int, stride: int = 1, dilate: bool = False) torch.nn.Sequential[source]
forward(self, features: List[torch.Tensor]) torch.Tensor[source]

Forward-pass of Bottleneck layer.

Parameters

features (List[Tensor]) – List of features extracted from the encoder.

Returns

Output of the bottleneck layer

Return type

Tensor

anomalib.models.reverse_distillation.components.bottleneck.get_bottleneck_layer(backbone: str, **kwargs) OCBE[source]

Get appropriate bottleneck layer based on the name of the backbone.

Parameters

backbone (str) – Name of the backbone.

Returns

One-Class Bottleneck Embedding module.

Return type

Bottleneck_layer