If any bounding box coordinates are outside the image (less than 0 or more than image size) or the order of the coordinates is wrong, the loss might become nan. Check that all coordinates are within image after scaling and that all x_max > x_min and y_max > y_min.
If any bounding box coordinates are outside the image (less than 0 or more than image size) or the order of the coordinates is wrong, the loss might become nan. Check that all coordinates are within image after scaling and that all x_max > x_min and y_max > y_min.