class_docstr: Darknet backbone.
  
  Args:
      depth (int): Depth of Darknet. Currently only support 53.
      out_indices (Sequence[int]): Output from which stages.
      frozen_stages (int): Stages to be frozen (stop grad and set eval mode).
          -1 means not freezing any parameters. Default: -1.
      conv_cfg (dict): Config dict for convolution layer. Default: None.
      norm_cfg (dict): Dictionary to construct and config norm layer.
          Default: dict(type='BN', requires_grad=True)
      act_cfg (dict): Config dict for activation layer.
          Default: dict(type='LeakyReLU', negative_slope=0.1).
      norm_eval (bool): Whether to set norm layers to eval mode, namely,
          freeze running stats (mean and var). Note: Effect on Batch Norm
          and its variants only.
      pretrained (str, optional): model pretrained path. Default: None
      init_cfg (dict or list[dict], optional): Initialization config dict.
          Default: None
  
  Example:
      >>> from mmdet.models import Darknet
      >>> import torch
      >>> self = Darknet(depth=53)
      >>> self.eval()
      >>> inputs = torch.rand(1, 3, 416, 416)
      >>> level_outputs = self.forward(inputs)
      >>> for level_out in level_outputs:
      ...     print(tuple(level_out.shape))
      ...
      (1, 256, 52, 52)
      (1, 512, 26, 26)
      (1, 1024, 13, 13)
class_docstr_tok: ["Darknet","backbone",".","Args",":","depth","(","int",")",":","Depth","of","Darknet",".","Currently","only","support","53.","out_indices","(","Sequence","[","int","]",")",":","Output","from","which","stages",".","frozen_stages","(","int",")",":","Stages","to","be","frozen","(","stop","grad","and","set","eval","mode",")",".","-1","means","not","freezing","any","parameters",".","Default",":","-1.","conv_cfg","(","dict",")",":","Config","dict","for","convolution","layer",".","Default",":","None",".","norm_cfg","(","dict",")",":","Dictionary","to","construct","and","config","norm","layer",".","Default",":","dict","(","type='BN","'",",","requires_grad=True",")","act_cfg","(","dict",")",":","Config","dict","for","activation","layer",".","Default",":","dict","(","type='LeakyReLU","'",",","negative_slope=0.1",")",".","norm_eval","(","bool",")",":","Whether","to","set","norm","layers","to","eval","mode",",","namely",",","freeze","running","stats","(","mean","and","var",")",".","Note",":","Effect","on","Batch","Norm","and","its","variants","only",".","pretrained","(","str",",","optional",")",":","model","pretrained","path",".","Default",":","None","init_cfg","(","dict","or","list","[","dict","]",",","optional",")",":","Initialization","config","dict",".","Default",":","None","Example",":",">",">",">","from","mmdet.models","import","Darknet",">",">",">","import","torch",">",">",">","self","=","Darknet","(","depth=53",")",">",">",">","self.eval","(",")",">",">",">","inputs","=","torch.rand","(","1",",","3",",","416",",","416",")",">",">",">","level_outputs","=","self.forward","(","inputs",")",">",">",">","for","level_out","in","level_outputs",":","...","print","(","tuple","(","level_out.shape",")",")","...","(","1",",","256",",","52",",","52",")","(","1",",","512",",","26",",","26",")","(","1",",","1024",",","13",",","13",")"]
code: def __init__(
      self,
      depth=53,
      out_indices=(3, 4, 5),
      frozen_stages=-1,
      conv_cfg=None,
      norm_cfg=dict(type="BN", requires_grad=True),
      act_cfg=dict(type="LeakyReLU", negative_slope=0.1),
      norm_eval=True,
      pretrained=None,
      init_cfg=None,
  ):
      super(Darknet, self).__init__(init_cfg)
      if depth not in self.arch_settings:
          raise KeyError(f"invalid depth {depth} for darknet")
  
      self.depth = depth
      self.out_indices = out_indices
      self.frozen_stages = frozen_stages
      self.layers, self.channels = self.arch_settings[depth]
  
      cfg = dict(conv_cfg=conv_cfg, norm_cfg=norm_cfg, act_cfg=act_cfg)
  
      self.conv1 = ConvModule(3, 32, 3, padding=1, **cfg)
  
      self.cr_blocks = ["conv1"]
      for i, n_layers in enumerate(self.layers):
          layer_name = f"conv_res_block{i + 1}"
          in_c, out_c = self.channels[i]
          self.add_module(
              layer_name,
              self.make_conv_res_block(in_c, out_c, n_layers, **cfg),
          )
          self.cr_blocks.append(layer_name)
  
      self.norm_eval = norm_eval
  
      assert not (
          init_cfg and pretrained
      ), "init_cfg and pretrained cannot be specified at the same time"
      if isinstance(pretrained, str):
          warnings.warn(
              "DeprecationWarning: pretrained is deprecated, "
              'please use "init_cfg" instead'
          )
          self.init_cfg = dict(type="Pretrained", checkpoint=pretrained)
      elif pretrained is None:
          if init_cfg is None:
              self.init_cfg = [
                  dict(type="Kaiming", layer="Conv2d"),
                  dict(
                      type="Constant",
                      val=1,
                      layer=["_BatchNorm", "GroupNorm"],
                  ),
              ]
      else:
          raise TypeError("pretrained must be a str or None")
  
file_path: mmdetection/mmdet/models/backbones/darknet.py
imports: import warnings
  import torch.nn
  from mmcv.cnn import ConvModule
  from mmengine.model import BaseModule
  from torch.nn.modules.batchnorm import _BatchNorm
  from mmdet.registry import MODELS
label_desc: Use image node_id 1 to create a new Darknet object from inherited base classes: BaseModule with example: obj = Darknet(depth, out_indices, frozen_stages, conv_cfg, norm_cfg, act_cfg, norm_eval, pretrained, init_cfg)