def faster_rcnn_resnet101_v1d_custom(
    classes, transfer=None, pretrained_base=True, pretrained=False, **kwargs
):
    r"""Faster RCNN model with resnet101_v1d base network on custom dataset.

    Parameters
    ----------
    classes : iterable of str
        Names of custom foreground classes. `len(classes)` is the number of foreground classes.
    transfer : str or None
        If not `None`, will try to reuse pre-trained weights from faster RCNN networks trained
        on other datasets.
    pretrained_base : bool or str
        Boolean value controls whether to load the default pretrained weights for model.
        String value represents the hashtag for a certain version of pretrained weights.
    ctx : Context, default CPU
        The context in which to load the pretrained weights.
    root : str, default '~/.mxnet/models'
        Location for keeping the model parameters.

    Returns
    -------
    mxnet.gluon.HybridBlock
        Hybrid faster RCNN network.
    """
    if pretrained:
        warnings.warn(
            "Custom models don't provide `pretrained` weights, ignored."
        )
    if transfer is None:
        from gluoncv.model_zoo.resnetv1b import resnet101_v1d

        base_network = resnet101_v1d(
            pretrained=pretrained_base,
            dilated=False,
            use_global_stats=True,
            **kwargs
        )
        features = nn.HybridSequential()
        top_features = nn.HybridSequential()
        for layer in [
            "conv1",
            "bn1",
            "relu",
            "maxpool",
            "layer1",
            "layer2",
            "layer3",
        ]:
            features.add(getattr(base_network, layer))
        for layer in ["layer4"]:
            top_features.add(getattr(base_network, layer))
        train_patterns = "|".join(
            [".*dense", ".*rpn", ".*down(2|3|4)_conv", ".*layers(2|3|4)_conv"]
        )
        return get_faster_rcnn(
            name="resnet101_v1d",
            dataset="custom",
            pretrained=pretrained,
            features=features,
            top_features=top_features,
            classes=classes,
            short=600,
            max_size=1000,
            train_patterns=train_patterns,
            nms_thresh=0.5,
            nms_topk=400,
            post_nms=100,
            roi_mode="align",
            roi_size=(14, 14),
            strides=16,
            clip=4.14,
            rpn_channel=1024,
            base_size=16,
            scales=(2, 4, 8, 16, 32),
            ratios=(0.5, 1, 2),
            alloc_size=(128, 128),
            rpn_nms_thresh=0.7,
            rpn_train_pre_nms=12000,
            rpn_train_post_nms=2000,
            rpn_test_pre_nms=6000,
            rpn_test_post_nms=300,
            rpn_min_size=16,
            num_sample=128,
            pos_iou_thresh=0.5,
            pos_ratio=0.25,
            max_num_gt=3000,
            **kwargs
        )
    else:
        net = faster_rcnn_resnet101_v1d_coco(pretrained=True)
        reuse_classes = [x for x in classes if x in net.classes]
        net.reset_class(classes, reuse_weights=reuse_classes)
    return net
Faster RCNN model with resnet101_v1d base network on custom dataset.

    Parameters
    ----------
    classes : iterable of str
        Names of custom foreground classes. `len(classes)` is the number of foreground classes.
    transfer : str or None
        If not `None`, will try to reuse pre-trained weights from faster RCNN networks trained
        on other datasets.
    pretrained_base : bool or str
        Boolean value controls whether to load the default pretrained weights for model.
        String value represents the hashtag for a certain version of pretrained weights.
    ctx : Context, default CPU
        The context in which to load the pretrained weights.
    root : str, default '~/.mxnet/models'
        Location for keeping the model parameters.

    Returns
    -------
    mxnet.gluon.HybridBlock
        Hybrid faster RCNN network.
    
examples/mxnet/scenegraph/model/faster_rcnn.py