mit-han-lab / pvcnn

[NeurIPS 2019, Spotlight] Point-Voxel CNN for Efficient 3D Deep Learning
https://pvcnn.mit.edu/
MIT License
636 stars 129 forks source link

Model Inference #78

Closed nargesghv closed 4 months ago

nargesghv commented 11 months ago

Hello, I am trying to predict your S3dis_model on my custom data without any labels my data is like xyz_room.npy and I was using your prepare_data.py for the preparation of my data, but I skipped making the h5 file and labels, my code for loading the model and the dataset is in the following: Loading Model: model = PVCNN2(num_classes=13,width_multiplier=1, voxel_resolution_multiplier=1,extra_feature_channels=6).to(device) print(f'\n==> creating model "{configs.model}"') model = configs.model() model = torch.nn.DataParallel(model) model = model.to(device)

if os.path.exists(configs.evaluate.best_checkpoint_path): print(f'==> loading checkpoint "{configs.evaluate.best_checkpoint_path}"') checkpoint = torch.load(configs.evaluate.best_checkpoint_path) model.load_state_dict(checkpoint.pop('model')) del checkpoint else: return model.zero_grad model.eval() Loading data:

class RandomDataset:

def __init__(self, input_size: int, voxel_size: float) -> None:
    self.input_size = input_size
    self.voxel_size = voxel_size

def __getitem__(self, _: int):
    path = os.path.expanduser("/home/jovyan/work/newdataset/xyz_room.npy")
    inputs = np.load(path)
    new_input=np.expand_dims(inputs,-1)
    print(new_input.shape)

output= (138339347, 6, 1)

    reshaped_arr = np.transpose(new_input, (2, 1, 0))
    inputs = reshaped_arr
    inputs[:, 0:3] -= np.amin(inputs, axis=0)[0:3]
    new_input=torch.tensor(inputs)

    coords, features = new_input[:, :3, :].contiguous(), new_input
    coords -= np.min(coords, axis=0, keepdims=True)

    coords = coords.to(device)
    features = features.to(device)

    return {'coords': coords,'features': features}

def __len__(self):
    return 100

and Inference:

cuda_input=RandomDataset(input_size=138339347, voxel_size=0.5) print('model_inference...') time = datetime.now() with profiler.profile(profile_memory=True, use_cuda=True) as prof: with profiler.record_function('model_inference'):

optimizer.zero_grad()

    outputs = model(cuda_input)
    outputs = outputs.argmax(1)

First, I would like to know if my way is the correct way. and if not what is the correct way and code? and if the input shape is correct too, and if not what is the correct way to get a result from this git, I don't know what should be the input shape and how I can have coordinates and features from my input.

zhijian-liu commented 4 months ago

Adding support for a custom dataset is beyond the scope of this codebase, and unfortunately, we don't have the capacity to accommodate such customized requests.