centermask2
centermask2 copied to clipboard
'BitMasks' object has no attribute 'polygons'
Hello @youngwanLEE ,
I am trying to implement CenterMask2 https://github.com/youngwanLEE/centermask2 which makes use of Detectron2.
My annotations are in COCO RLE format, my data registration is successful. I visualized the data as well using the detectron2 visualizer, also I have set cfg.INPUT.MASk_FORMAT= bitmask
, but somehow this error is being raised while I try to train the network.
Can somebody help me out here with what could be done?
/home/student2/anaconda3/envs/Parag_Centremask2/lib/python3.8/site-packages/detectron2/data/detection_utils.py:414: 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 /opt/conda/conda-bld/pytorch_1607370172916/work/torch/csrc/utils/tensor_numpy.cpp:141.)
torch.stack([torch.from_numpy(np.ascontiguousarray(x)) for x in masks])
/home/student2/Desktop/Parag_Centremask2/centermask2/centermask/modeling/fcos/fcos_outputs.py:402: UserWarning: This overload of nonzero is deprecated:
nonzero()
Consider using one of the following signatures instead:
nonzero(*, bool as_tuple) (Triggered internally at /opt/conda/conda-bld/pytorch_1607370172916/work/torch/csrc/utils/python_arg_parser.cpp:882.)
per_candidate_nonzeros = per_candidate_inds.nonzero()
Traceback (most recent call last):
File "/home/student2/Desktop/Parag_Centremask2/centermask2/train_net.py", line 291, in <module>
launch(
File "/home/student2/anaconda3/envs/Parag_Centremask2/lib/python3.8/site-packages/detectron2/engine/launch.py", line 62, in launch
main_func(*args)
File "/home/student2/Desktop/Parag_Centremask2/centermask2/train_net.py", line 285, in main
return trainer.train()
File "/home/student2/Desktop/Parag_Centremask2/centermask2/train_net.py", line 162, in train
self.train_loop(self.start_iter, self.max_iter)
File "/home/student2/Desktop/Parag_Centremask2/centermask2/train_net.py", line 151, in train_loop
self.run_step()
File "/home/student2/anaconda3/envs/Parag_Centremask2/lib/python3.8/site-packages/detectron2/engine/defaults.py", line 423, in run_step
self._trainer.run_step()
File "/home/student2/anaconda3/envs/Parag_Centremask2/lib/python3.8/site-packages/detectron2/engine/train_loop.py", line 228, in run_step
loss_dict = self.model(data)
File "/home/student2/anaconda3/envs/Parag_Centremask2/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/student2/anaconda3/envs/Parag_Centremask2/lib/python3.8/site-packages/detectron2/modeling/meta_arch/rcnn.py", line 166, in forward
_, detector_losses = self.roi_heads(images, features, proposals, gt_instances)
File "/home/student2/anaconda3/envs/Parag_Centremask2/lib/python3.8/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
result = self.forward(*input, **kwargs)
File "/home/student2/Desktop/Parag_Centremask2/centermask2/centermask/modeling/centermask/center_heads.py", line 401, in forward
losses, mask_features, selected_mask, labels, maskiou_targets = self._forward_mask(features, proposals)
File "/home/student2/Desktop/Parag_Centremask2/centermask2/centermask/modeling/centermask/center_heads.py", line 476, in _forward_mask
loss, selected_mask, labels, maskiou_targets = mask_rcnn_loss(mask_logits, proposals, self.maskiou_on)
File "/home/student2/Desktop/Parag_Centremask2/centermask2/centermask/modeling/centermask/mask_head.py", line 80, in mask_rcnn_loss
cropped_mask = crop(instances_per_image.gt_masks.polygons, instances_per_image.proposal_boxes.tensor)
AttributeError: 'BitMasks' object has no attribute 'polygons'
I have met the same problem as you. Have you solved this problem?
I think the reason for this problem is:
cropped_mask = crop(instances_per_image.gt_masks.polygons, instances_per_image.proposal_boxes.tensor)
It is caused by the masks of training data encoded as RLE. You will need to convert the masks from RLE to polygon.
I met the same problem,but my dataset are in polygon format. could you help me?
I have the same problem
Traceback (most recent call last):
File "/root/autodl-tmp/code/detectron2/detectron2/engine/train_loop.py", line 149, in train
self.run_step()
File "/root/autodl-tmp/code/detectron2/detectron2/engine/defaults.py", line 494, in run_step
self._trainer.run_step()
File "/root/autodl-tmp/code/detectron2/detectron2/engine/train_loop.py", line 274, in run_step
loss_dict = self.model(data)
File "/root/miniconda3/envs/detectronTwoEth/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/root/autodl-tmp/code/detectron2/detectron2/modeling/meta_arch/rcnn.py", line 167, in forward
_, detector_losses = self.roi_heads(images, features, proposals, gt_instances)
File "/root/miniconda3/envs/detectronTwoEth/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/root/autodl-tmp/code/FashionpediaCode/centermask2-master/centermask2-master/centermask/modeling/centermask/center_heads.py", line 401, in forward
losses, mask_features, selected_mask, labels, maskiou_targets = self._forward_mask(features, proposals)
File "/root/autodl-tmp/code/FashionpediaCode/centermask2-master/centermask2-master/centermask/modeling/centermask/center_heads.py", line 476, in _forward_mask
loss, selected_mask, labels, maskiou_targets = mask_rcnn_loss(mask_logits, proposals, self.maskiou_on)
File "/root/autodl-tmp/code/FashionpediaCode/centermask2-master/centermask2-master/centermask/modeling/centermask/mask_head.py", line 80, in mask_rcnn_loss
cropped_mask = crop(instances_per_image.gt_masks.polygons, instances_per_image.proposal_boxes.tensor)
AttributeError: 'BitMasks' object has no attribute 'polygons'
[32m[09/17 00:45:07 d2.engine.hooks]: [0mTotal training time: 0:00:01 (0:00:00 on hooks)
[32m[09/17 00:45:07 d2.utils.events]: [0m iter: 0 lr: N/A max_mem: 16139M
Traceback (most recent call last):
File "train_netPedia.py", line 172, in