Model Inference
nargesghv opened this issue · 1 comments
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.
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.