class_docstr: HourglassNet backbone.
  
  Stacked Hourglass Networks for Human Pose Estimation.
  More details can be found in the `paper
  <https://arxiv.org/abs/1603.06937>`_ .
  
  Args:
      downsample_times (int): Downsample times in a HourglassModule.
      num_stacks (int): Number of HourglassModule modules stacked,
          1 for Hourglass-52, 2 for Hourglass-104.
      stage_channels (Sequence[int]): Feature channel of each sub-module in a
          HourglassModule.
      stage_blocks (Sequence[int]): Number of sub-modules stacked in a
          HourglassModule.
      feat_channel (int): Feature channel of conv after a HourglassModule.
      norm_cfg (norm_cfg): Dictionary to construct and config norm layer.
     init_cfg (dict or ConfigDict, optional): the config to control the
         initialization.
  
  Example:
      >>> from mmdet.models import HourglassNet
      >>> import torch
      >>> self = HourglassNet()
      >>> self.eval()
      >>> inputs = torch.rand(1, 3, 511, 511)
      >>> level_outputs = self.forward(inputs)
      >>> for level_output in level_outputs:
      ...     print(tuple(level_output.shape))
      (1, 256, 128, 128)
      (1, 256, 128, 128)
class_docstr_tok: ["HourglassNet","backbone",".","Stacked","Hourglass","Networks","for","Human","Pose","Estimation",".","More","details","can","be","found","in","the","`","paper","<","https",":","\/\/arxiv.org\/abs\/1603.06937",">","`","_",".","Args",":","downsample_times","(","int",")",":","Downsample","times","in","a","HourglassModule",".","num_stacks","(","int",")",":","Number","of","HourglassModule","modules","stacked",",","1","for","Hourglass-52",",","2","for","Hourglass-104",".","stage_channels","(","Sequence","[","int","]",")",":","Feature","channel","of","each","sub-module","in","a","HourglassModule",".","stage_blocks","(","Sequence","[","int","]",")",":","Number","of","sub-modules","stacked","in","a","HourglassModule",".","feat_channel","(","int",")",":","Feature","channel","of","conv","after","a","HourglassModule",".","norm_cfg","(","norm_cfg",")",":","Dictionary","to","construct","and","config","norm","layer",".","init_cfg","(","dict","or","ConfigDict",",","optional",")",":","the","config","to","control","the","initialization",".","Example",":",">",">",">","from","mmdet.models","import","HourglassNet",">",">",">","import","torch",">",">",">","self","=","HourglassNet","(",")",">",">",">","self.eval","(",")",">",">",">","inputs","=","torch.rand","(","1",",","3",",","511",",","511",")",">",">",">","level_outputs","=","self.forward","(","inputs",")",">",">",">","for","level_output","in","level_outputs",":","...","print","(","tuple","(","level_output.shape",")",")","(","1",",","256",",","128",",","128",")","(","1",",","256",",","128",",","128",")"]
code: def __init__(
      self,
      downsample_times: int = 5,
      num_stacks: int = 2,
      stage_channels: Sequence = (256, 256, 384, 384, 384, 512),
      stage_blocks: Sequence = (2, 2, 2, 2, 2, 4),
      feat_channel: int = 256,
      norm_cfg: ConfigType = dict(type="BN", requires_grad=True),
      init_cfg: OptMultiConfig = None,
  ) -> None:
      assert init_cfg is None, (
          "To prevent abnormal initialization "
          "behavior, init_cfg is not allowed to be set"
      )
      super().__init__(init_cfg)
  
      self.num_stacks = num_stacks
      assert self.num_stacks >= 1
      assert len(stage_channels) == len(stage_blocks)
      assert len(stage_channels) > downsample_times
  
      cur_channel = stage_channels[0]
  
      self.stem = nn.Sequential(
          ConvModule(
              3,
              cur_channel // 2,
              7,
              padding=3,
              stride=2,
              norm_cfg=norm_cfg,
          ),
          ResLayer(
              BasicBlock,
              cur_channel // 2,
              cur_channel,
              1,
              stride=2,
              norm_cfg=norm_cfg,
          ),
      )
  
      self.hourglass_modules = nn.ModuleList(
          [
              HourglassModule(
                  downsample_times, stage_channels, stage_blocks
              )
              for _ in range(num_stacks)
          ]
      )
  
      self.inters = ResLayer(
          BasicBlock,
          cur_channel,
          cur_channel,
          num_stacks - 1,
          norm_cfg=norm_cfg,
      )
  
      self.conv1x1s = nn.ModuleList(
          [
              ConvModule(
                  cur_channel,
                  cur_channel,
                  1,
                  norm_cfg=norm_cfg,
                  act_cfg=None,
              )
              for _ in range(num_stacks - 1)
          ]
      )
  
      self.out_convs = nn.ModuleList(
          [
              ConvModule(
                  cur_channel,
                  feat_channel,
                  3,
                  padding=1,
                  norm_cfg=norm_cfg,
              )
              for _ in range(num_stacks)
          ]
      )
  
      self.remap_convs = nn.ModuleList(
          [
              ConvModule(
                  feat_channel,
                  cur_channel,
                  1,
                  norm_cfg=norm_cfg,
                  act_cfg=None,
              )
              for _ in range(num_stacks - 1)
          ]
      )
  
      self.relu = nn.ReLU(inplace=True)
  
file_path: mmdetection/mmdet/models/backbones/hourglass.py
imports: from typing import List, Sequence
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import ConvModule
  from mmengine.model import BaseModule
  from mmdet.registry import MODELS
  from mmdet.utils import ConfigType, OptMultiConfig
  from ..layers import ResLayer
  from .resnet import BasicBlock
label_desc: Use image node_id 1 to create a new HourglassNet object from inherited base classes: BaseModule with example: obj = HourglassNet(downsample_times, num_stacks, stage_channels, stage_blocks, feat_channel, norm_cfg, init_cfg)