opr.modules package
Building blocks for the OPR modular system.
opr.modules.cosplace
CosPlace aggregation layer implementation.
- class opr.modules.cosplace.CosPlace(in_dim: int, out_dim: int)[source]
Bases:
ModuleCosPlace aggregation layer.
As implemented in https://github.com/gmberton/CosPlace/blob/main/model/network.py
- forward(x: Tensor) Tensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
opr.modules.cross_attention
opr.modules.eca
Implementation of Efficient Channel Attention ECA block.
Wang, Qilong, et al. “ECA-Net: Efficient channel attention for deep convolutional neural networks.” Proceedings of the IEEE/CVF conference on computer vision and pattern recognition. 2020.
Paper: https://arxiv.org/abs/1910.03151 Code for Mink version adopted from the repository: https://github.com/jac99/MinkLoc3Dv2, MIT License
- class opr.modules.eca.MinkECABasicBlock(*args: Any, **kwargs: Any)[source]
Bases:
BasicBlockEfficient Channel Attention BasicBlock for ResNet with MinkowskiEngine.
opr.modules.fusion
Basic fusion modules implementation.
- class opr.modules.fusion.Add[source]
Bases:
ModuleAddition module.
- forward(data: Dict[str, Tensor]) Tensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class opr.modules.fusion.Concat[source]
Bases:
ModuleConcatenation module.
- forward(data: Dict[str, Tensor]) Tensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class opr.modules.fusion.GeMFusion(p: int = 3, eps: float = 1e-06)[source]
Bases:
ModuleGeM fusion module.
- forward(data: Dict[str, Tensor]) Tensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
opr.modules.gem
Generalized-Mean pooling layer implementation.
Radenović, Filip, Giorgos Tolias, and Ondřej Chum. “Fine-tuning CNN image retrieval with no human annotation.” IEEE transactions on pattern analysis and machine intelligence 41.7 (2018): 1655-1668.
Paper: https://arxiv.org/abs/1711.02512 Code adopted from the repository: https://github.com/jac99/MinkLocMultimodal, MIT License
- class opr.modules.gem.GeM(p: int = 3, eps: float = 1e-06)[source]
Bases:
ModuleGeM pooling layer.
- forward(x: Tensor) Tensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class opr.modules.gem.GlobalAvgPooling[source]
Bases:
ModuleGlobal average pooling fusion module.
- forward(x: Tensor) Tensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class opr.modules.gem.GlobalMaxPooling[source]
Bases:
ModuleGlobal max pooling fusion module.
- forward(x: Tensor) Tensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class opr.modules.gem.MinkGeM(p: int = 3, eps: float = 1e-06)[source]
Bases:
ModuleGeM pooling layer for sparse tensors with MinkowskiEngine.
- forward(x: object) Tensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- sparse: bool = True
opr.modules.mixvpr
MixVPR: Feature Mixing for Visual Place Recognition.
Source: https://github.com/amaralibey/MixVPR/blob/main/models/aggregators/mixvpr.py
- class opr.modules.mixvpr.FeatureMixerLayer(in_dim: int, mlp_ratio: float = 1.0)[source]
Bases:
ModuleFeature Mixer Layer.
- forward(x: Tensor) Tensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class opr.modules.mixvpr.MixVPR(in_channels: int = 256, in_h: int = 10, in_w: int = 18, out_channels: int = 128, mix_depth: int = 4, mlp_ratio: float = 1, out_rows: int = 2)[source]
Bases:
ModuleMixVPR aggregation layer.
Source: https://github.com/amaralibey/MixVPR/blob/main/models/aggregators/mixvpr.py
- forward(x: Tensor) Tensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
opr.modules.mlp
2-layer MLP module implementation.
- class opr.modules.mlp.MLP(in_features: int, hidden_features: int | None = None, out_features: int | None = None, act_layer: str = 'gelu', bias: bool = True, drop: float = 0.0, use_conv: bool = False)[source]
Bases:
ModuleMLP as used in Vision Transformer, MLP-Mixer and related networks.
- forward(x: Tensor) Tensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
opr.modules.netvlad
NetVLAD layer implementation.
- class opr.modules.netvlad.NetVLAD(num_clusters: int = 64, dim: int = 128, normalize_input: bool = True, vladv2: bool = False)[source]
Bases:
ModuleNetVLAD layer implementation.
- forward(x: Tensor) Tensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
opr.modules.self_attention
Self-attention modules.
- class opr.modules.self_attention.SelfAttention(embed_size: int)[source]
Bases:
ModuleSelf-attention module.
- forward(x: Tensor | Dict[str, Tensor]) Tensor | Dict[str, Tensor][source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
opr.modules.svt
Implementation of ASVT and CSVT modules.
- Citation:
Fan, Zhaoxin, et al. “Svt-net: Super light-weight sparse voxel transformer for large scale place recognition.” Proceedings of the AAAI Conference on Artificial Intelligence. Vol. 36. No. 1. 2022.
Source: https://github.com/ZhenboSong/SVTNet Paper: https://arxiv.org/abs/2105.00149
- class opr.modules.svt.ASVT(in_dim: int, reduction: int = 8)[source]
Bases:
ModuleASVT - Atom-Based Sparse Voxel Transformer.
- forward(x: MinkowskiEngine.SparseTensor) MinkowskiEngine.SparseTensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class opr.modules.svt.CSVT(channels: int, num_tokens: int = 16)[source]
Bases:
ModuleCSVT - Cluster-Based Sparse Voxel Transformer.
- forward(x: MinkowskiEngine.SparseTensor) MinkowskiEngine.SparseTensor[source]
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.