def __init__(self, config): """Initialize configurations.""" self.image_size = config['image_size'] self.class_num = config['class_num'] self.class_names = config['class_names'] self.k_proposals = config['k_proposals'] self.balance_factor = config['balance_factor'] self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu") self.basebone = fc_resnet50(self.class_num, True) self.prm_module = peak_response_mapping(self.basebone, **config['model']) self.filling_module = instance_extent_filling(self.basebone, config) self.cuda = torch.cuda.is_available() if self.cuda: self.prm_module.to(self.device) self.filling_module.to(self.device) self.prm_module_criterion = multilabel_soft_margin_loss self.filling_module_criterion = binary_cross_entropy_loss self.max_epoch = config['max_epoch'] self.params = finetune(self.prm_module, **config['finetune']) self.optimizer_prm = sgd_optimizer(self.params, **config['optimizer']) self.params = finetune(self.filling_module, **config['finetune']) self.optimizer_filling = sgd_optimizer(self.params, **config['optimizer']) self.lr_update_step = 999999 self.lr = config['optimizer']['lr'] self.snapshot = config['snapshot']
def __init__(self, config): """Initialize configurations.""" self.basebone = fc_resnet50(20, True) self.model = peak_response_mapping(self.basebone, **config['model']) self.criterion = multilabel_soft_margin_loss self.max_epoch = config['max_epoch'] self.cuda = (config['device'] == 'cuda') self.params = finetune(self.model, **config['finetune']) # print(self.params) self.optimizer = sgd_optimizer(self.params, **config['optimizer']) self.lr_update_step = 999999 self.lr = config['optimizer']['lr'] self.snapshot = config['snapshot'] if self.cuda: self.model.to('cuda')