Open londumas opened 7 months ago
Hello, I encountered a similar issue while performing inference on a custom dataset. Do you have any solutions to resolve this? Thank you very much for your response!
File "/home/com/anaconda3/envs/devit/lib/python3.9/site-packages/torch/multiprocessing/spawn.py", line 69, in _wrap fn(i, args) File "/media/A/code/lyl/devit-main/tools/../detectron2/engine/launch.py", line 125, in _distributed_worker main_func(args) File "/media/A/code/lyl/devit-main/tools/train_net.py", line 201, in main return trainer.train() File "/media/A/code/lyl/devit-main/tools/../detectron2/engine/defaults.py", line 496, in train super().train(self.start_iter, self.max_iter) File "/media/A/code/lyl/devit-main/tools/../detectron2/engine/train_loop.py", line 150, in train self.after_step() File "/media/A/code/lyl/devit-main/tools/../detectron2/engine/train_loop.py", line 180, in after_step h.after_step() File "/media/A/code/lyl/devit-main/tools/../detectron2/engine/hooks.py", line 386, in after_step self._do_eval() File "/media/A/code/lyl/devit-main/tools/../detectron2/engine/hooks.py", line 359, in _do_eval results = self._func() File "/media/A/code/lyl/devit-main/tools/../detectron2/engine/defaults.py", line 465, in test_and_save_results self._last_eval_results = self.test(self.cfg, self.model) File "/media/A/code/lyl/devit-main/tools/../detectron2/engine/defaults.py", line 618, in test results_i = inference_on_dataset(model, data_loader, evaluator) File "/media/A/code/lyl/devit-main/tools/../detectron2/evaluation/evaluator.py", line 159, in inference_on_dataset outputs = model(inputs) File "/home/com/anaconda3/envs/devit/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, kwargs) File "/home/com/anaconda3/envs/devit/lib/python3.9/site-packages/torch/nn/parallel/distributed.py", line 1040, in forward output = self._run_ddp_forward(*inputs, *kwargs) File "/home/com/anaconda3/envs/devit/lib/python3.9/site-packages/torch/nn/parallel/distributed.py", line 1000, in _run_ddp_forward return module_to_run(inputs[0], kwargs[0]) File "/home/com/anaconda3/envs/devit/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, *kwargs) File "/media/A/code/lyl/devit-main/tools/../detectron2/modeling/meta_arch/devit.py", line 1198, in forward inter_dist_emb = other_classes.reshape(bs num_active_classes, -1, self.roialign_size, self.roialign_size) RuntimeError: cannot reshape tensor of 0 elements into shape [0, -1, 7, 7] because the unspecified dimension size -1 can be any value and is ambiguous
In other type of dataset than COCO, having no bbox in a crop is likely. The "-1" dim in a reshape is imposible then.
Change this:
https://github.com/mlzxy/devit/blob/cfd0e0e28c8cdc8c0deff9b3f9dba7dcc1a08e61/lib/regionprop.py#L79
to this:
pred_roi_mask = mask_h.reshape(N, mask_h.shape[-1], 1) * mask_w.reshape(N, 1, mask_w.shape[-1])
Same there:
gt_roi_mask = mask_h.reshape(N, mask_h.shape[-1], 1) * mask_w.reshape(N, 1, mask_w.shape[-1])
and there:
mask_logits = mask_logits.view(bs, np.prod(mask_logits.shape[1:])) / self.temperature # N x K2
The error is what follows: