def ResNet_roi_conv5_head_for_masks(dim_in): """ResNet "conv5" / "stage5" head for predicting masks.""" dilation = cfg.MRCNN.DILATION stride_init = cfg.MRCNN.ROI_XFORM_RESOLUTION // 7 # by default: 2 module, dim_out = ResNet.add_stage(dim_in, 2048, 512, 3, dilation, stride_init) return module, dim_out
def add_ResNet_roi_conv5_head_for_masks( model, blob_in, dim_in, spatial_scale, preprefix='_[mask]_', dilation=1, shared=False): assert not shared, \ 'Using shared ResNet stage not supported (temporarily)' model.RoIFeatureTransform( blob_in, blob_out=preprefix + 'pool5', blob_rois='mask_rois', method=cfg.MRCNN.ROI_XFORM_METHOD, resolution=cfg.MRCNN.ROI_XFORM_RESOLUTION, sampling_ratio=cfg.MRCNN.ROI_XFORM_SAMPLING_RATIO, spatial_scale=spatial_scale) stride_init = int(cfg.MRCNN.ROI_XFORM_RESOLUTION / 7) # by default: 2 if not shared: s, dim_in = ResNet.add_stage( model, preprefix + 'res5', preprefix + 'pool5', 3, dim_in, 2048, 512, dilation, stride_init=stride_init) else: s, dim_in = ResNet.add_stage_shared( model, preprefix, 'res5', preprefix + 'pool5', 3, dim_in, 2048, 512, dilation, stride_init=stride_init) return s, 2048, spatial_scale
def add_ResNet_roi_conv5_head_for_keypoints(model, blob_in, dim_in, spatial_scale): """Add a ResNet "conv5" / "stage5" head for Mask R-CNN keypoint prediction. """ model.RoIFeatureTransform( blob_in, '_[pose]_pool5', blob_rois='keypoint_rois', method=cfg.KRCNN.ROI_XFORM_METHOD, resolution=cfg.KRCNN.ROI_XFORM_RESOLUTION, sampling_ratio=cfg.KRCNN.ROI_XFORM_SAMPLING_RATIO, spatial_scale=spatial_scale) # Using the prefix '_[pose]_' to 'res5' enables initializing the head's # parameters using pretrained 'res5' parameters if given (see # utils.net.initialize_gpu_0_from_weights_file) s, dim_in = ResNet.add_stage(model, '_[pose]_res5', '_[pose]_pool5', 3, dim_in, 2048, 512, cfg.KRCNN.DILATION, stride_init=int( cfg.KRCNN.ROI_XFORM_RESOLUTION / 7)) return s, 2048
def add_ResNet_roi_conv5_head_for_masks(model, blob_in, dim_in, spatial_scale): """Add a ResNet "conv5" / "stage5" head for predicting masks.""" model.RoIFeatureTransform( blob_in, blob_out='_[mask]_pool5', blob_rois='mask_rois', method=cfg.MRCNN.ROI_XFORM_METHOD, resolution=cfg.MRCNN.ROI_XFORM_RESOLUTION, sampling_ratio=cfg.MRCNN.ROI_XFORM_SAMPLING_RATIO, spatial_scale=spatial_scale) dilation = cfg.MRCNN.DILATION stride_init = int(cfg.MRCNN.ROI_XFORM_RESOLUTION / 7) # by default: 2 s, dim_in = ResNet.add_stage(model, '_[mask]_res5', '_[mask]_pool5', 3, dim_in, 2048, 512, dilation, stride_init=stride_init) return s, 2048
def add_ResNet_roi_conv5_head_for_keypoints( model, blob_in, dim_in, spatial_scale ): """Add a ResNet "conv5" / "stage5" head for Mask R-CNN keypoint prediction. """ model.RoIFeatureTransform( blob_in, '_[pose]_pool5', blob_rois='keypoint_rois', method=cfg.KRCNN.ROI_XFORM_METHOD, resolution=cfg.KRCNN.ROI_XFORM_RESOLUTION, sampling_ratio=cfg.KRCNN.ROI_XFORM_SAMPLING_RATIO, spatial_scale=spatial_scale ) # Using the prefix '_[pose]_' to 'res5' enables initializing the head's # parameters using pretrained 'res5' parameters if given (see # utils.net.initialize_gpu_0_from_weights_file) s, dim_in = ResNet.add_stage( model, '_[pose]_res5', '_[pose]_pool5', 3, dim_in, 2048, 512, cfg.KRCNN.DILATION, stride_init=int(cfg.KRCNN.ROI_XFORM_RESOLUTION / 7) ) return s, 2048
def add_ResNet_roi_conv5_head_for_masks(model, blob_in, dim_in, spatial_scale): """Add a ResNet "conv5" / "stage5" head for predicting masks.""" model.RoIFeatureTransform( blob_in, blob_out='_[mask]_pool5', blob_rois='mask_rois', method=cfg.MRCNN.ROI_XFORM_METHOD, resolution=cfg.MRCNN.ROI_XFORM_RESOLUTION, sampling_ratio=cfg.MRCNN.ROI_XFORM_SAMPLING_RATIO, spatial_scale=spatial_scale ) dilation = cfg.MRCNN.DILATION stride_init = int(cfg.MRCNN.ROI_XFORM_RESOLUTION / 7) # by default: 2 s, dim_in = ResNet.add_stage( model, '_[mask]_res5', '_[mask]_pool5', 3, dim_in, 2048, 512, dilation, stride_init=stride_init ) return s, 2048
def add_ResNet_roi_conv5_head_for_keypoints( model, blob_in, dim_in, spatial_scale): model.RoIFeatureTransform( blob_in, '_[pose]_pool5', blob_rois='keypoint_rois', method=cfg.KRCNN.ROI_XFORM_METHOD, resolution=cfg.KRCNN.ROI_XFORM_RESOLUTION, sampling_ratio=cfg.KRCNN.ROI_XFORM_SAMPLING_RATIO, spatial_scale=spatial_scale) s, dim_in = ResNet.add_stage( model, '_[pose]_res5', '_[pose]_pool5', 3, dim_in, 2048, 512, cfg.KRCNN.DILATION, stride_init=int(cfg.KRCNN.ROI_XFORM_RESOLUTION / 7)) return s, 2048, spatial_scale
def add_ResNet_roi_conv5_head_for_keypoints(model, blob_in, dim_in, spatial_scale): model.RoIFeatureTransform( blob_in, '_[pose]_pool5', blob_rois='keypoint_rois', method=cfg.KRCNN.ROI_XFORM_METHOD, resolution=cfg.KRCNN.ROI_XFORM_RESOLUTION, sampling_ratio=cfg.KRCNN.ROI_XFORM_SAMPLING_RATIO, spatial_scale=spatial_scale) s, dim_in = ResNet.add_stage(model, '_[pose]_res5', '_[pose]_pool5', 3, dim_in, 2048, 512, cfg.KRCNN.DILATION, stride_init=int( cfg.KRCNN.ROI_XFORM_RESOLUTION / 7)) return s, 2048, spatial_scale