tianzhi0549 / FCOS

FCOS: Fully Convolutional One-Stage Object Detection (ICCV'19)
https://arxiv.org/abs/1904.01355
Other
3.26k stars 630 forks source link

IndexError: index 0 is out of bounds in get_sample_region #190

Open toddChavezz opened 4 years ago

toddChavezz commented 4 years ago

Traceback (most recent call last): File "tools/train_net.py", line 180, in main() File "tools/train_net.py", line 173, in main model = train(cfg, args.local_rank, args.distributed) File "tools/train_net.py", line 79, in train arguments, File "/FCOS/fcos_core/engine/trainer.py", line 91, in do_train loss_dict = model(images, targets) File "/miniconda/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(*input, *kwargs) File "/FCOS/fcos_core/modeling/detector/generalized_rcnn.py", line 50, in forward proposals, proposal_losses = self.rpn(images, features, targets) File "/miniconda/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 491, in call result = self.forward(input, **kwargs) File "/FCOS/fcos_core/modeling/rpn/fcos/fcos.py", line 159, in forward centerness, targets File "/FCOS/fcos_core/modeling/rpn/fcos/fcos.py", line 169, in _forward_train locations, box_cls, box_regression, centerness, targets File "/FCOS/fcos_core/modeling/rpn/fcos/loss.py", line 224, in call labels, reg_targets = self.prepare_targets(locations, targets) File "/FCOS/fcos_core/modeling/rpn/fcos/loss.py", line 123, in prepare_targets points_all_level, targets, expanded_object_sizes_of_interest File "/FCOS/fcos_core/modeling/rpn/fcos/loss.py", line 172, in compute_targets_for_locations radius=self.center_sampling_radius File "/FCOS/fcos_core/modeling/rpn/fcos/loss.py", line 68, in get_sample_region if center_x[..., 0].sum() == 0: IndexError: index 0 is out of bounds for dimension 1 with size 0

as I want to train bounding boxes and no segmentation masks, I followed issue #79 already and that worked. But this error seems to be new. It looks like there are no bounding boxes for some images, which is not the case. I use my own dataset which is in the coco-format.

Any help is much appreciated!

trungpham2606 commented 4 years ago

@toddChavezz I'm having the same problem. How do you fix it ? P.S: i had figured out the problem. For my situation, when I converted my datasets to coco_format, I forgot to set the value of "iscrowd" in it. When i checked it, the value of my iscrowd is None, then in file fcos_core/data/datasets/coco.py line 71, anno = [obj for obj in anno if obj["iscrowd"] == 0] will return []. Just delete that line if you're sure that no image has no bounding boxes in it.

toddChavezz commented 4 years ago

@trungpham2606 the problem in my program was, that some images didn't have annotations, because my data was corrupted. Some of the bounding boxes didn't fit on the image and the implementation threw all those out.

z30832564 commented 4 years ago

Hello, I have encountered the same problem, but my data set is extracted from COCO2014's bowl category, I am sure there is no mistake, I am very troubled.When I used COCO2014 in its entirety, I had no problems.

quantumsquirrel commented 3 years ago

您好,我遇到了同样的问题,但是我的数据集是从COCO2014的碗类中提取的,我确定没有错,我很麻烦。当我完全使用COCO2014时,我没有任何问题。

Same,Have you solved the problem? It happens when I'm using dataset extracted from COCO. It seems like some annotations cannot loaded properly in get_sample_region, I log the params: center_x torch.Size([30785, 0]) center_y torch.Size([30785, 0]) center_gt torch.Size([30785, 0, 4]) which should not contain zero.

pp00704831 commented 3 years ago

Hello, Does anyone figure out how to solve it? I use my own datasets which have the max size 800 and the smallest size 144. I have removed all objects without annotation. But the problem keeps occuring: if center_x[..., 0].sum() == 0: IndexError: index 0 is out of bounds for dimension 1 with size 0