def visualize_results(img_path,
                      bboxes,
                      labels,
                      scores,
                      cfg,
                      store_to_path=None):
    """
    Renders the detection results (bboxes and labels) onto the image.
    :param img_path: the path to the image
    :param bboxes: the predicted bounding boxes
    :param labels: the single class label per bounding box
    :param scores: the probability for the assigned class label per bounding box
    :param cfg: the configuration
    :param store_to_path: optional: a path where to store the rendered image.
                          If set to 'None' the image will be displayed on screen.
    :return:
    """

    from matplotlib.pyplot import imsave, imshow, show
    from utils.plot_helpers import visualize_detections
    img = visualize_detections(img_path,
                               bboxes,
                               labels,
                               scores,
                               cfg.IMAGE_WIDTH,
                               cfg.IMAGE_HEIGHT,
                               classes=cfg["DATA"].CLASSES,
                               draw_negative_rois=cfg.DRAW_NEGATIVE_ROIS)

    if store_to_path is not None:
        imsave(store_to_path, img)
    else:
        imshow(img)
        show()
示例#2
0
def visualize_results(img_path, bboxes, labels, scores, cfg, store_to_path=None):
    """
    Renders the detection results (bboxes and labels) onto the image.
    :param img_path: the path to the image
    :param bboxes: the predicted bounding boxes
    :param labels: the single class label per bounding box
    :param scores: the probability for the assigned class label per bounding box
    :param cfg: the configuration
    :param store_to_path: optional: a path where to store the rendered image.
                          If set to 'None' the image will be displayed on screen.
    :return:
    """

    from matplotlib.pyplot import imsave, imshow, show
    from utils.plot_helpers import visualize_detections
    img = visualize_detections(img_path, bboxes, labels, scores,
                               cfg.IMAGE_WIDTH, cfg.IMAGE_HEIGHT,
                               classes = cfg["DATA"].CLASSES,
                               draw_negative_rois = cfg.DRAW_NEGATIVE_ROIS)

    if store_to_path is not None:
        imsave(store_to_path, img)
    else:
        imshow(img)
        show()