def __init__(self, dim_in):
        super().__init__()
        self.dim_in = dim_in

        n_classes = cfg.MODEL.NUM_CLASSES if cfg.MRCNN.CLS_SPECIFIC_MASK else 1
        if cfg.MRCNN.USE_FC_OUTPUT:
            # Predict masks with a fully connected layer
            self.classify = nn.Linear(dim_in, n_classes * cfg.MRCNN.RESOLUTION**2)
        else:
            # Predict mask using Conv
            self.classify = nn.Conv2d(dim_in, n_classes, 1, 1, 0)
            if cfg.MRCNN.UPSAMPLE_RATIO > 1:
                self.upsample = mynn.BilinearInterpolation2d(
                    n_classes, n_classes, cfg.MRCNN.UPSAMPLE_RATIO)
        self._init_weights()
    def __init__(self, dim_in):
        super(keypoint_outputs, self).__init__()
        self.upsample_heatmap = (cfg.KRCNN.UP_SCALE > 1)

        if cfg.KRCNN.USE_DECONV:
            # Apply ConvTranspose to the feature representation; results in 2x # upsampling
            self.deconv = nn.ConvTranspose2d(
                dim_in,
                cfg.KRCNN.DECONV_DIM,
                cfg.KRCNN.DECONV_KERNEL,
                2,
                padding=int(cfg.KRCNN.DECONV_KERNEL / 2) - 1)
            dim_in = cfg.KRCNN.DECONV_DIM

        if cfg.KRCNN.USE_DECONV_OUTPUT:
            # Use ConvTranspose to predict heatmaps; results in 2x upsampling
            self.classify = nn.ConvTranspose2d(
                dim_in,
                cfg.KRCNN.NUM_KEYPOINTS,
                cfg.KRCNN.DECONV_KERNEL,
                2,
                padding=int(cfg.KRCNN.DECONV_KERNEL / 2 - 1))
        else:
            # Use Conv to predict heatmaps; does no upsampling
            self.classify = nn.Conv2d(dim_in,
                                      cfg.KRCNN.NUM_KEYPOINTS,
                                      1,
                                      1,
                                      padding=0)

        if self.upsample_heatmap:
            # self.upsample = nn.UpsamplingBilinear2d(scale_factor=cfg.KRCNN.UP_SCALE)
            self.upsample = mynn.BilinearInterpolation2d(
                cfg.KRCNN.NUM_KEYPOINTS, cfg.KRCNN.NUM_KEYPOINTS,
                cfg.KRCNN.UP_SCALE)

        self._init_weights()