def obj_feature_map(self, features, rois): """ Gets the ROI features :param features: [batch_size, dim, IM_SIZE/4, IM_SIZE/4] (features at level p2) :param rois: [num_rois, 5] array of [img_num, x0, y0, x1, y1]. :return: [num_rois, #dim] array """ feature_pool = RoIAlignFunction(self.pooling_size, self.pooling_size, spatial_scale=1 / 16)( self.compress(features) if self.use_resnet else features, rois) return self.roi_fmap(feature_pool.view(rois.size(0), -1))
def new_obj_feature_map(self, features, rois): """ Gets the ROI features :param features: [batch_size, dim, IM_SIZE/4, IM_SIZE/4] (features at level p2) :param rois: [num_rois, 5] array of [img_num, x0, y0, x1, y1]. :return: [num_rois, #dim] array """ feature_pool = RoIAlignFunction(self.pooling_size, self.pooling_size, spatial_scale=1 / 16)( features, rois) return self.new_roi_fmap_obj(feature_pool.view(rois.size(0), -1)) # vgg.classifier
def obj_feature_map(self, features, rois): """ Gets the ROI features :param features: [batch_size, dim, IM_SIZE/4, IM_SIZE/4] (features at level p2) :param rois: [num_rois, 5] array of [img_num, x0, y0, x1, y1]. :return: [num_rois, #dim] array """ if not self.use_resnet: feature_pool = RoIAlignFunction( self.pooling_size, self.pooling_size, spatial_scale=1 / 16)( self.compress(features) if self.use_resnet else features, rois) return self.roi_fmap(feature_pool.view(rois.size(0), -1)) else: # feature_pool: [batch, 1024, 8, 8]; x: [batch, 1024, 7, 7]; fc7: [2048, 4, 4] --> [2048] feature_pool = RoIAlignFunction(self.pooling_size + 1, self.pooling_size + 1, spatial_scale=1 / 16)(features, rois) x = F.avg_pool2d(feature_pool, kernel_size=2, stride=1) fc7 = self.features.layer4(x) fc7 = fc7.mean(3).mean(2) return fc7
def obj_feature_map(self, features, rois): feature_pool = RoIAlignFunction(self.pooling_size, self.pooling_size, spatial_scale=1 / 16)(features, rois) return self.roi_fmap_obj(feature_pool.view(rois.size(0), -1))