(self,
                 use_norm=True,
                 num_class=2,
                 layer_nums=(3, 5, 5),
                 layer_strides=(2, 2, 2),
                 num_filters=(128, 128, 256),
                 upsample_strides=(1, 2, 4),
                 num_upsample_filters=(256, 256, 256),
                 num_input_features=128,
                 num_anchor_per_loc=2,
                 encode_background_as_zeros=True,
                 use_direction_classifier=True,
                 use_groupnorm=False,
                 num_groups=32,
                 box_code_size=7,
                 num_direction_bins=2,
                 name='rpn')
upsample_strides support float: [0.25, 0.5, 1]
        if upsample_strides < 1, conv2d will be used instead of convtranspose2d.
upsample_strides support float: [0.25, 0.5, 1]
        if upsample_strides < 1, conv2d will be used instead of convtranspose2d.
upsample_strides support float : [ 0 . 25 0 . 5 1 ] if upsample_strides < 1 conv2d will be used instead of convtranspose2d .
def __init__(self,
                 use_norm=True,
                 num_class=2,
                 layer_nums=(3, 5, 5),
                 layer_strides=(2, 2, 2),
                 num_filters=(128, 128, 256),
                 upsample_strides=(1, 2, 4),
                 num_upsample_filters=(256, 256, 256),
                 num_input_features=128,
                 num_anchor_per_loc=2,
                 encode_background_as_zeros=True,
                 use_direction_classifier=True,
                 use_groupnorm=False,
                 num_groups=32,
                 box_code_size=7,
                 num_direction_bins=2,
                 name='rpn'):
        """upsample_strides support float: [0.25, 0.5, 1]
        if upsample_strides < 1, conv2d will be used instead of convtranspose2d.
        """
        super(RPNBase, self).__init__(
            use_norm=use_norm,
            num_class=num_class,
            layer_nums=layer_nums,
            layer_strides=layer_strides,
            num_filters=num_filters,
            upsample_strides=upsample_strides,
            num_upsample_filters=num_upsample_filters,
            num_input_features=num_input_features,
            num_anchor_per_loc=num_anchor_per_loc,
            encode_background_as_zeros=encode_background_as_zeros,
            use_direction_classifier=use_direction_classifier,
            use_groupnorm=use_groupnorm,
            num_groups=num_groups,
            box_code_size=box_code_size,
            num_direction_bins=num_direction_bins,
            name=name)
        self._num_anchor_per_loc = num_anchor_per_loc
        self._num_direction_bins = num_direction_bins
        self._num_class = num_class
        self._use_direction_classifier = use_direction_classifier
        self._box_code_size = box_code_size

        if encode_background_as_zeros:
            num_cls = num_anchor_per_loc * num_class
        else:
            num_cls = num_anchor_per_loc * (num_class + 1)
        if len(num_upsample_filters) == 0:
            final_num_filters = self._num_out_filters
        else:
            final_num_filters = sum(num_upsample_filters)
        self.conv_cls = nn.Conv2d(final_num_filters, num_cls, 1)
        self.conv_box = nn.Conv2d(final_num_filters,
                                  num_anchor_per_loc * box_code_size, 1)
        if use_direction_classifier:
            self.conv_dir_cls = nn.Conv2d(
                final_num_filters, num_anchor_per_loc * num_direction_bins, 1)
def __init__ ( self , use_norm = True , num_class = 2 , layer_nums = ( 3 , 5 , 5 ) , layer_strides = ( 2 , 2 , 2 ) , num_filters = ( 128 , 128 , 256 ) , upsample_strides = ( 1 , 2 , 4 ) , num_upsample_filters = ( 256 , 256 , 256 ) , num_input_features = 128 , num_anchor_per_loc = 2 , encode_background_as_zeros = True , use_direction_classifier = True , use_groupnorm = False , num_groups = 32 , box_code_size = 7 , num_direction_bins = 2 , name = 'rpn' ) : super ( RPNBase , self ) . __init__ ( use_norm = use_norm , num_class = num_class , layer_nums = layer_nums , layer_strides = layer_strides , num_filters = num_filters , upsample_strides = upsample_strides , num_upsample_filters = num_upsample_filters , num_input_features = num_input_features , num_anchor_per_loc = num_anchor_per_loc , encode_background_as_zeros = encode_background_as_zeros , use_direction_classifier = use_direction_classifier , use_groupnorm = use_groupnorm , num_groups = num_groups , box_code_size = box_code_size , num_direction_bins = num_direction_bins , name = name ) self . _num_anchor_per_loc = num_anchor_per_loc self . _num_direction_bins = num_direction_bins self . _num_class = num_class self . _use_direction_classifier = use_direction_classifier self . _box_code_size = box_code_size if encode_background_as_zeros : num_cls = num_anchor_per_loc * num_class else : num_cls = num_anchor_per_loc * ( num_class + 1 ) if len ( num_upsample_filters ) == 0 : final_num_filters = self . _num_out_filters else : final_num_filters = sum ( num_upsample_filters ) self . conv_cls = nn . Conv2d ( final_num_filters , num_cls , 1 ) self . conv_box = nn . Conv2d ( final_num_filters , num_anchor_per_loc * box_code_size , 1 ) if use_direction_classifier : self . conv_dir_cls = nn . Conv2d ( final_num_filters , num_anchor_per_loc * num_direction_bins , 1 )