Hi All,
I am trying to reproduce an instance segmentation .using this [tutorial].(GitHub - dbtmpl/OPMask: Official implementation of the paper 'Prior to Segment: Foreground Cues for Weakly Annotated Classes in Partially Supervised Instance Segmentation' (ICCV 2021)) In this case ,it is trying to use the FPNCamRoiHeads
model. However, I get an error for the code. Please find the code below and the respective error.
class FPNCamRoiHeads(StandardROIHeads):
“”"
Copyright (c) Facebook, Inc. and its affiliates.
Adapted Detectron2 class.
Small adjustments to the StandardROIHeads to be able to calculate and process
class activation maps (CAMs)
"""
def __init__(self, cfg, input_shape):
super().__init__(cfg, input_shape)
self.cam_res = cfg.MODEL.ROI_MASK_HEAD.POOLER_RESOLUTION
def _init_box_head(self, cfg, input_shape):
# fmt: off
pooler_resolution = cfg.MODEL.ROI_BOX_HEAD.POOLER_RESOLUTION
pooler_scales = tuple(1.0 / input_shape[k].stride for k in self.in_features)
sampling_ratio = cfg.MODEL.ROI_BOX_HEAD.POOLER_SAMPLING_RATIO
pooler_type = cfg.MODEL.ROI_BOX_HEAD.POOLER_TYPE
self.train_on_pred_boxes = cfg.MODEL.ROI_BOX_HEAD.TRAIN_ON_PRED_BOXES
# fmt: on
# If StandardROIHeads is applied on multiple feature maps (as in FPN),
# then we share the same predictors and therefore the channel counts must be the same
in_channels = [input_shape[f].channels for f in self.in_features]
# Check all channel counts are equal
assert len(set(in_channels)) == 1, in_channels
in_channels = in_channels[0]
self.box_pooler = ROIPooler(
output_size=pooler_resolution,
scales=pooler_scales,
sampling_ratio=sampling_ratio,
pooler_type=pooler_type,
)
self.box_head = build_box_head(
cfg,
ShapeSpec(channels=in_channels, height=pooler_resolution, width=pooler_resolution),
self.num_classes,
self.cls_agnostic_bbox_reg,
)