datasetinsights.stats.visualization

datasetinsights.stats.visualization.app

datasetinsights.stats.visualization.app.get_app()

datasetinsights.stats.visualization.bbox2d_plot

Use a bounding box library to plot pretty bounding boxes with a simple Python API. This library helps to display pretty bounding boxes with a chosen set of colors. Reference: https://github.com/nalepae/bounding-box

datasetinsights.stats.visualization.bbox2d_plot.add_single_bbox_on_image(image, bbox, label, color, font_size=100, box_line_width=15)

Add single bounding box with label on a given image.

Parameters
  • image (numpy array) – a numpy array for an image.

  • bbox (BBox2D) – a canonical bounding box.

  • color (str) – a color name for one bounding box.

  • color = None (If) –

  • will randomly assign a color for each box. (it) –

  • font_size (int) – font size for each label. Defaults to 100.

  • box_line_width (int) – line width of the bounding boxes. Defaults to 15.

datasetinsights.stats.visualization.bbox3d_plot

Helper bounding box 3d library to plot pretty 3D boundign boxes with a simple Python API.

datasetinsights.stats.visualization.bbox3d_plot.add_single_bbox3d_on_image(image, box, proj, color=None, box_line_width=2, orthographic=False)

” Add single 3D bounding box on a given image.

Parameters
  • image (numpy array) – a numpy array for an image

  • box (BBox3D) – a 3D bounding box in camera’s coordinate system

  • proj (numpy 2D array) – camera’s 3x3 projection matrix

  • color (tuple) – RGBA color of the bounding box. Defaults to None. If

  • = None the the tuple of [0 (color) –

  • 255 (Green) –

  • 0 (Green) –

  • 255] (Green) –

  • box_line_width (int) – line width of the bounding boxes. Defaults to 2.

  • orthographic (bool) – true if proj is orthographic, else perspective

datasetinsights.stats.visualization.constants

datasetinsights.stats.visualization.keypoints_plot

Helper keypoints library to plot keypoint joints and skeletons with a simple Python API.

datasetinsights.stats.visualization.keypoints_plot.draw_keypoints_for_figure(image, figure, draw, templates, visual_width=6)

Draws keypoints for a figure on an image.

keypoints {

label_id: <int> Integer identifier of the label. instance_id: <str> UUID of the instance. template_guid: <str> UUID of the keypoint template. pose: <str> String label for current pose. keypoints [

{

index: <int> Index of keypoint in template. x: <float> X subpixel coordinate of keypoint. y: <float> Y subpixel coordinate of keypoint state: <int> 0: keypoint does not exist,

1: keypoint exists but is not visible, 2: keypoint exists and is visible.

}, …

]

}

Parameters
  • image (PIL Image) – a PIL image.

  • figure – The figure to draw.

  • draw (PIL ImageDraw) – PIL image draw interface.

  • templates (list) – a list of keypoint templates.

  • visual_width (int) – the visual width of the joints.

Returns: a PIL image with keypoints for a figure drawn on it.

datasetinsights.stats.visualization.object_detection

class datasetinsights.stats.visualization.object_detection.Lighting(data_root)

Bases: object

This class contains methods for object lighting statistics visualization.

metrics

a collection of metrics records

Type

sim.Metrics

lighting

contains information about per-frame light color and orientation information.

Type

pandas.DataFrame

COLOR_COLUMNS = ['color.r', 'color.g', 'color.b', 'color.a']
X_Y_COLUMNS = ['x_rotation', 'y_rotation']
html()
Method for generating html layout for the

lighting statistics.

Returns

displays lighting graphs.

Return type

html layout

class datasetinsights.stats.visualization.object_detection.ObjectPlacement(data_root)

Bases: object

This class contains methods for object orientation statistics visualization.

metrics

a collection of metrics records

Type

sim.Metrics

lighting

contains information about per-frame light color and orientation information.

Type

pandas.DataFrame

OBJECT_ORIENTATION = ('x_rot', 'y_rot', 'z_rot')
html()
Method for generating html layout for the object

orientation statistics.

Returns

displays object orientation graphs.

Return type

html layout

class datasetinsights.stats.visualization.object_detection.ScaleFactor(data_root)

Bases: object

Generate scale factor distribution.

Scale Factor describes the size of the rendered object in a capture. Higher the scale factor, higher would be the visible pixels.

Atrributes:

captures(sim.Captures): a collection of capture records.

static generate_scale_data(captures)

Method to extract scale parameter from sensor data.

Parameters

captures (sim.Captures) – a collection of capture records.

Returns

contains ‘scale’ parameter from the sensor data.

Return type

pandas.DataFrame

html()

Method for generating plots for scale factor distribution.

Returns

displays scale factor distribution.

Return type

html layout

class datasetinsights.stats.visualization.object_detection.UserParameter(data_root)

Bases: object

Generate User Parameter

Generate User Parameter table to be displayed on the Dashboard. Users parameters, such as ScaleFactors, MaxFrames, MaxForegroundObjectsPerFrame are used to control the domain randomization parameter used in the simulation.

Atrributes:

metrics(sim.Metrics): a collection of metrics records user_parameter_table (pandas.DataFrame): dataframe containing user

parameters.

Parameters

data_root (str) – path to the dataset.

html()
Method for generating html layout for the

user input parameter table.

Returns

displays user input parameter table.

Return type

html layout

datasetinsights.stats.visualization.object_detection.render_object_detection_layout(data_root)

Method for displaying object detection statistics.

Parameters

data_root (str) – path to the dataset.

Returns

displays graphs for rotation and

lighting statistics for the object.

Return type

html layout

datasetinsights.stats.visualization.overview

datasetinsights.stats.visualization.overview.generate_per_capture_count_figure(max_samples, roinfo)

Method for generating object count per capture histogram using ploty.

Parameters
  • max_samples (int) – maximum number of samples that will be included in the plot.

  • roinfo (datasetinsights.data.datasets.statistics.RenderedObjectInfo) – Rendered Object Info in Captures.

Returns

chart to display object counts per capture

Return type

plotly.graph_objects.Figure

datasetinsights.stats.visualization.overview.generate_pixels_visible_per_object_figure(max_samples, roinfo)

Method for generating pixels visible per object histogram using ploty.

Parameters
  • max_samples (int) – maximum number of samples that will be included in the plot.

  • roinfo (datasetinsights.data.datasets.statistics.RenderedObjectInfo) – Rendered Object Info in Captures.

Returns

chart to display visible pixels per object

Return type

plotly.graph_objects.Figure

datasetinsights.stats.visualization.overview.generate_total_counts_figure(max_samples, roinfo)

Method for generating total object count bar plot using ploty.

Parameters
  • max_samples (int) – maximum number of samples that will be included in the plot.

  • roinfo (datasetinsights.data.datasets.statistics.RenderedObjectInfo) – Rendered Object Info in Captures.

Returns

chart to display total object count

Return type

plotly.graph_objects.Figure

datasetinsights.stats.visualization.overview.html_overview(data_root)

Method for displaying overview statistics.

Parameters

data_root (str) – path to the dataset.

Returns

displays graphs for overview statistics.

Return type

html layout

datasetinsights.stats.visualization.overview.update_object_counts_capture_figure(label_value, json_data_root)
Method for generating object count per capture histogram for selected

object.

Parameters

label_value (str) – value selected by user using drop-down

Returns

displays object count distribution.

Return type

plotly.graph_objects.Figure

datasetinsights.stats.visualization.overview.update_visible_pixels_figure(label_value, json_data_root)

Method for generating pixels visible histogram for selected object. :param label_value: value selected by user using drop-down :type label_value: str

Returns

displays visible pixels distribution.

Return type

plotly.graph_objects.Figure

datasetinsights.stats.visualization.plots

datasetinsights.stats.visualization.plots.bar_plot(df, x, y, title=None, x_title=None, y_title=None, x_tickangle=0, **kwargs)

Create plotly bar plot

Parameters
  • df (pd.DataFrame) – A pandas dataframe that contain bar plot data.

  • x (str) – The column name of the data in x-axis.

  • y (str) – The column name of the data in y-axis.

  • title (str, optional) – The title of this plot.

  • x_title (str, optional) – The x-axis title.

  • y_title (str, optional) – The y-axis title.

  • x_tickangle (int, optional) – X-axis text tickangle (default: 0)

This method can also take addition keyword arguments that can be passed to [plotly.express.bar](https://plotly.com/python-api-reference/generated/plotly.express.bar.html#plotly.express.bar) method.

Examples

>>> import pandas as pd
>>> df = pd.DataFrame({"id": [0, 1, 2], "name": ["a", "b", "c"],
...                    "count": [10, 20, 30]})
>>> bar_plot(df, x="id", y="count", hover_name="name")
datasetinsights.stats.visualization.plots.grid_plot(images, figsize=(3, 5), img_type='rgb', titles=None)

Plot 2D array of images in grid. :param images: 2D array of images. :type images: list :param figsize: target figure size of each image in the grid. :type figsize: tuple :param Defaults to: :type Defaults to: 3, 5 :param img_type: image plot type (“rgb”, “gray”). Defaults to “rgb”. :type img_type: string :param titles: a list of titles. Defaults to None. :type titles: list[str]

Returns

matplotlib figure the combined grid plot.

datasetinsights.stats.visualization.plots.histogram_plot(df, x, max_samples=None, title=None, x_title=None, y_title=None, **kwargs)

Create plotly histogram plot

Parameters
  • df (pd.DataFrame) – A pandas dataframe that contain raw data.

  • x (str) – The column name of the raw data for histogram plot.

  • title (str, optional) – The title of this plot.

  • x_title (str, optional) – The x-axis title.

  • y_title (str, optional) – The y-axis title.

This method can also take addition keyword arguments that can be passed to [plotly.express.histogram](https://plotly.com/python-api-reference/generated/plotly.express.histogram.html) method.

Examples

>>> import pandas as pd
>>> df = pd.DataFrame({"id": [0, 1, 2], "count": [10, 20, 30]})
>>> histogram_plot(df, x="count")

Histnorm plot using probability density:

>>> histogram_plot(df, x="count", histnorm="probability density")
datasetinsights.stats.visualization.plots.model_performance_box_plot(title=None, mean_ap=None, mean_ap_50=None, mean_ar=None, range=[0, 1.0], **kwargs)

Create a box plot for one model performance :param title: title of the plot :type title: str :param mean_ap: a list of base mAP :type mean_ap: list :param mean_ap_50: a list of base mAP :type mean_ap_50: list :param mean_ar: a list of base mAP :type mean_ar: list :param range: the range of y axis. Defaults to [0, 1.0] :type range: list

Returns

A plotly.graph_objects.Figure containing the box plot

datasetinsights.stats.visualization.plots.model_performance_comparison_box_plot(title=None, mean_ap_base=None, mean_ap_50_base=None, mean_ar_base=None, mean_ap_new=None, mean_ap_50_new=None, mean_ar_new=None, range=[0, 1.0], **kwargs)

Create a box plot for a base and new model performance :param title: title of the plot :type title: str :param mean_ap_base: a list of base mAP :type mean_ap_base: list :param mean_ap_50_base: a list of base mAP :type mean_ap_50_base: list :param mean_ar_base: a list of base mAP :type mean_ar_base: list :param mean_ap_new: a list of base mAP :type mean_ap_new: list :param mean_ap_50_new: a list of base mAP :type mean_ap_50_new: list :param mean_ar_new: a list of base mAP :type mean_ar_new: list :param range: the range of y axis. Defaults to [0, 1.0] :type range: list

Returns

A plotly.graph_objects.Figure containing the box plot

datasetinsights.stats.visualization.plots.plot_bboxes(image, bboxes, label_mappings=None, colors=None)

Plot an image with bounding boxes.

For ground truth image, a color is randomly selected for each bounding box. For prediction, the color of a boundnig box is coded based on IOU value between prediction and ground truth bounding boxes. It is considered true positive if IOU >= 0.5. We only visualize prediction bounding box with score >= 0.5. For prediction, it’s a green box if the predicted bounding box can be matched to a ground truth bounding boxes. It’s a red box if the predicted bounding box can’t be matched to a ground truth bounding boxes.

Parameters
  • image (PIL Image) – a PIL image.

  • bboxes (list) – a list of BBox2D objects.

  • label_mappings (dict) – a dict of {label_id: label_name} mapping

  • to None. (Defaults) –

  • colors (list) – a color list for boxes. Defaults to None.

  • colors = None (If) –

  • will randomly assign PIL.COLORS for each box. (it) –

Returns

a PIL image with bounding boxes drawn.

Return type

PIL Image

datasetinsights.stats.visualization.plots.plot_bboxes3d(image, bboxes, projection, colors=None, orthographic=False)

Plot an image with 3D bounding boxes

Currently this method should only be used for ground truth images, and doesn’t support predictions. If a list of colors is not provided as an argument to this routine, the default color of green will be used.

Parameters
  • image (PIL Image) – a PIL image.

  • bboxes (list) – a list of BBox3D objects

  • projection – The perspective projection of the camera which

  • the ground truth. (captured) –

  • colors (list) – a color list for boxes. Defaults to none. If

  • = None (colors) –

  • will default to coloring all boxes green. (it) –

  • orthographic (bool) – true if proj is orthographic, else perspective

Returns

a PIL image with bounding boxes drawn on it.

Return type

PIL image

datasetinsights.stats.visualization.plots.plot_keypoints(image, annotations, templates, visual_width=6)

Plot an image with keypoint data.

Currently only used for ground truth info. Keypoints and colors are defined in templates.

Parameters
  • image (PIL Image) – a PIL image.

  • annotations (list) – a list of keypoint annotation data.

  • templates (list) – a list of keypoint templates.

  • visual_width (int) – the width of the visual elements

Returns

a PIL image with keypoints drawn.

Return type

PIL Image

datasetinsights.stats.visualization.plots.rotation_plot(df, x, y, z=None, max_samples=None, title=None, **kwargs)

Create a plotly 3d rotation plot :param df: A pandas dataframe that contains the raw data. :type df: pd.DataFrame :param x: The column name containing x rotations. :type x: str :param y: The column name containing y rotations. :type y: str :param z: The column name containing z rotations. :type z: str, optional :param title: The title of this plot. :type title: str, optional

This method can also take addition keyword arguments that can be passed to [plotly.graph_objects.Scatter3d](https://plotly.com/python-api-reference/generated/plotly.graph_objects.Scatter3d.html) method.

Returns

A plotly.graph_objects.Figure containing the scatter plot

datasetinsights.stats.visualization.grid_plot(images, figsize=(3, 5), img_type='rgb', titles=None)

Plot 2D array of images in grid. :param images: 2D array of images. :type images: list :param figsize: target figure size of each image in the grid. :type figsize: tuple :param Defaults to: :type Defaults to: 3, 5 :param img_type: image plot type (“rgb”, “gray”). Defaults to “rgb”. :type img_type: string :param titles: a list of titles. Defaults to None. :type titles: list[str]

Returns

matplotlib figure the combined grid plot.

datasetinsights.stats.visualization.plot_bboxes(image, bboxes, label_mappings=None, colors=None)

Plot an image with bounding boxes.

For ground truth image, a color is randomly selected for each bounding box. For prediction, the color of a boundnig box is coded based on IOU value between prediction and ground truth bounding boxes. It is considered true positive if IOU >= 0.5. We only visualize prediction bounding box with score >= 0.5. For prediction, it’s a green box if the predicted bounding box can be matched to a ground truth bounding boxes. It’s a red box if the predicted bounding box can’t be matched to a ground truth bounding boxes.

Parameters
  • image (PIL Image) – a PIL image.

  • bboxes (list) – a list of BBox2D objects.

  • label_mappings (dict) – a dict of {label_id: label_name} mapping

  • to None. (Defaults) –

  • colors (list) – a color list for boxes. Defaults to None.

  • colors = None (If) –

  • will randomly assign PIL.COLORS for each box. (it) –

Returns

a PIL image with bounding boxes drawn.

Return type

PIL Image