equiadapt.images.canonicalization package
Submodules
equiadapt.images.canonicalization.continuous_group module
- class equiadapt.images.canonicalization.continuous_group.ContinuousGroupImageCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig, in_shape: tuple)[source]
Bases:
ContinuousGroupCanonicalizationThis class represents a continuous group image canonicalization model.
The model is designed to be equivariant under a continuous group of transformations, which can include rotations and reflections. Other specific continuous group image canonicalization classes can be derived from this class.
- get_rotation_matrix_from_vector()
This method takes the input vector and returns the rotation matrix.
- transformations_before_canonicalization_network_forward()[source]
Applies transformations to the input image before forwarding it through the canonicalization network.
- get_group_from_out_vectors()[source]
This method takes the output of the canonicalization network and returns the group element.
- invert_canonicalization()[source]
Inverts the canonicalization process on the output of the canonicalized image.
- canonicalize(x: Tensor, targets: List | None = None, **kwargs: Any) Tensor | Tuple[Tensor, List][source]
This method takes an image as input and returns the canonicalized image
- Parameters:
x (torch.Tensor) – The input image.
targets (Optional[List]) – The targets, if any.
- Returns:
canonicalized image
- Return type:
torch.Tensor
- get_group_from_out_vectors(out_vectors: Tensor) Tuple[dict, Tensor][source]
This method takes the output of the canonicalization network and returns the group element
- Parameters:
out_vectors (torch.Tensor) – output of the canonicalization network
- Returns:
group element torch.Tensor: group element representation
- Return type:
- get_groupelement(x: Tensor) dict[source]
This method takes the input image and maps it to the group element
- Parameters:
x (torch.Tensor) – input image
- Returns:
group element
- Return type:
- invert_canonicalization(x_canonicalized_out: Tensor, **kwargs: Any) Tensor[source]
Inverts the canonicalization process on the output of the canonicalized image.
- Parameters:
x_canonicalized_out (torch.Tensor) – The output of the canonicalized image.
- Returns:
The output corresponding to the original image.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization.continuous_group.OptimizedSteerableImageCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig, in_shape: tuple)[source]
Bases:
ContinuousGroupImageCanonicalizationThis class represents an optimized steerable image canonicalization model.
The model is designed to be equivariant under a continuous group of transformations, which can include rotations and reflections.
- get_rotation_matrix_from_vector()[source]
This method takes the input vector and returns the rotation matrix.
- get_groupelement(x: Tensor) dict[source]
Maps the input image to the group element.
- Parameters:
x (torch.Tensor) – The input image.
- Returns:
The group element.
- Return type:
- get_optimization_specific_loss() Tensor[source]
This method returns the optimization specific loss
- Returns:
optimization specific loss
- Return type:
torch.Tensor
- get_rotation_matrix_from_vector(vectors: Tensor) Tensor[source]
This method takes the input vector and returns the rotation matrix
- Parameters:
vectors (torch.Tensor) – input vector
- Returns:
rotation matrices
- Return type:
torch.Tensor
- group_augment(x: Tensor) Tuple[Tensor, Tensor][source]
Augmentation of the input images by applying random rotations and, if applicable, reflections, with corresponding transformation matrices.
- Parameters:
x (torch.Tensor) – Input images of shape (batch_size, in_channels, height, width).
- Returns:
Augmented images. torch.Tensor: Corresponding transformation matrices.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization.continuous_group.SteerableImageCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig, in_shape: tuple)[source]
Bases:
ContinuousGroupImageCanonicalizationThis class represents a steerable image canonicalization model.
The model is designed to be equivariant under a continuous group of euclidean transformations - rotations and reflections.
- get_rotation_matrix_from_vector()[source]
This method takes the input vector and returns the rotation matrix.
equiadapt.images.canonicalization.discrete_group module
- class equiadapt.images.canonicalization.discrete_group.DiscreteGroupImageCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig, in_shape: tuple)[source]
Bases:
DiscreteGroupCanonicalizationThis class represents a discrete group image canonicalization model.
The model is designed to be equivariant under a discrete group of transformations, which can include rotations and reflections. Other discrete group canonicalizers can be derived from this class.
- groupactivations_to_groupelement()[source]
Takes the activations for each group element as input and returns the group element.
- transformations_before_canonicalization_network_forward()[source]
Applies transformations to the input images before passing it through the canonicalization network.
- invert_canonicalization()[source]
Inverts the canonicalization of the output of the canonicalized image.
- canonicalize(x: Tensor, targets: List | None = None, **kwargs: Any) Tensor | Tuple[Tensor, List][source]
Canonicalizes the input images.
- Parameters:
x (torch.Tensor) – The input images.
targets (Optional[List], optional) – The targets for instance segmentation. Defaults to None.
**kwargs (Any) – Additional keyword arguments.
- Returns:
The canonicalized image, and optionally the targets.
- Return type:
Union[torch.Tensor, Tuple[torch.Tensor, List]]
- get_group_activations(x: Tensor) Tensor[source]
Gets the group activations for the input images.
- Parameters:
x (torch.Tensor) – The input images.
- Returns:
The group activations.
- Return type:
torch.Tensor
- groupactivations_to_groupelement(group_activations: Tensor) dict[source]
This method takes the activations for each group element as input and returns the group element
- Parameters:
group_activations (torch.Tensor) – activations for each group element.
- Returns:
group element.
- Return type:
- invert_canonicalization(x_canonicalized_out: Tensor, **kwargs: Any) Tensor[source]
Inverts the canonicalization of the output of the canonicalized image.
- Parameters:
x_canonicalized_out (torch.Tensor) – The output of the canonicalized image.
**kwargs (Any) – Additional keyword arguments.
- Returns:
The output corresponding to the original image.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization.discrete_group.GroupEquivariantImageCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig, in_shape: tuple)[source]
Bases:
DiscreteGroupImageCanonicalizationThis class represents a discrete group equivariant image canonicalization model.
The model is designed to be equivariant under a discrete group of transformations, which can include rotations and reflections.
- get_group_activations(x: Tensor) Tensor[source]
Gets the group activations for the input image.
This method takes an image as input, applies transformations before forwarding it through the canonicalization network, and then returns the group activations.
- Parameters:
x (torch.Tensor) – The input image.
- Returns:
The group activations.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization.discrete_group.OptimizedGroupEquivariantImageCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig, in_shape: tuple)[source]
Bases:
DiscreteGroupImageCanonicalizationThis class represents an optimized (discrete) group equivariant image canonicalization model.
The model is designed to be equivariant under a discrete group of transformations, which can include rotations and reflections.
- group_augment()[source]
Augment the input images by applying group transformations (rotations and reflections).
- get_group_activations(x: Tensor) Tensor[source]
Gets the group activations for the input image.
- Parameters:
x (torch.Tensor) – The input image.
- Returns:
The group activations.
- Return type:
torch.Tensor
- get_optimization_specific_loss() Tensor[source]
Gets the loss specific to the optimization process.
- Returns:
The loss.
- Return type:
torch.Tensor
- group_augment(x: Tensor) Tensor[source]
Augment the input images by applying group transformations (rotations and reflections).
- Parameters:
x (torch.Tensor) – The input image.
- Returns:
The augmented image.
- Return type:
torch.Tensor
- rotate_and_maybe_reflect(x: Tensor, degrees: Tensor, reflect: bool = False) List[Tensor][source]
Rotate and maybe reflect the input images.
- Parameters:
x (torch.Tensor) – The input image.
degrees (torch.Tensor) – The degrees of rotation.
reflect (bool, optional) – Whether to reflect the image. Defaults to False.
- Returns:
The list of rotated and maybe reflected images.
- Return type:
List[torch.Tensor]
Module contents
- class equiadapt.images.canonicalization.ContinuousGroupImageCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig, in_shape: tuple)[source]
Bases:
ContinuousGroupCanonicalizationThis class represents a continuous group image canonicalization model.
The model is designed to be equivariant under a continuous group of transformations, which can include rotations and reflections. Other specific continuous group image canonicalization classes can be derived from this class.
- get_rotation_matrix_from_vector()
This method takes the input vector and returns the rotation matrix.
- transformations_before_canonicalization_network_forward()[source]
Applies transformations to the input image before forwarding it through the canonicalization network.
- get_group_from_out_vectors()[source]
This method takes the output of the canonicalization network and returns the group element.
- invert_canonicalization()[source]
Inverts the canonicalization process on the output of the canonicalized image.
- canonicalize(x: Tensor, targets: List | None = None, **kwargs: Any) Tensor | Tuple[Tensor, List][source]
This method takes an image as input and returns the canonicalized image
- Parameters:
x (torch.Tensor) – The input image.
targets (Optional[List]) – The targets, if any.
- Returns:
canonicalized image
- Return type:
torch.Tensor
- get_group_from_out_vectors(out_vectors: Tensor) Tuple[dict, Tensor][source]
This method takes the output of the canonicalization network and returns the group element
- Parameters:
out_vectors (torch.Tensor) – output of the canonicalization network
- Returns:
group element torch.Tensor: group element representation
- Return type:
- get_groupelement(x: Tensor) dict[source]
This method takes the input image and maps it to the group element
- Parameters:
x (torch.Tensor) – input image
- Returns:
group element
- Return type:
- invert_canonicalization(x_canonicalized_out: Tensor, **kwargs: Any) Tensor[source]
Inverts the canonicalization process on the output of the canonicalized image.
- Parameters:
x_canonicalized_out (torch.Tensor) – The output of the canonicalized image.
- Returns:
The output corresponding to the original image.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization.DiscreteGroupImageCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig, in_shape: tuple)[source]
Bases:
DiscreteGroupCanonicalizationThis class represents a discrete group image canonicalization model.
The model is designed to be equivariant under a discrete group of transformations, which can include rotations and reflections. Other discrete group canonicalizers can be derived from this class.
- groupactivations_to_groupelement()[source]
Takes the activations for each group element as input and returns the group element.
- transformations_before_canonicalization_network_forward()[source]
Applies transformations to the input images before passing it through the canonicalization network.
- invert_canonicalization()[source]
Inverts the canonicalization of the output of the canonicalized image.
- canonicalize(x: Tensor, targets: List | None = None, **kwargs: Any) Tensor | Tuple[Tensor, List][source]
Canonicalizes the input images.
- Parameters:
x (torch.Tensor) – The input images.
targets (Optional[List], optional) – The targets for instance segmentation. Defaults to None.
**kwargs (Any) – Additional keyword arguments.
- Returns:
The canonicalized image, and optionally the targets.
- Return type:
Union[torch.Tensor, Tuple[torch.Tensor, List]]
- get_group_activations(x: Tensor) Tensor[source]
Gets the group activations for the input images.
- Parameters:
x (torch.Tensor) – The input images.
- Returns:
The group activations.
- Return type:
torch.Tensor
- groupactivations_to_groupelement(group_activations: Tensor) dict[source]
This method takes the activations for each group element as input and returns the group element
- Parameters:
group_activations (torch.Tensor) – activations for each group element.
- Returns:
group element.
- Return type:
- invert_canonicalization(x_canonicalized_out: Tensor, **kwargs: Any) Tensor[source]
Inverts the canonicalization of the output of the canonicalized image.
- Parameters:
x_canonicalized_out (torch.Tensor) – The output of the canonicalized image.
**kwargs (Any) – Additional keyword arguments.
- Returns:
The output corresponding to the original image.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization.GroupEquivariantImageCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig, in_shape: tuple)[source]
Bases:
DiscreteGroupImageCanonicalizationThis class represents a discrete group equivariant image canonicalization model.
The model is designed to be equivariant under a discrete group of transformations, which can include rotations and reflections.
- get_group_activations(x: Tensor) Tensor[source]
Gets the group activations for the input image.
This method takes an image as input, applies transformations before forwarding it through the canonicalization network, and then returns the group activations.
- Parameters:
x (torch.Tensor) – The input image.
- Returns:
The group activations.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization.OptimizedGroupEquivariantImageCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig, in_shape: tuple)[source]
Bases:
DiscreteGroupImageCanonicalizationThis class represents an optimized (discrete) group equivariant image canonicalization model.
The model is designed to be equivariant under a discrete group of transformations, which can include rotations and reflections.
- group_augment()[source]
Augment the input images by applying group transformations (rotations and reflections).
- get_group_activations(x: Tensor) Tensor[source]
Gets the group activations for the input image.
- Parameters:
x (torch.Tensor) – The input image.
- Returns:
The group activations.
- Return type:
torch.Tensor
- get_optimization_specific_loss() Tensor[source]
Gets the loss specific to the optimization process.
- Returns:
The loss.
- Return type:
torch.Tensor
- group_augment(x: Tensor) Tensor[source]
Augment the input images by applying group transformations (rotations and reflections).
- Parameters:
x (torch.Tensor) – The input image.
- Returns:
The augmented image.
- Return type:
torch.Tensor
- rotate_and_maybe_reflect(x: Tensor, degrees: Tensor, reflect: bool = False) List[Tensor][source]
Rotate and maybe reflect the input images.
- Parameters:
x (torch.Tensor) – The input image.
degrees (torch.Tensor) – The degrees of rotation.
reflect (bool, optional) – Whether to reflect the image. Defaults to False.
- Returns:
The list of rotated and maybe reflected images.
- Return type:
List[torch.Tensor]
- class equiadapt.images.canonicalization.OptimizedSteerableImageCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig, in_shape: tuple)[source]
Bases:
ContinuousGroupImageCanonicalizationThis class represents an optimized steerable image canonicalization model.
The model is designed to be equivariant under a continuous group of transformations, which can include rotations and reflections.
- get_rotation_matrix_from_vector()[source]
This method takes the input vector and returns the rotation matrix.
- get_groupelement(x: Tensor) dict[source]
Maps the input image to the group element.
- Parameters:
x (torch.Tensor) – The input image.
- Returns:
The group element.
- Return type:
- get_optimization_specific_loss() Tensor[source]
This method returns the optimization specific loss
- Returns:
optimization specific loss
- Return type:
torch.Tensor
- get_rotation_matrix_from_vector(vectors: Tensor) Tensor[source]
This method takes the input vector and returns the rotation matrix
- Parameters:
vectors (torch.Tensor) – input vector
- Returns:
rotation matrices
- Return type:
torch.Tensor
- group_augment(x: Tensor) Tuple[Tensor, Tensor][source]
Augmentation of the input images by applying random rotations and, if applicable, reflections, with corresponding transformation matrices.
- Parameters:
x (torch.Tensor) – Input images of shape (batch_size, in_channels, height, width).
- Returns:
Augmented images. torch.Tensor: Corresponding transformation matrices.
- Return type:
torch.Tensor
- class equiadapt.images.canonicalization.SteerableImageCanonicalization(canonicalization_network: Module, canonicalization_hyperparams: DictConfig, in_shape: tuple)[source]
Bases:
ContinuousGroupImageCanonicalizationThis class represents a steerable image canonicalization model.
The model is designed to be equivariant under a continuous group of euclidean transformations - rotations and reflections.
- get_rotation_matrix_from_vector()[source]
This method takes the input vector and returns the rotation matrix.