summary#

Methods to display examples and their label issues in an object detection dataset.

Functions:

visualize(image, *[, label, prediction, ...])

Display the annotated bounding boxes (given labels) and predicted bounding boxes (model predictions) for a particular image.

cleanlab.object_detection.summary.visualize(image, *, label=None, prediction=None, prediction_threshold=None, overlay=True, class_names=None, figsize=None, save_path=None)[source]#

Display the annotated bounding boxes (given labels) and predicted bounding boxes (model predictions) for a particular image. Given labels are shown in red, model predictions in blue.

Parameters:
  • image (Union[str, TypeVar(Image)]) – Image object loaded into memory or full path to the image file. If path is provided, image is loaded into memory.

  • label (Optional[Dict[str, Any]]) –

    The given label for a single image in the format {'bboxes': np.ndarray((L,4)), 'labels': np.ndarray((L,))} where L is the number of bounding boxes for the i-th image and bboxes[j] is in the format [x1,y1,x2,y2] with given label labels[j].

    Note: Here, [x1,y1] corresponds to the coordinates of the bottom-left corner of the bounding box, while [x2,y2] corresponds to the coordinates of the top-right corner of the bounding box. The last column, pred_prob, represents the predicted probability that the bounding box contains an object of the class k.

  • prediction (Optional[ndarray]) – A prediction for a single image in the format np.ndarray((K,)) and prediction[k] is of shape np.ndarray(N,5) where M is the number of predicted bounding boxes for class k and the five columns correspond to [x,y,x,y,pred_prob] where [x,y,x,y] are the bounding box coordinates predicted by the model and pred_prob is the model’s confidence in predictions[i].

  • prediction_threshold (Optional[float]) – All model-predicted bounding boxes with confidence (pred_prob) below this threshold are omitted from the visualization.

  • overlay (bool) – If True, display a single image with given labels and predictions overlaid. If False, display two images (side by side) with the left image showing the model predictions and the right image showing the given label.

  • class_names (Optional[Dict[Any, Any]]) – Optional dictionary mapping one-hot-encoded class labels back to their original class names in the format {"integer-label": "original-class-name"}.

  • save_path (Optional[str]) – Path to save figure at. If a path is provided, the figure is saved. To save in a specific image format, add desired file extension to the end of save_path. Allowed file extensions are: ‘png’, ‘pdf’, ‘ps’, ‘eps’, and ‘svg’.

  • figsize (Optional[Tuple[int, int]]) – Optional figure size for plotting the image. Corresponds to matplotlib.figure.figsize.

Return type:

None