Function used to arrange the model architecture to generate bounding box with correct coordinates as below:
detections = result.reshape(-1, 5)
for i, detection in enumerate(detections):
xmin, ymin, xmax, ymax, confidence = detection
if confidence > 0.2:
xmin = int(max((xmin * image.shape[1]), 10))
ymin = int(max((ymin * image.shape[0]), 10))
xmax = int(min((xmax * image.shape[1]), image.shape[1] - 10))
ymax = int(min((ymax * image.shape[0]), image.shape[0] - 10))
Obtained incorrect coordinates of the bounding box.
Set the margin at least ten pixels from the image edge when drawing the bounding box as below:
xmin = int(max(xmin, 10))
ymin = int(max(ymin, 10))
xmax = int(min(xmax, image.shape[1] - 10))
ymax = int(min(ymax, image.shape[0] - 10))