def load_pointnet(model_path): model = Pointnet(num_classes=4, input_channels=72, use_xyz=False) if os.path.isfile(model_path): print("==> Loading from checkpoint '{}'".format(model_path)) checkpoint = torch.load(model_path) epoch = checkpoint["epoch"] it = checkpoint.get("it", 0.0) best_prec = checkpoint["best_prec"] if model is not None and checkpoint["model_state"] is not None: model.load_state_dict(checkpoint["model_state"]) print("==> Done") return model
test_set = Kitti3DSemSeg(args.num_points, train=False) test_loader = DataLoader(test_set, batch_size=args.batch_size, shuffle=True, pin_memory=True, num_workers=0) # train_set = Indoor3DSemSeg(args.num_points) train_set = Kitti3DSemSeg(args.num_points) train_loader = DataLoader(train_set, batch_size=args.batch_size, pin_memory=True, num_workers=0, shuffle=True) model = Pointnet(num_classes=34, input_channels=6, use_xyz=True) # 设置设备 device_name = "cpu" if torch.cuda.is_available(): device_name = "cuda" torch.backends.cudnn.deterministic = True torch.cuda.manual_seed(0) device = torch.device(device_name) print(device) model.cuda() optimizer = optim.Adam(model.parameters(), lr=args.lr, weight_decay=args.weight_decay) lr_lbmd = lambda it: max(
batch_size=args.batch_size, shuffle=True, pin_memory=True, num_workers=2, ) train_set = Indoor3DSemSeg(args.num_points) train_loader = DataLoader( train_set, batch_size=args.batch_size, pin_memory=True, num_workers=2, shuffle=True, ) model = Pointnet(num_classes=13, input_channels=6, use_xyz=True) model.cuda() print(model) model_parameters = filter(lambda p: p.requires_grad, model.parameters()) params = sum([np.prod(p.size()) for p in model_parameters]) print("Model size = %i" % params) optimizer = optim.Adam(model.parameters(), lr=args.lr, weight_decay=args.weight_decay) lr_lbmd = lambda it: max( args.lr_decay**(int(it * args.batch_size / args.decay_step)), lr_clip / args.lr, ) bnm_lmbd = lambda it: max( args.bn_momentum * args.bn_decay**
batch_size=args.batch_size, shuffle=True, pin_memory=True, num_workers=2, ) train_set = Indoor3DSemSeg(args.num_points) train_loader = DataLoader( train_set, batch_size=args.batch_size, pin_memory=True, num_workers=2, shuffle=True, ) model = Pointnet(num_classes=13, input_channels=6, use_xyz=True) model.cuda() optimizer = optim.Adam( model.parameters(), lr=args.lr, weight_decay=args.weight_decay ) lr_lbmd = lambda it: max( args.lr_decay ** (int(it * args.batch_size / args.decay_step)), lr_clip / args.lr, ) bnm_lmbd = lambda it: max( args.bn_momentum * args.bn_decay ** (int(it * args.batch_size / args.decay_step)), bnm_clip, )
visualization.custom_draw_geometry_with_key_callback(point_cloud) if __name__ == "__main__": args = parser.parse_args() test_set = WaymoDatasetLoader(args.test_data_path, args.num_points) test_loader = DataLoader( test_set, batch_size=args.batch_size, shuffle=True, pin_memory=True, num_workers=2, ) model = Pointnet(num_classes=2, input_channels=0, use_xyz=True) model.cuda() print("checkpoint filename: {}".format(args.checkpoint.split(".")[0])) # load status from checkpoint if args.checkpoint is not None: checkpoint_status = pt_utils.load_checkpoint( model, None, filename=args.checkpoint.split(".")[0]) if checkpoint_status is not None: it, start_epoch, best_loss = checkpoint_status data_iter = iter(test_loader.__iter__()) for data in data_iter: inputs, labels = data
gpu_index = paras.gpu os.environ["CUDA_VISIBLE_DEVICES"] = gpu_index lr_clip = 1e-5 bnm_clip = 1e-2 if __name__ == "__main__": args = parser.parse_args() test_set = Indoor3DSemSeg(args.num_points, train=False) test_loader = DataLoader(test_set, batch_size=args.batch_size, shuffle=False, pin_memory=True, num_workers=2) model = Pointnet(3, input_channels=6).cuda() model.load_state_dict( torch.load( '/home1/xuhui/Pointnet2_PyTorch-master/pointnet2/train/checkpoints/poitnet2_semseg_best.pth.tar' )['model_state']) model.eval() # for i, data in tqdm.tqdm(enumerate(test_loader, 0), total=len(test_loader), # leave=False, desc='val'): for i, data in enumerate(test_loader): f = open(os.path.join(preds_path, str(i).zfill(2) + '.txt'), 'w') inputs, labels = data inputs = inputs.to('cuda', non_blocking=True) labels = labels.to('cuda', non_blocking=True) # print(labels) preds = model(inputs)