Visualizations¶
vis_bbox¶
-
chainercv.visualizations.
vis_bbox
(img, bbox, label=None, score=None, label_names=None, ax=None)¶ Visualize bounding boxes inside image.
Example
>>> from chainercv.datasets import VOCDetectionDataset >>> from chainercv.datasets import voc_detection_label_names >>> from chainercv.visualizations import vis_bbox >>> import matplotlib.pyplot as plot >>> dataset = VOCDetectionDataset() >>> img, bbox, label = dataset[60] >>> vis_bbox(img, bbox, label, ... label_names=voc_detection_label_names) >>> plot.show()
Parameters: - img (ndarray) – An array of shape \((3, height, width)\). This is in RGB format and the range of its value is \([0, 255]\).
- bbox (ndarray) – An array of shape \((R, 4)\), where
\(R\) is the number of bounding boxes in the image.
Each element is organized
by
(y_min, x_min, y_max, x_max)
in the second axis. - label (ndarray) – An integer array of shape \((R,)\).
The values correspond to id for label names stored in
label_names
. This is optional. - score (ndarray) – A float array of shape \((R,)\). Each value indicates how confident the prediction is. This is optional.
- label_names (iterable of strings) – Name of labels ordered according
to label ids. If this is
None
, labels will be skipped. - ax (matplotlib.axes.Axis) – The visualization is displayed on this
axis. If this is
None
(default), a new axis is created.
Returns: Returns the Axes object with the plot for further tweaking.
Return type: Axes
vis_image¶
-
chainercv.visualizations.
vis_image
(img, ax=None)¶ Visualize a color image.
Parameters: Returns: Returns the Axes object with the plot for further tweaking.
Return type: Axes
vis_keypoint¶
-
chainercv.visualizations.
vis_keypoint
(img, keypoint, kp_mask=None, ax=None)¶ Visualize keypoints in an image.
Example
>>> import chainercv >>> import matplotlib.pyplot as plot >>> dataset = chainercv.datasets.CUBKeypointDataset() >>> img, keypoint, kp_mask = dataset[0] >>> chainercv.visualizations.vis_keypoint(img, keypoint, kp_mask) >>> plot.show()
Parameters: - img (ndarray) – An image of shape \((3, height, width)\).
This is in RGB format and the range of its value is
\([0, 255]\). This should be visualizable using
matplotlib.pyplot.imshow(img)
- keypoint (ndarray) – An array with keypoint pairs whose shape is \((K, 2)\), where \(K\) is the number of keypoints in the array. The second axis corresponds to \(y\) and \(x\) coordinates of the keypoint.
- kp_mask (ndarray, optional) – A boolean array whose shape is
\((K,)\). If \(i\) th index is
True
, the \(i\) th keypoint is not displayed. If not specified, all keypoints inkeypoint
will be displayed. - ax (matplotlib.axes.Axes, optional) – If provided, plot on this axis.
Returns: Returns the Axes object with the plot for further tweaking.
Return type: Axes
- img (ndarray) – An image of shape \((3, height, width)\).
This is in RGB format and the range of its value is
\([0, 255]\). This should be visualizable using
vis_label¶
-
chainercv.visualizations.
vis_label
(label, label_names=None, label_colors=None, ignore_label_color=(0, 0, 0), alpha=1, ax=None)¶ Visualize a label for semantic segmentation.
Example
>>> from chainercv.datasets import VOCSemanticSegmentationDataset >>> from chainercv.datasets ... import voc_semantic_segmentation_label_colors >>> from chainercv.datasets ... import voc_semantic_segmentation_label_names >>> from chainercv.visualizations import vis_image >>> from chainercv.visualizations import vis_label >>> import matplotlib.pyplot as plot >>> dataset = VOCSemanticSegmentationDataset() >>> img, label = dataset[60] >>> ax = vis_image(img) >>> _, legend_handles = vis_label( ... label, ... label_names=voc_semantic_segmentation_label_names, ... label_colors=voc_semantic_segmentation_label_colors, ... alpha=0.9, ax=ax) >>> ax.legend(handles=legend_handles, bbox_to_anchor=(1, 1), loc=2) >>> plot.show()
Parameters: - label (ndarray) – An integer array of shape
\((height, width)\).
The values correspond to id for label names stored in
label_names
. - label_names (iterable of strings) – Name of labels ordered according to label ids.
- label_colors – (iterable of tuple): An iterable of colors for regular
labels.
Each color is RGB format and the range of its values is
\([0, 255]\).
If
colors
isNone
, the default color map used. - ignore_label_color (tuple) – Color for ignored label.
This is RGB format and the range of its values is \([0, 255]\).
The default value is
(0, 0, 0)
. - alpha (float) – The value which determines transparency of the figure.
The range of this value is \([0, 1]\). If this
value is
0
, the figure will be completely transparent. The default value is1
. This option is useful for overlaying the label on the source image. - ax (matplotlib.axes.Axis) – The visualization is displayed on this
axis. If this is
None
(default), a new axis is created.
Returns: Returns
ax
andlegend_handles
.ax
is anmatploblib.axes.Axes
with the plot. It can be used for further tweaking.legend_handles
is a list of legends. It can be passedmatploblib.pyplot.legend()
to show a legend.Return type: matploblib.axes.Axes and list of matplotlib.patches.Patch
- label (ndarray) – An integer array of shape
\((height, width)\).
The values correspond to id for label names stored in