feature_extractor = models.resnet34(pretrained=True) posenet = PoseNet(feature_extractor, droprate=dropout, pretrained=True, filter_nans=(args.model == 'mapnet++')) if args.model == 'posenet': model = posenet elif args.model.find('mapnet') >= 0: model = MapNet(mapnet=posenet) else: raise NotImplementedError # loss function if args.model == 'posenet': train_criterion = PoseNetCriterion(sax=sax, saq=saq, learn_beta=args.learn_beta) val_criterion = PoseNetCriterion() elif args.model.find('mapnet') >= 0: kwargs = dict(sax=sax, saq=saq, srx=srx, srq=srq, learn_beta=args.learn_beta, learn_gamma=args.learn_gamma) if args.model.find('++') >= 0: kwargs = dict(kwargs, gps_mode=(vo_lib == 'gps')) train_criterion = MapNetOnlineCriterion(**kwargs) val_criterion = MapNetOnlineCriterion() else: train_criterion = MapNetCriterion(**kwargs)
feature_extractor = models.resnet34(pretrained=True) posenet = PoseNet(feature_extractor, droprate=dropout, pretrained=True, filter_nans=False) if args.model == 'posenet': model = posenet elif args.model.find('mapnet') >= 0: model = MapNet(mapnet=posenet) else: raise NotImplementedError # loss function if args.model == 'posenet': train_criterion = PoseNetCriterion(sax=sax, saq=saq, learn_beta=True) val_criterion = PoseNetCriterion() elif args.model.find('mapnet') >= 0: kwargs = dict(sax=sax, saq=saq, srx=srx, srq=srq, learn_beta=True, learn_gamma=True) train_criterion = MapNetCriterion(**kwargs) val_criterion = MapNetCriterion() else: raise NotImplementedError # optimizer param_list = [{'params': model.parameters()}]
feat_dim=feature_dim) else: raise NotImplementedError # loss function loss_fn = nn.L1Loss() #default regression loss if loss_fn_config in ['l2', 'mse']: loss_fn = nn.MSELoss() print('Using MSE Loss') elif loss_fn_config in ['smoothl1', 'huber']: loss_fn = nn.SmoothL1Loss() print('Using Smooth L1 / Huber Loss') if args.model == 'posenet': train_criterion = PoseNetCriterion(t_loss_fn=loss_fn, q_loss_fn=loss_fn, sax=sax, saq=saq, learn_beta=args.learn_beta) val_criterion = PoseNetCriterion() elif args.model == 'semanticOutput': train_criterion = SemanticCriterion() val_criterion = SemanticCriterion() elif 'mapnet' in args.model or 'semantic' in args.model or 'multitask' in args.model: kwargs = dict(t_loss_fn=loss_fn, q_loss_fn=loss_fn, sax=sax, saq=saq, srx=srx, srq=srq, learn_beta=args.learn_beta, learn_gamma=args.learn_gamma)