def __init__(self, cfg, in_channels, out_channels): super(CropRoi, self).__init__() self.num_scales = len(cfg.rpn_scales) self.scales = cfg.rpn_scales self.crop_size = cfg.crop_size self.convs = nn.ModuleList() for l in range(self.num_scales): if self.scales[l] == 1: self.convs.append( nn.Sequential( nn.Conv2d(in_channels, out_channels // self.num_scales, kernel_size=3, padding=1), )) else: self.convs.append( nn.Sequential( nn.Conv2d(in_channels, out_channels // self.num_scales, kernel_size=3, padding=1), nn.Upsample(scale_factor=self.scales[l], mode='bilinear'), )) self.crop = Crop(self.crop_size, self.crop_size, 1)
def __init__(self, cfg, crop_size): super(CropRoi_1layer, self).__init__() self.num_scales = len(cfg.rpn_scales) self.crop_size = crop_size self.sizes = cfg.rpn_base_sizes self.scales = cfg.rpn_scales self.crops = Crop(self.crop_size, self.crop_size, 1 / self.scales[0])
def __init__(self, cfg): super(CropRoi, self).__init__() self.num_heads = cfg.rpn_num_heads self.pool_size = cfg.pool_size self.size_thresholds = cfg.rcnn_select_size_thresholds self.crops = nn.ModuleList() for i in range(cfg.rpn_num_heads): self.crops.append( Crop(cfg.pool_size, cfg.pool_size, 1 / cfg.rpn_strides[i]))
def __init__(self, cfg, crop_size): super(CropRoi, self).__init__() self.num_scales = len(cfg.rpn_scales) self.crop_size = crop_size self.sizes = cfg.rpn_base_sizes self.scales = cfg.rpn_scales self.crops = nn.ModuleList() for l in range(self.num_scales): self.crops.append(Crop(self.crop_size, self.crop_size, 1 / self.scales[l]))
def __init__(self, cfg, crop_size): super(CropRoi, self).__init__() self.num_scales = len(cfg.rpn_scales) self.crop_size = crop_size self.sizes = cfg.rpn_base_sizes self.sizes = torch.from_numpy(np.array(self.sizes, np.float32)) self.sizes = self.sizes.cuda() if USE_CUDA else self.sizes self.scales = cfg.rpn_scales self.crops = nn.ModuleList() for l in range(self.num_scales): self.crops.append( Crop(self.crop_size, self.crop_size, 1 / self.scales[l]) )