Amodal-Segmentation-Based-on-Visible-Region-Segmentation-and-Shape-Prior
Amodal-Segmentation-Based-on-Visible-Region-Segmentation-and-Shape-Prior copied to clipboard
从dataloader里获取数据的时候报错
感谢作者,就是我下载了d2sa数据集,并且在builtin.py中设置了数据集的路径
_PREDEFINED_SPLITS_D2SA = {
"d2sa_train": ("D2SA/images", "D2SA/annotations/D2S_amodal_training_rot0.json"),
"d2sa_train_visible": ("D2SA/images", "D2SA/annotations/D2S_amodal_training_rot0.json"),
"d2sa_train_aug": ("D2SA/images", "D2SA/annotations/D2S_amodal_augmented.json"),
"d2sa_train_aug_visible": ("D2SA/images", "D2SA/annotations/D2S_amodal_augmented.json"),
}
def register_all_d2sa(root="D:\\Desktop\\refproject\\ShapePrior\\Amodal"):
for key, (image_root, json_file) in _PREDEFINED_SPLITS_D2SA.items():
# Assume pre-defined datasets live in `./datasets`.
register_d2sa_instances(
key,
_get_builtin_metadata("d2sa"),
os.path.join(root, json_file) if "://" not in json_file else json_file,
os.path.join(root, image_root),
)
``
但是运行之后报错
d:\desktop\refproject\shapeprior\amodal\detectron2.21shape\detectron2\data\detection_utils.py:275: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:141.)
masks = BitMasks(torch.stack([torch.from_numpy(x) for x in segm]))
[01/20 13:41:17 d2.engine.train_loop]: Starting training from iteration 0
d:\desktop\refproject\shapeprior\amodal\detectron2.21shape\detectron2\data\detection_utils.py:275: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:141.)
masks = BitMasks(torch.stack([torch.from_numpy(x) for x in segm]))
d:\desktop\refproject\shapeprior\amodal\detectron2.21shape\detectron2\modeling\roi_heads\fast_rcnn.py:333: UserWarning: This overload of nonzero is deprecated:
nonzero()
Consider using one of the following signatures instead:
nonzero(*, bool as_tuple) (Triggered internally at ..\torch\csrc\utils\python_arg_parser.cpp:882.)
num_fg = fg_inds.nonzero().numel()
Traceback (most recent call last):
File "D:/Desktop/refproject/ShapePrior/Amodal/tools/train_net.py", line 214, in <module>
launch(
File "d:\desktop\refproject\shapeprior\amodal\detectron2.21shape\detectron2\engine\launch.py", line 51, in launch
main_func(*args)
File "D:/Desktop/refproject/ShapePrior/Amodal/tools/train_net.py", line 208, in main
return trainer.train()
File "d:\desktop\refproject\shapeprior\amodal\detectron2.21shape\detectron2\engine\defaults.py", line 418, in train
super().train(self.start_iter, self.max_iter)
File "d:\desktop\refproject\shapeprior\amodal\detectron2.21shape\detectron2\engine\train_loop.py", line 132, in train
self.run_step()
File "d:\desktop\refproject\shapeprior\amodal\detectron2.21shape\detectron2\engine\train_loop.py", line 211, in run_step
data = next(self._data_loader_iter)
File "D:\ProgramData\Anaconda3\envs\shape\lib\site-packages\torch\utils\data\dataloader.py", line 435, in __next__
data = self._next_data()
File "D:\ProgramData\Anaconda3\envs\shape\lib\site-packages\torch\utils\data\dataloader.py", line 1065, in _next_data
return self._process_data(data)
File "D:\ProgramData\Anaconda3\envs\shape\lib\site-packages\torch\utils\data\dataloader.py", line 1111, in _process_data
data.reraise()
File "D:\ProgramData\Anaconda3\envs\shape\lib\site-packages\torch\_utils.py", line 428, in reraise
raise self.exc_type(msg)
ValueError: Caught ValueError in DataLoader worker process 2.
Original Traceback (most recent call last):
File "D:\ProgramData\Anaconda3\envs\shape\lib\site-packages\torch\utils\data\_utils\worker.py", line 198, in _worker_loop
data = fetcher.fetch(index)
File "D:\ProgramData\Anaconda3\envs\shape\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "D:\ProgramData\Anaconda3\envs\shape\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "d:\desktop\refproject\shapeprior\amodal\detectron2.21shape\detectron2\data\common.py", line 39, in __getitem__
data = self._map_func(self._dataset[cur_idx])
File "d:\desktop\refproject\shapeprior\amodal\detectron2.21shape\detectron2\data\dataset_mapper.py", line 130, in __call__
instances = utils.annotations_to_instances(
File "d:\desktop\refproject\shapeprior\amodal\detectron2.21shape\detectron2\data\detection_utils.py", line 275, in annotations_to_instances
masks = BitMasks(torch.stack([torch.from_numpy(x) for x in segm]))
File "d:\desktop\refproject\shapeprior\amodal\detectron2.21shape\detectron2\data\detection_utils.py", line 275, in <listcomp>
masks = BitMasks(torch.stack([torch.from_numpy(x) for x in segm]))
ValueError: At least one stride in the given numpy array is negative, and tensors with negative strides are not currently supported. (You can probably work around this by making a copy of your array with array.copy().)
[01/20 13:41:19 d2.engine.hooks]: Total training time: 0:00:00 (0:00:00 on hooks)
Process finished with exit code 1
同问,请问解决了吗?