Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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)
        _, classes = torch.max(preds, -1)

        acc = (classes == labels).float().sum() / labels.numel()