def initialize(self,layer): if os.path.isabs(self.net_path): net_path_full = self.net_path else: net_path_full = os.path.join(env_settings().network_path, self.net_path) self.net, _ = load_network(net_path_full, backbone_pretrained=False) if self.use_gpu: self.net.cuda() self.net.eval() self.iou_predictor = self.net.bb_regressor self.layer_stride = {'conv1': 2, 'layer1': 4, 'layer2': 8, 'layer3': 16, 'layer4': 32, 'classification': 16, 'fc': None} self.layer_dim = {'conv1': 64, 'layer1': 64, 'layer2': 128, 'layer3': 256, 'layer4': 512, 'classification': 256,'fc': None} self.iounet_feature_layers = self.net.bb_regressor_layer if isinstance(self.pool_stride, int) and self.pool_stride == 1: self.pool_stride = [1]*len(self.output_layers) #print(self.output_layers) self.output_layers = list(layer) self.feature_layers = sorted(list(set(self.output_layers + self.iounet_feature_layers))) #print('ajun',self.output_layers1,self.output_layers1,self.output_layers1 + self.iounet_feature_layers,self.output_layers + self.iounet_feature_layers) self.mean = torch.Tensor([0.485, 0.456, 0.406]).view(1,-1,1,1) self.std = torch.Tensor([0.229, 0.224, 0.225]).view(1,-1,1,1)
def initialize(self): if os.path.isabs(self.net_path): net_path_full = self.net_path else: net_path_full = os.path.join(env_settings().network_path, self.net_path) self.net, _ = load_network(net_path_full, backbone_pretrained=False) self.net.cuda() self.net.eval() self.mean = torch.Tensor([0.485, 0.456, 0.406]).view(1, -1, 1, 1).cuda() self.std = torch.Tensor([0.229, 0.224, 0.225]).view(1, -1, 1, 1).cuda() self.layer_stride = { 'conv1': 2, 'layer1': 4, 'layer2': 8, 'layer3': 16, 'layer4': 32, 'classification': 16, 'fc': None } self.layer_dim = { 'conv1': 64, 'layer1': 64, 'layer2': 128, 'layer3': 256, 'layer4': 512, 'classification': 256, 'fc': None } self.iou_predictor = self.net.bb_regressor self.location_predictor = self.net.location_predictor #self.iounet_feature_layers = self.net.bb_regressor_layer #self.locator_feature_layers = self.net.location_predictor_layer self.iounet_feature_layers = ('layer2', 'layer3') self.locator_feature_layers = ('layer2', 'layer3') self.backbone_feature_layers = sorted( list(set(self.iounet_feature_layers + self.locator_feature_layers))) ## all parameters do not require grad for p in self.net.parameters(): p.requires_grad = False
def initialize(self): if os.path.isabs(self.net_path): net_path_full = self.net_path else: net_path_full = os.path.join(env_settings().network_path, self.net_path) self.net, _ = load_network(net_path_full, backbone_pretrained=False) self.net.cuda() self.net.eval() self.mean = torch.Tensor([0.485, 0.456, 0.406]).view(1, -1, 1, 1).cuda() self.std = torch.Tensor([0.229, 0.224, 0.225]).view(1, -1, 1, 1).cuda() self.iou_predictor = self.net.bb_regressor self.iou_feature_extractor = self.net.bb_regressor.get_iou_feat self.locator_feature_extractor = self.net.location_predictor.get_locator_feat ## all parameters do not require grad for p in self.net.parameters(): p.requires_grad = False