yolact icon indicating copy to clipboard operation
yolact copied to clipboard

IndexError: max(): Expected reduction dim 0 to have non-zero size.

Open AbhiKhoyani opened this issue 3 years ago • 1 comments

I'm training Yolact model for my custom dataset and continuously getting this error: IndexError: max(): Expected reduction dim 0 to have non-zero size after uncertain iterations. I'm using pre-trained weights resnet50-19c8e357.pth and Yolact model. Sometimes it runs for 5-6 iteration and gives this error and sometimes it runs for 20-30 iteration and then after gives this error.

Below is the error trace.

overlaps size: torch.Size([0, 16368]) #I've printed this overlap shape for referance. Traceback (most recent call last): File "train.py", line 509, in train() File "train.py", line 312, in train losses = net(datum) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/data_parallel.py", line 166, in forward return self.module(*inputs[0], **kwargs[0]) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "train.py", line 146, in forward losses = self.criterion(self.net, preds, targets, masks, num_crowds) File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, **kwargs) File "/content/yolact/layers/modules/multibox_loss.py", line 124, in forward loc_t, conf_t, idx_t, idx, loc_data[idx]) File "/content/yolact/layers/box_utils.py", line 185, in match best_truth_overlap, best_truth_idx = overlaps.max(0) IndexError: max(): Expected reduction dim 0 to have non-zero size.

By going through this error partially I came to know because of Intersection over Union values could be zero for some images and during that it might be raising error. Any help on above will be much appreciated.

AbhiKhoyani avatar Jan 15 '22 07:01 AbhiKhoyani

me too. ssame issue

JamesLeeeeeee avatar Aug 09 '22 03:08 JamesLeeeeeee

Have you solve the issue? I had a same issue

HZYO-0 avatar May 29 '23 11:05 HZYO-0

maybe you can change your batch size

cw-maker avatar Jun 03 '23 07:06 cw-maker

Ohh yess, sorry I forgot to mention here that the problem was assigned class id in annotation. Since, the model is considering background as a class 0, all the other class in dataset should have class id of greater than 1.

AbhiKhoyani avatar Oct 17 '23 13:10 AbhiKhoyani