eriklindernoren/PyTorch-YOLOv3

Negative values for some coordinates

alexandru-dinu opened this issue · 1 comments

What is the reason of having negative values for some coordinates, when converting from
(center x, center y, width, height) to (x1, y1, x2, y2) (in non_max_suppresion function)?

For example, the values for x1 coordinates are calculated as:
box_corner[:, :, 0] = prediction[:, :, 0] - prediction[:, :, 2] / 2 and there are some negative values here.

box_corner[:, :, 0] <= 0 boils down to sigmoid(tx) + grid_x <= anchor_w * exp(tw) / 2.

How can this happen?

Thanks!

There is not really a reason for having the model output negative values for the corner coordinates. It is of course penalized for doing so during training (since there won't be negative values occuring in the label set) but there is no explicit restriction set in place to hinder the model from outputting them. You could map negative values to zero if this is a problem for your use case.