sleap.nn.architectures.hrnet#
(Higher)HRNet backbone.
This implementation is based on the PyTorch implementation of HRNet, modified to implement HigherHRNet’s configuration and new deconvolution heads.
Refs: https://arxiv.org/pdf/1902.09212.pdf https://arxiv.org/pdf/1908.10357.pdf
- class sleap.nn.architectures.hrnet.HigherHRNet(C: int = 18, initial_downsampling_steps: int = 1, n_deconv_modules: int = 1, bottleneck: bool = False, deconv_filters: int = 256, bilinear_upsampling: bool = False, stem_filters: int = 64)[source]#
HigherHRNet backbone.
- C#
The variant of HRNet to use. The most common is HRNet32, which has ~30M params. This number is effectively the number of filters at the highest resolution output.
- Type:
int
- initial_downsampling_steps#
Number of initial downsampling steps at the stem. Decrease if this introduces too much loss of resolution from the initial images.
- Type:
int
- n_deconv_modules#
Number of upsampling steps to perform at the head. If this is equal to initial_downsampling_steps, the output will be at the same scale as the input.
- Type:
int
- bottleneck#
If True, uses bottleneck blocks instead of simple residual blocks.
- Type:
bool
- deconv_filters#
Number of filters to use in deconv blocks if using transposed convolutions.
- Type:
int
- bilinear_upsampling#
Use bilinear upsampling instead of transposed convolutions at the output heads.
- Type:
bool
- property down_blocks#
Returns the number of downsampling steps in the model.
- output(x_in, n_output_channels)[source]#
Builds the layers for this backbone and return the output tensor.
- Parameters:
x_in – Input 4D tf.Tensor.
n_output_channels – The number of final output channels.
- Returns:
- A tf.keras.model whose outputs are a list of tf.Tensors
at each scale of the deconv_modules.
- Return type:
higher_hrnet_model
- property output_scale#
Returns relative scaling factor of this backbone.
- sleap.nn.architectures.hrnet.adjust_prefix(name_prefix)[source]#
Adds a delimiter if the prefix is not empty.