The draw function will draw a box inside the identified image and put text on the image as a label, as well as place a prediction percentage for the identified class.
We will use OpenCV techniques in this step:
def draw_box(image, image_boxes, image_scores, image_classes, image_all_classes):
"""Draw the boxes on the image.
# Argument:
image: original image.
image_boxes: ndarray, boxes of objects.
image_classes: ndarray, classes of objects.
image_scores: ndarray, scores of objects.
image_all_classes: all classes name.
"""
for box, score, cl in zip(image_boxes, image_scores, image_classes):
x, y, w, h = box
image_top = max(0, np.floor(x + 0.5).astype(int))
image_left = max(0, np.floor(y + 0.5).astype(int))
image_right = min(image.shape[1], np.floor(x + w + 0.5).astype(int))
image_bottom = min(image.shape[0], np.floor(y + h + 0.5).astype(int))
cv2.rectangle(image, (image_top...