anomalib.models.ganomaly.torch_model¶
Torch models defining encoder, decoder, Generator and Discriminator.
Code adapted from https://github.com/samet-akcay/ganomaly.
Module Contents¶
Classes¶
Encoder Network. |
|
Decoder Network. |
|
Discriminator. |
|
Generator model. |
|
Ganomaly Model. |
- class anomalib.models.ganomaly.torch_model.Encoder(input_size: Tuple[int, int], latent_vec_size: int, num_input_channels: int, n_features: int, extra_layers: int = 0, add_final_conv_layer: bool = True)[source]¶
Bases:
torch.nn.ModuleEncoder Network.
- Parameters
input_size (Tuple[int, int]) – Size of input image
latent_vec_size (int) – Size of latent vector z
num_input_channels (int) – Number of input channels in the image
n_features (int) – Number of features per convolution layer
extra_layers (int) – Number of extra layers since the network uses only a single encoder layer by default. Defaults to 0.
- class anomalib.models.ganomaly.torch_model.Decoder(input_size: Tuple[int, int], latent_vec_size: int, num_input_channels: int, n_features: int, extra_layers: int = 0)[source]¶
Bases:
torch.nn.ModuleDecoder Network.
- Parameters
input_size (Tuple[int, int]) – Size of input image
latent_vec_size (int) – Size of latent vector z
num_input_channels (int) – Number of input channels in the image
n_features (int) – Number of features per convolution layer
extra_layers (int) – Number of extra layers since the network uses only a single encoder layer by default. Defaults to 0.
- class anomalib.models.ganomaly.torch_model.Discriminator(input_size: Tuple[int, int], num_input_channels: int, n_features: int, extra_layers: int = 0)[source]¶
Bases:
torch.nn.ModuleDiscriminator.
Made of only one encoder layer which takes x and x_hat to produce a score.
- Parameters
input_size (Tuple[int,int]) – Input image size.
num_input_channels (int) – Number of image channels.
n_features (int) – Number of feature maps in each convolution layer.
extra_layers (int, optional) – Add extra intermediate layers. Defaults to 0.
- class anomalib.models.ganomaly.torch_model.Generator(input_size: Tuple[int, int], latent_vec_size: int, num_input_channels: int, n_features: int, extra_layers: int = 0, add_final_conv_layer: bool = True)[source]¶
Bases:
torch.nn.ModuleGenerator model.
Made of an encoder-decoder-encoder architecture.
- Parameters
input_size (Tuple[int,int]) – Size of input data.
latent_vec_size (int) – Dimension of latent vector produced between the first encoder-decoder.
num_input_channels (int) – Number of channels in input image.
n_features (int) – Number of feature maps in each convolution layer.
extra_layers (int, optional) – Extra intermediate layers in the encoder/decoder. Defaults to 0.
add_final_conv_layer (bool, optional) – Add a final convolution layer in the decoder. Defaults to True.
- class anomalib.models.ganomaly.torch_model.GanomalyModel(input_size: Tuple[int, int], num_input_channels: int, n_features: int, latent_vec_size: int, extra_layers: int = 0, add_final_conv_layer: bool = True)[source]¶
Bases:
torch.nn.ModuleGanomaly Model.
- Parameters
input_size (Tuple[int,int]) – Input dimension.
num_input_channels (int) – Number of input channels.
n_features (int) – Number of features layers in the CNNs.
latent_vec_size (int) – Size of autoencoder latent vector.
extra_layers (int, optional) – Number of extra layers for encoder/decoder. Defaults to 0.
add_final_conv_layer (bool, optional) – Add convolution layer at the end. Defaults to True.