code: def __init__(
      self,
      num_convs=4,
      roi_feat_size=14,
      in_channels=256,
      conv_kernel_size=3,
      conv_out_channels=256,
      num_classes=80,
      class_agnostic=False,
      upsample_cfg=dict(type="deconv", scale_factor=2),
      conv_cfg=None,
      norm_cfg=None,
      loss_mask=dict(
          type="CrossEntropyLoss", use_mask=True, loss_weight=1.0
      ),
  ):
      super(FCNMaskHead, self).__init__()
      self.upsample_cfg = upsample_cfg.copy()
      if self.upsample_cfg["type"] not in [
          None,
          "deconv",
          "nearest",
          "bilinear",
          "carafe",
      ]:
          raise ValueError(
              f'Invalid upsample method {self.upsample_cfg["type"]}, '
              'accepted methods are "deconv", "nearest", "bilinear", '
              '"carafe"'
          )
      self.num_convs = num_convs
      # WARN: roi_feat_size is reserved and not used
      self.roi_feat_size = _pair(roi_feat_size)
      self.in_channels = in_channels
      self.conv_kernel_size = conv_kernel_size
      self.conv_out_channels = conv_out_channels
      self.upsample_method = self.upsample_cfg.get("type")
      self.scale_factor = self.upsample_cfg.pop("scale_factor", None)
      self.num_classes = num_classes
      self.class_agnostic = class_agnostic
      self.conv_cfg = conv_cfg
      self.norm_cfg = norm_cfg
      self.fp16_enabled = False
      self.loss_mask = build_loss(loss_mask)
  
      self.convs = nn.ModuleList()
      for i in range(self.num_convs):
          in_channels = (
              self.in_channels if i == 0 else self.conv_out_channels
          )
          padding = (self.conv_kernel_size - 1) // 2
          self.convs.append(
              ConvModule(
                  in_channels,
                  self.conv_out_channels,
                  self.conv_kernel_size,
                  padding=padding,
                  conv_cfg=conv_cfg,
                  norm_cfg=norm_cfg,
              )
          )
      upsample_in_channels = (
          self.conv_out_channels if self.num_convs > 0 else in_channels
      )
      upsample_cfg_ = self.upsample_cfg.copy()
      if self.upsample_method is None:
          self.upsample = None
      elif self.upsample_method == "deconv":
          upsample_cfg_.update(
              in_channels=upsample_in_channels,
              out_channels=self.conv_out_channels,
              kernel_size=self.scale_factor,
              stride=self.scale_factor,
          )
          self.upsample = build_upsample_layer(upsample_cfg_)
      elif self.upsample_method == "carafe":
          upsample_cfg_.update(
              channels=upsample_in_channels,
              scale_factor=self.scale_factor,
          )
          self.upsample = build_upsample_layer(upsample_cfg_)
      else:
          # suppress warnings
          align_corners = (
              None if self.upsample_method == "nearest" else False
          )
          upsample_cfg_.update(
              scale_factor=self.scale_factor,
              mode=self.upsample_method,
              align_corners=align_corners,
          )
          self.upsample = build_upsample_layer(upsample_cfg_)
  
      out_channels = 1 if self.class_agnostic else self.num_classes
      logits_in_channel = (
          self.conv_out_channels
          if self.upsample_method == "deconv"
          else upsample_in_channels
      )
      self.conv_logits = Conv2d(logits_in_channel, out_channels, 1)
      self.relu = nn.ReLU(inplace=True)
      self.debug_imgs = None
  
file_path: insightface/detection/scrfd/mmdet/models/roi_heads/mask_heads/fcn_mask_head.py
imports: import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from mmcv.cnn import Conv2d, ConvModule, build_upsample_layer
  from mmcv.ops.carafe import CARAFEPack
  from mmcv.runner import auto_fp16, force_fp32
  from torch.nn.modules.utils import _pair
  from mmdet.core import mask_target
  from mmdet.models.builder import HEADS, build_loss
label_desc: Use image node_id 1 to create a new FCNMaskHead object from inherited base classes: nn with example: obj = FCNMaskHead(num_convs, roi_feat_size, in_channels, conv_kernel_size, conv_out_channels, num_classes, class_agnostic, upsample_cfg, conv_cfg, norm_cfg, loss_mask)