huangjh-pub / synorim

[T-PAMI'22] [Jittor & Pytorch] Multiway Non-rigid Point Cloud Registration via Learned Functional Map Synchronization
https://cg.cs.tsinghua.edu.cn/people/~huangjh/publication/synorim/
118 stars 10 forks source link

How to create testing data #7

Closed Juliejulie111 closed 1 year ago

Juliejulie111 commented 1 year ago

I've tried to retrain the network via my datasets. However, it was always killed. Therefore, I want to test the pretrained network on my data first.

How to create a suitable .npz for test? I have read all the closed issues before. They cannot help me. It seems that if I zip 4 point clouds into one .npz (.npz only has [pcs]=4 point clouds without [flows] and [flow_mask]), I can do the test. But I got the error: (I had put the .npz to mpc-dt4d folder, and add the name into meta.json )

Run: python evaluate.py configs/mpc-dt4d/test_pretrained.yaml

Checkpoint loaded from out_pretrained/dt4d/basis/best.pth. Test: 0%| | 0/9 [00:00<?, ?it/s] Traceback (most recent call last): File "evaluate.py", line 87, in test_meter = test_epoch() File "evaluate.py", line 50, in test_epoch for batch_idx, data in enumerate(pbar): File "/home/pm/anaconda3/envs/py3-mink/lib/python3.8/site-packages/tqdm/std.py", line 1195, in iter for obj in iterable: File "/home/pm/anaconda3/envs/py3-mink/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 521, in next data = self._next_data() File "/home/pm/anaconda3/envs/py3-mink/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1203, in _next_data return self._process_data(data) File "/home/pm/anaconda3/envs/py3-mink/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1229, in _process_data data.reraise() File "/home/pm/anaconda3/envs/py3-mink/lib/python3.8/site-packages/torch/_utils.py", line 425, in reraise raise self.exc_type(msg) KeyError: Caught KeyError in DataLoader worker process 0. Original Traceback (most recent call last): File "/home/pm/anaconda3/envs/py3-mink/lib/python3.8/site-packages/torch/utils/data/_utils/worker.py", line 287, in _worker_loop data = fetcher.fetch(index) File "/home/pm/anaconda3/envs/py3-mink/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "/home/pm/anaconda3/envs/py3-mink/lib/python3.8/site-packages/torch/utils/data/_utils/fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "/media/pm/Day2/hand_forarm/synorim/pytorch/dataset/flow_dataset.py", line 128, in getitem return self._get_item(data_id, rng) File "/media/pm/Day2/hand_forarm/synorim/pytorch/dataset/flow_dataset.py", line 162, in _get_item (ret_vals[DatasetSpec.FULL_FLOW][(fidx, fjdx)].shape[0], 3), dtype=np.float32) KeyError: <DatasetSpec.FULL_FLOW: 300>

/home/pm/anaconda3/envs/py3-mink/lib/python3.8/site-packages/torch/_utils.py(425)reraise() -> raise self.exc_type(msg)

Could you help me? Thanks a lot!!!

Juliejulie111 commented 1 year ago

In addition, the test on the datasets you provided works well. I don't know if I need to create flows and masks by myself. If I need to do it, how to do it? Thx!!

faeze-el commented 1 year ago

@Juliejulie111 in test_dataloader remove some part of spec, "DS.FULL_FLOW, DS.FULL_MASK".

Juliejulie111 commented 1 year ago

@faeze-el Thank you for your suggestion. I changed the test_dataloader like: def test_dataloader(self): test_set = FlowDataset(**self.hparams.test_kwargs, spec=[ DS.FILENAME, DS.QUANTIZED_COORDS, DS.PC], hparams=self.hparams) return DataLoader(test_set, batch_size=1, shuffle=False, num_workers=4, collate_fn=list_collate) And got the error: Checkpoint loaded from out_pretrained/dt4d/basis/best.pth. Test: 0%| | 0/1 [00:01<?, ?it/s] Traceback (most recent call last): File "evaluate.py", line 87, in test_meter = test_epoch() File "evaluate.py", line 53, in test_epoch test_result, test_metric = net_model.test_step(data, batch_idx) File "/media/pm/Day2/hand_forarm/synorim/pytorch/models/full_sync.py", line 184, in test_step error = self.evaluate_flow_error(batch, full_final_flows) File "/media/pm/Day2/hand_forarm/synorim/pytorch/models/full_sync.py", line 207, in evaluate_flow_error eval_pairs = list(batch[DS.FULL_FLOW].keys()) KeyError: <DatasetSpec.FULL_FLOW: 300>

/media/pm/Day2/hand_forarm/synorim/pytorch/models/full_sync.py(207)evaluate_flow_error() -> eval_pairs = list(batch[DS.FULL_FLOW].keys()) (Pdb)

heiwang1997 commented 1 year ago

Sorry for the late response! @Juliejulie111 You are getting this error because we compute the test error against the ground-truth flow during testing. If you don't have ground truth, you could safely comment this line (full_sync.py, line 184):

error = self.evaluate_flow_error(batch, full_final_flows)

and instead use error = {}.

Thanks!

Juliejulie111 commented 1 year ago

@heiwang1997 Thanks!!! It works!!!