facebookresearch / maskrcnn-benchmark

Fast, modular reference implementation of Instance Segmentation and Object Detection algorithms in PyTorch.
MIT License
9.29k stars 2.5k forks source link

KeyError: "Field 'masks' not found in BoxList(num_boxes=1, image_width=1334, image_height=620, mode=xyxy)" #982

Open VinACE opened 5 years ago

VinACE commented 5 years ago

❓ Questions and Help

$python tools/train_net.py --config-file "configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml"

I checked the image width and height in my annotation file I don't have the size for error, also all the id of the image have annotation(segments), what I am missing here File "/home/p_vinsentds/maskrcnn-benchmark/maskrcnn_benchmark/modeling/roi_heads/mask_head/loss.py", line 59, in match_targets_to_proposals target = target.copy_with_fields(["labels", "masks"]) File "/home/p_vinsentds/maskrcnn-benchmark/maskrcnn_benchmark/structures/bounding_box.py", line 241, in copy_with_fields if not isinstance(fields, (list, tuple)): KeyError: "Field 'masks' not found in BoxList(num_boxes=5, image_width=1332, image_height=754, mode=xyxy)"

VinACE commented 5 years ago

Full list of the error-> if not isinstance(fields, (list, tuple)): (Pdb) c

/home/p_vinsentds/maskrcnn-benchmark/maskrcnn_benchmark/structures/bounding_box.py(241)copy_with_fields() -> if not isinstance(fields, (list, tuple)): (Pdb) c Traceback (most recent call last): File "tools/train_net.py", line 192, in main() File "tools/train_net.py", line 185, in main model = train(cfg, args.local_rank, args.distributed) File "tools/train_net.py", line 86, in train arguments, File "/home/p_vinsentds/maskrcnn-benchmark/maskrcnn_benchmark/engine/trainer.py", line 70, in do_train loss_dict = model(images, targets) File "/home/p_vinsentds/.conda/envs/qanet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in call result = self.forward(input, kwargs) File "/home/p_vinsentds/.conda/envs/qanet/lib/python3.6/site-packages/apex-0.1-py3.6-linux-x86_64.egg/apex/amp/_initialize.py", line 204, in new_fwd applier(kwargs, input_caster)) File "/home/p_vinsentds/maskrcnn-benchmark/maskrcnn_benchmark/modeling/detector/generalized_rcnn.py", line 52, in forward x, result, detector_losses = self.roi_heads(features, proposals, targets) File "/home/p_vinsentds/.conda/envs/qanet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in call result = self.forward(input, *kwargs) File "/home/p_vinsentds/maskrcnn-benchmark/maskrcnn_benchmark/modeling/roi_heads/roi_heads.py", line 39, in forward x, detections, loss_mask = self.mask(mask_features, detections, targets) File "/home/p_vinsentds/.conda/envs/qanet/lib/python3.6/site-packages/torch/nn/modules/module.py", line 493, in call result = self.forward(input, **kwargs) File "/home/p_vinsentds/maskrcnn-benchmark/maskrcnn_benchmark/modeling/roi_heads/mask_head/mask_head.py", line 77, in forward loss_mask = self.loss_evaluator(proposals, mask_logits, targets) File "/home/p_vinsentds/maskrcnn-benchmark/maskrcnn_benchmark/modeling/roi_heads/mask_head/loss.py", line 112, in call labels, mask_targets = self.prepare_targets(proposals, targets) File "/home/p_vinsentds/maskrcnn-benchmark/maskrcnn_benchmark/modeling/roi_heads/mask_head/loss.py", line 73, in prepare_targets proposals_per_image, targets_per_image File "/home/p_vinsentds/maskrcnn-benchmark/maskrcnn_benchmark/modeling/roi_heads/mask_head/loss.py", line 59, in match_targets_to_proposals target = target.copy_with_fields(["labels", "masks"]) File "/home/p_vinsentds/maskrcnn-benchmark/maskrcnn_benchmark/structures/bounding_box.py", line 241, in copy_with_fields if not isinstance(fields, (list, tuple)): KeyError: "Field 'masks' not found in BoxList(num_boxes=5, image_width=1332, image_height=754, mode=xyxy)"

bingogome commented 5 years ago

I get the same error when I tried to train on my own dataset, but it was fine when I try COCO dataset. I assume my own dataset is not in COCO-style, although I used the demos in cocoapi to validate it and it works very well...

narendoraiswamy commented 5 years ago

I am trying to use the raw PASCAL data as I need to train only on a certain number of classes. I received the same error and this is due to the non availability of the masks which is usually present in the JSON files for the dataset. Making the MASK_ON as False in the pascal_voc config works fine on the PASCAL dataset without the usage of coco format. However this wont help in generating instance segmentations. So the voc.py file inside data/datasets folder should be able to accommodate the masks for the instance segmentation and would solve the issue. Any ideas, suggestions or even workarounds regarding the same would be appreciated. @botcs @fmassa @LeviViana .

narendoraiswamy commented 5 years ago

Related to #256 . Support for this is essential for using raw png files for segmentation.