MCPcopy Create free account
hub / github.com/alinlab/SelfPatch / HRNet

Class HRNet

segmentation/backbones/hrnet.py:218–642  ·  view source on GitHub ↗

HRNet backbone. This backbone is the implementation of `High-Resolution Representations for Labeling Pixels and Regions `_. Args: extra (dict): Detailed configuration for each stage of HRNet. There must be 4 stages, the configuratio

Source from the content-addressed store, hash-verified

216
217@BACKBONES.register_module()
218class HRNet(BaseModule):
219 """HRNet backbone.
220
221 This backbone is the implementation of `High-Resolution Representations
222 for Labeling Pixels and Regions <https://arxiv.org/abs/1904.04514>`_.
223
224 Args:
225 extra (dict): Detailed configuration for each stage of HRNet.
226 There must be 4 stages, the configuration for each stage must have
227 5 keys:
228
229 - num_modules (int): The number of HRModule in this stage.
230 - num_branches (int): The number of branches in the HRModule.
231 - block (str): The type of convolution block.
232 - num_blocks (tuple): The number of blocks in each branch.
233 The length must be equal to num_branches.
234 - num_channels (tuple): The number of channels in each branch.
235 The length must be equal to num_branches.
236 in_channels (int): Number of input image channels. Normally 3.
237 conv_cfg (dict): Dictionary to construct and config conv layer.
238 Default: None.
239 norm_cfg (dict): Dictionary to construct and config norm layer.
240 Use `BN` by default.
241 norm_eval (bool): Whether to set norm layers to eval mode, namely,
242 freeze running stats (mean and var). Note: Effect on Batch Norm
243 and its variants only. Default: False.
244 with_cp (bool): Use checkpoint or not. Using checkpoint will save some
245 memory while slowing down the training speed. Default: False.
246 frozen_stages (int): Stages to be frozen (stop grad and set eval mode).
247 -1 means not freezing any parameters. Default: -1.
248 zero_init_residual (bool): Whether to use zero init for last norm layer
249 in resblocks to let them behave as identity. Default: False.
250 multiscale_output (bool): Whether to output multi-level features
251 produced by multiple branches. If False, only the first level
252 feature will be output. Default: True.
253 pretrained (str, optional): Model pretrained path. Default: None.
254 init_cfg (dict or list[dict], optional): Initialization config dict.
255 Default: None.
256
257 Example:
258 >>> from mmseg.models import HRNet
259 >>> import torch
260 >>> extra = dict(
261 >>> stage1=dict(
262 >>> num_modules=1,
263 >>> num_branches=1,
264 >>> block='BOTTLENECK',
265 >>> num_blocks=(4, ),
266 >>> num_channels=(64, )),
267 >>> stage2=dict(
268 >>> num_modules=1,
269 >>> num_branches=2,
270 >>> block='BASIC',
271 >>> num_blocks=(4, 4),
272 >>> num_channels=(32, 64)),
273 >>> stage3=dict(
274 >>> num_modules=4,
275 >>> num_branches=3,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected