Errors when use some images only with background
oyxhust opened this issue · 2 comments
Hello, I am using your code to train my customer dataset. In my dataset, there are some images only with the background (without any bboxes). I met an issue:
Traceback (most recent call last):
File "train.py", line 289, in
main()
File "train.py", line 279, in main
train(train_loader, net, criterion, optimizer, epoch, epoch_step, gamma, use_refine)
File "train.py", line 106, in train
loss_l, loss_c = ssd_criterion(output, targets)
File "/home/xiouyang/.conda/envs/py36/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "/home/xiouyang/kaggle/ssd_xi/layers/modules/multibox_loss.py", line 115, in forward
loss_c = F.cross_entropy(conf_p, targets_weighted, size_average=False)
File "/home/xiouyang/.conda/envs/py36/lib/python3.6/site-packages/torch/nn/functional.py", line 1550, in cross_entropy
return nll_loss(log_softmax(input, 1), target, weight, None, ignore_index, None, reduction)
File "/home/xiouyang/.conda/envs/py36/lib/python3.6/site-packages/torch/nn/functional.py", line 975, in log_softmax
return input.log_softmax(dim)
RuntimeError: Dimension out of range (expected to be in range of [-1, 0], but got 1)
or sometimes the training is stopped.
I check the size of "conf_p" and "targets_weighted" in the "multibox_loss.py". I find:
conf_p: torch.Size([0]), targets_weighted: torch.Size([0])
This issue only happens sometimes. Any idea for this problem?
By the way, there are another little problem in "voc_eval.py":
plt_save_path = os.path.join(".", "eval", "pr")
if not os.path.exists(plt_save_path):
os.makedirs(plt_save_path)
pr_curl = os.path.join(plt_save_path, '{}{}{}pr.jpg'.format(classname, str(final_prec), str(final_rec)))
Before storing the eval image, it should make the dir.
Ok, thanks a lot!