class_docstr: A semantic segmentation head described in :paper:`PanopticFPN`.
  It takes a list of FPN features as input, and applies a sequence of
  3x3 convs and upsampling to scale all of them to the stride defined by
  ``common_stride``. Then these features are added and used to make final
  predictions by another 1x1 conv layer.
class_docstr_tok: ["A","semantic","segmentation","head","described","in",":","paper",":","`","PanopticFPN","`",".","It","takes","a","list","of","FPN","features","as","input",",","and","applies","a","sequence","of","3x3","convs","and","upsampling","to","scale","all","of","them","to","the","stride","defined","by","``","common_stride","``",".","Then","these","features","are","added","and","used","to","make","final","predictions","by","another","1x1","conv","layer","."]
docstr: NOTE: this interface is experimental.
  
  Args:
      input_shape: shapes (channels and stride) of the input features
      num_classes: number of classes to predict
      conv_dims: number of output channels for the intermediate conv layers.
      common_stride: the common stride that all features will be upscaled to
      loss_weight: loss weight
      norm (str or callable): normalization for all conv layers
      ignore_value: category id to be ignored during training.
docstr_tok: ["NOTE",":","this","interface","is","experimental",".","Args",":","input_shape",":","shapes","(","channels","and","stride",")","of","the","input","features","num_classes",":","number","of","classes","to","predict","conv_dims",":","number","of","output","channels","for","the","intermediate","conv","layers",".","common_stride",":","the","common","stride","that","all","features","will","be","upscaled","to","loss_weight",":","loss","weight","norm","(","str","or","callable",")",":","normalization","for","all","conv","layers","ignore_value",":","category","id","to","be","ignored","during","training","."]
code: def __init__(
      self,
      input_shape: Dict[str, ShapeSpec],
      *,
      num_classes: int,
      conv_dims: int,
      common_stride: int,
      loss_weight: float = 1.0,
      norm: Optional[Union[str, Callable]] = None,
      ignore_value: int = -1,
  ):
      """
      NOTE: this interface is experimental.
  
      Args:
          input_shape: shapes (channels and stride) of the input features
          num_classes: number of classes to predict
          conv_dims: number of output channels for the intermediate conv layers.
          common_stride: the common stride that all features will be upscaled to
          loss_weight: loss weight
          norm (str or callable): normalization for all conv layers
          ignore_value: category id to be ignored during training.
      """
      super().__init__()
      input_shape = sorted(
          input_shape.items(), key=lambda x: x[1].stride
      )
      if not len(input_shape):
          raise ValueError(
              "SemSegFPNHead(input_shape=) cannot be empty!"
          )
      self.in_features = [k for k, v in input_shape]
      feature_strides = [v.stride for k, v in input_shape]
      feature_channels = [v.channels for k, v in input_shape]
  
      self.ignore_value = ignore_value
      self.common_stride = common_stride
      self.loss_weight = loss_weight
  
      self.scale_heads = []
      for in_feature, stride, channels in zip(
          self.in_features, feature_strides, feature_channels
      ):
          head_ops = []
          head_length = max(
              1, int(np.log2(stride) - np.log2(self.common_stride))
          )
          for k in range(head_length):
              norm_module = get_norm(norm, conv_dims)
              conv = Conv2d(
                  channels if k == 0 else conv_dims,
                  conv_dims,
                  kernel_size=3,
                  stride=1,
                  padding=1,
                  bias=not norm,
                  norm=norm_module,
                  activation=F.relu,
              )
              weight_init.c2_msra_fill(conv)
              head_ops.append(conv)
              if stride != self.common_stride:
                  head_ops.append(
                      nn.Upsample(
                          scale_factor=2,
                          mode="bilinear",
                          align_corners=False,
                      )
                  )
          self.scale_heads.append(nn.Sequential(*head_ops))
          self.add_module(in_feature, self.scale_heads[-1])
      self.predictor = Conv2d(
          conv_dims, num_classes, kernel_size=1, stride=1, padding=0
      )
      weight_init.c2_msra_fill(self.predictor)
  
imports: import numpy
  from typing import Callable, Dict, Optional, Tuple, Union
  import fvcore.nn.weight_init
  import torch
  from torch import nn
  from torch.nn import functional
  from detectron2.config import configurable
  from detectron2.layers import Conv2d, ShapeSpec, get_norm
  from detectron2.structures import ImageList
  from detectron2.utils.registry import Registry
  from ..backbone import Backbone, build_backbone
  from ..postprocessing import sem_seg_postprocess
  from .build import META_ARCH_REGISTRY
label_desc: Use image node_id 1 to create a new SemSegFPNHead object from inherited base classes: nn with example: obj = SemSegFPNHead(input_shape)