MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / make_multianimal_labeled_image

Function make_multianimal_labeled_image

deeplabcut/utils/visualization.py:120–213  ·  view source on GitHub ↗

Plots groundtruth labels and predictions onto the matplotlib's axes, with the specified graphical parameters. Args: frame: image coords_truth: groundtruth labels coords_pred: predictions probs_pred: prediction probabilities colors: colors for poses

(
    frame: np.ndarray,
    coords_truth: np.ndarray | list,
    coords_pred: np.ndarray | list,
    probs_pred: np.ndarray | list,
    colors: Colormap,
    dotsize: float | int = 12,
    alphavalue: float = 0.7,
    pcutoff: float = 0.6,
    labels: list = None,
    ax: plt.Axes | None = None,
    bounding_boxes: tuple[np.ndarray, np.ndarray] | None = None,
    bboxes_cutoff: float = 0.6,
    bboxes_color: Colormap | str | None = None,
)

Source from the content-addressed store, hash-verified

118
119
120def make_multianimal_labeled_image(
121 frame: np.ndarray,
122 coords_truth: np.ndarray | list,
123 coords_pred: np.ndarray | list,
124 probs_pred: np.ndarray | list,
125 colors: Colormap,
126 dotsize: float | int = 12,
127 alphavalue: float = 0.7,
128 pcutoff: float = 0.6,
129 labels: list = None,
130 ax: plt.Axes | None = None,
131 bounding_boxes: tuple[np.ndarray, np.ndarray] | None = None,
132 bboxes_cutoff: float = 0.6,
133 bboxes_color: Colormap | str | None = None,
134) -> plt.Axes:
135 """Plots groundtruth labels and predictions onto the matplotlib's axes, with the
136 specified graphical parameters.
137
138 Args:
139 frame: image
140 coords_truth: groundtruth labels
141 coords_pred: predictions
142 probs_pred: prediction probabilities
143 colors: colors for poses
144 dotsize: size of dot
145 alphavalue: transparency for the keypoints
146 pcutoff: cut-off confidence value
147 labels: labels to use for ground truth, reliable predictions, and not reliable predictions (confidence below
148 cut-off value)
149 ax: matplotlib plot's axes object
150 bounding_boxes: bounding boxes (top-left corner, size) and their respective confidence levels,
151 bboxes_cutoff: bounding boxes confidence cutoff threshold.
152 bboxes_color: color(s) for the bounding boxes.
153 If Colormap is passed -> each bounding box will be colored into its own color from the colormap.
154 If string is passed -> all bboxes will be of string's defined color.
155 If None -> all bboxes will be colored into a default color.
156
157 Returns:
158 matplotlib Axes object with plotted labels and predictions.
159 """
160
161 if labels is None:
162 labels = ["+", ".", "x"]
163 if ax is None:
164 h, w, _ = np.shape(frame)
165 _, ax = prepare_figure_axes(w, h)
166 ax.imshow(frame, "gray")
167
168 if bounding_boxes is not None:
169 for i, (bbox, bbox_score) in enumerate(zip(bounding_boxes[0], bounding_boxes[1], strict=False)):
170 bbox_origin = (bbox[0], bbox[1])
171 (bbox_width, bbox_height) = (bbox[2], bbox[3])
172 if isinstance(bboxes_color, Colormap):
173 bbox_color = bboxes_color(i)
174 elif bboxes_color is None:
175 bbox_color = "red"
176 else:
177 bbox_color = bboxes_color

Callers 2

plot_gt_and_predictionsFunction · 0.90
plot_evaluation_resultsFunction · 0.85

Calls 2

prepare_figure_axesFunction · 0.85
plotMethod · 0.80

Tested by

no test coverage detected