Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove input_size argument from models #1827 #1856

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/anomalib/models/image/cfa/lightning_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class Cfa(AnomalyModule):
"""CFA: Coupled-hypersphere-based Feature Adaptation for Target-Oriented Anomaly Localization.

Args:
input_size (tuple[int, int]): Size of the model input.
Defaults to ``(256, 256)``.
backbone (str): Backbone CNN network
Defaults to ``"wide_resnet50_2"``.
gamma_c (int, optional): gamma_c value from the paper.
Expand Down
1 change: 0 additions & 1 deletion src/anomalib/models/image/cfa/torch_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ class CfaModel(DynamicBufferMixin):
"""Torch implementation of the CFA Model.

Args:
input_size: (tuple[int, int]): Input size of the image tensor.
backbone (str): Backbone CNN network.
gamma_c (int): gamma_c parameter from the paper.
gamma_d (int): gamma_d parameter from the paper.
Expand Down
2 changes: 0 additions & 2 deletions src/anomalib/models/image/cflow/lightning_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ class Cflow(AnomalyModule):
"""PL Lightning Module for the CFLOW algorithm.

Args:
input_size (tuple[int, int], optional): Input image size.
Defaults to ``(256, 256)``.
backbone (str, optional): Backbone CNN architecture.
Defaults to ``"wide_resnet50_2"``.
layers (Sequence[str], optional): Layers to extract features from.
Expand Down
1 change: 0 additions & 1 deletion src/anomalib/models/image/cflow/torch_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class CflowModel(nn.Module):
"""CFLOW: Conditional Normalizing Flows.

Args:
input_size (tuple[int, int]): Input image size.
backbone (str): Backbone CNN architecture.
layers (Sequence[str]): Layers to extract features from.
pre_trained (bool): Whether to use pre-trained weights.
Expand Down
4 changes: 1 addition & 3 deletions src/anomalib/models/image/csflow/lightning_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class Csflow(AnomalyModule):
"""Fully Convolutional Cross-Scale-Flows for Image-based Defect Detection.

Args:
input_size (tuple[int, int]): Size of the model input.
Defaults to ``(256, 256)``.
n_coupling_blocks (int): Number of coupling blocks in the model.
Defaults to ``4``.
cross_conv_hidden_channels (int): Number of hidden channels in the cross convolution.
Expand Down Expand Up @@ -60,7 +58,7 @@ def __init__(

def _setup(self) -> None:
if self.input_size is None:
msg = "Csflow needs input size to build torch model."
msg = "CsFlow needs input size to build torch model."
raise ValueError(msg)

self.model = CsFlowModel(
Expand Down
2 changes: 0 additions & 2 deletions src/anomalib/models/image/fastflow/lightning_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ class Fastflow(AnomalyModule):
"""PL Lightning Module for the FastFlow algorithm.

Args:
input_size (tuple[int, int]): Model input size.
Defaults to ``(256, 256)``.
backbone (str): Backbone CNN network
Defaults to ``resnet18``.
pre_trained (bool, optional): Boolean to check whether to use a pre_trained backbone.
Expand Down
4 changes: 1 addition & 3 deletions src/anomalib/models/image/ganomaly/lightning_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class Ganomaly(AnomalyModule):
"""PL Lightning Module for the GANomaly Algorithm.

Args:
input_size (tuple[int, int]): Input dimension.
Defaults to ``(256, 256)``.
batch_size (int): Batch size.
Defaults to ``32``.
n_features (int): Number of features layers in the CNNs.
Expand Down Expand Up @@ -94,7 +92,7 @@ def __init__(

def _setup(self) -> None:
if self.input_size is None:
msg = "CSflow needs input size to build torch model."
msg = "GANomaly needs input size to build torch model."
raise ValueError(msg)

self.model = GanomalyModel(
Expand Down
2 changes: 0 additions & 2 deletions src/anomalib/models/image/padim/lightning_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class Padim(MemoryBankMixin, AnomalyModule):
"""PaDiM: a Patch Distribution Modeling Framework for Anomaly Detection and Localization.

Args:
input_size (tuple[int, int]): Size of the model input.
Defaults to ``(256, 256)``.
backbone (str): Backbone CNN network
Defaults to ``resnet18``.
layers (list[str]): Layers to extract features from the backbone CNN
Expand Down
1 change: 0 additions & 1 deletion src/anomalib/models/image/padim/torch_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class PadimModel(nn.Module):
"""Padim Module.

Args:
input_size (tuple[int, int]): Input size for the model.
layers (list[str]): Layers used for feature extraction
backbone (str, optional): Pre-trained model backbone. Defaults to "resnet18".
Defaults to ``resnet18``.
Expand Down
5 changes: 2 additions & 3 deletions src/anomalib/models/image/patchcore/anomaly_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class AnomalyMapGenerator(nn.Module):
"""Generate Anomaly Heatmap.

Args:
input_size (ListConfig, tuple): Size of the input image.
The anomaly map is upsampled to this dimension.
The anomaly map is upsampled to this dimension.
sigma (int, optional): Standard deviation for Gaussian Kernel.
Defaults to ``4``.
"""
Expand Down Expand Up @@ -65,7 +64,7 @@ def forward(
Defaults to None.

Example:
>>> anomaly_map_generator = AnomalyMapGenerator(input_size=input_size)
>>> anomaly_map_generator = AnomalyMapGenerator()
>>> map = anomaly_map_generator(patch_scores=patch_scores)

Returns:
Expand Down
2 changes: 0 additions & 2 deletions src/anomalib/models/image/patchcore/lightning_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class Patchcore(MemoryBankMixin, AnomalyModule):
"""PatchcoreLightning Module to train PatchCore algorithm.

Args:
input_size (tuple[int, int]): Size of the model input.
Defaults to ``(224, 224)``.
backbone (str): Backbone CNN network
Defaults to ``wide_resnet50_2``.
layers (list[str]): Layers to extract features from the backbone CNN
Expand Down
1 change: 0 additions & 1 deletion src/anomalib/models/image/patchcore/torch_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ class PatchcoreModel(DynamicBufferMixin, nn.Module):
"""Patchcore Module.

Args:
input_size (tuple[int, int]): Input size for the model.
layers (list[str]): Layers used for feature extraction
backbone (str, optional): Pre-trained model backbone.
Defaults to ``resnet18``.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ class ReverseDistillation(AnomalyModule):
"""PL Lightning Module for Reverse Distillation Algorithm.

Args:
input_size (tuple[int, int]): Size of model input
Defaults to ``(256, 256)``.
backbone (str): Backbone of CNN network
Defaults to ``wide_resnet50_2``.
layers (list[str]): Layers to extract features from the backbone CNN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class ReverseDistillationModel(nn.Module):
self.encoder = torchvision.models.wide_resnet50_2(pretrained=True)

Args:
backbone (str): Name of the backbone used for encoder and decoder
input_size (tuple[int, int]): Size of input image
backbone (str): Name of the backbone used for encoder and decoder.
input_size (tuple[int, int]): Size of input image.
layers (list[str]): Name of layers from which the features are extracted.
anomaly_map_mode (str): Mode used to generate anomaly map. Options are between ``multiply`` and ``add``.
pre_trained (bool, optional): Boolean to check whether to use a pre_trained backbone.
Expand Down
2 changes: 0 additions & 2 deletions src/anomalib/models/image/stfpm/lightning_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class Stfpm(AnomalyModule):
"""PL Lightning Module for the STFPM algorithm.

Args:
input_size (tuple[int, int]): Size of the model input.
Defaults to ``(256, 256)``.
backbone (str): Backbone CNN network
Defaults to ``resnet18``.
layers (list[str]): Layers to extract features from the backbone CNN
Expand Down
3 changes: 1 addition & 2 deletions src/anomalib/models/image/stfpm/torch_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class STFPMModel(nn.Module):
"""STFPM: Student-Teacher Feature Pyramid Matching for Unsupervised Anomaly Detection.

Args:
layers (list[str]): Layers used for feature extraction
input_size (tuple[int, int]): Input size for the model.
layers (list[str]): Layers used for feature extraction.
backbone (str, optional): Pre-trained model backbone.
Defaults to ``resnet18``.
"""
Expand Down
1 change: 0 additions & 1 deletion src/anomalib/models/image/uflow/lightning_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def __init__(
"""Uflow model.

Args:
input_size (tuple[int, int]): Input image size.
backbone (str): Backbone name.
flow_steps (int): Number of flow steps.
affine_clamp (float): Affine clamp.
Expand Down
Loading