src/maskrcnn/model.py
def overlay_class_names(image, predictions):
    """
    Adds detected class names and scores in the positions defined by the
    top-left corner of the predicted bounding box

    Arguments:
        image (np.ndarray): an image as returned by OpenCV
        predictions (BoxList): the result of the computation by the model.
            It should contain the field `scores` and `labels`.
    """
    scores = predictions.get_field("scores").tolist()
    labels = predictions.get_field("labels").tolist()
    labels = [CATEGORIES[i] for i in labels]
    boxes = predictions.bbox

    template = "{}: {:.2f}"
    for box, score, label in zip(boxes, scores, labels):
        x, y = box[:2]
        s = template.format(label, score)
        cv2.putText(image, s, (x, y), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)

    return image

    Adds detected class names and scores in the positions defined by the
    top-left corner of the predicted bounding box

    Arguments:
        image (np.ndarray): an image as returned by OpenCV
        predictions (BoxList): the result of the computation by the model.
            It should contain the field `scores` and `labels`.
    
Adds detected class names and scores in the positions defined by the
top-left corner of the predicted bounding box
Adds detected class names and scores in the positions defined by the top - left corner of the predicted bounding box
def overlay_class_names(image, predictions):
    scores = predictions.get_field("scores").tolist()
    labels = predictions.get_field("labels").tolist()
    labels = [CATEGORIES[i] for i in labels]
    boxes = predictions.bbox
    template = "{}: {:.2f}"
    for box, score, label in zip(boxes, scores, labels):
        x, y = box[:2]
        s = template.format(label, score)
        cv2.putText(image, s, (x, y), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 1)
    return image
def overlay_class_names ( image , predictions ) : scores = predictions . get_field ( "scores" ) . tolist ( ) labels = predictions . get_field ( "labels" ) . tolist ( ) labels = [ CATEGORIES [ i ] for i in labels ] boxes = predictions . bbox template = "{}: {:.2f}" for box , score , label in zip ( boxes , scores , labels ) : x , y = box [ : 2 ] s = template . format ( label , score ) cv2 . putText ( image , s , ( x , y ) , cv2 . FONT_HERSHEY_SIMPLEX , 0.5 , ( 255 , 255 , 255 ) , 1 ) return image
Adds detected class names and scores in the positions defined by the
top-left corner of the predicted bounding box
Adds detected class names and scores in the positions defined by the top - left corner of the predicted bounding box
"""
    Adds detected class names and scores in the positions defined by the
    top-left corner of the predicted bounding box

    Arguments:
        image (np.ndarray): an image as returned by OpenCV
        predictions (BoxList): the result of the computation by the model.
            It should contain the field `scores` and `labels`.
    """
image
an image as returned by OpenCV
an image as returned by OpenCV
predictions
the result of the computation by the model.
It should contain the field `scores` and `labels`.
the result of the computation by the model . It should contain the field ` scores ` and ` labels ` .