--- title: visualization keywords: fastai sidebar: home_sidebar summary: "API details." description: "API details." nb_path: "nbs/05_visualization.ipynb" ---
{% raw %}
{% endraw %} {% raw %}
'\nCopyright 2017-2018 Fizyr (https://fizyr.com)\n\nLicensed under the Apache License, Version 2.0 (the "License");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n'
{% endraw %} {% raw %}
{% endraw %} {% raw %}

label_color[source]

label_color(label)

Return a color from a set of predefined colors. Contains 80 colors in total.

Args label: The label to get the color for.

Returns A list of three values representing a RGB color.

If no color is defined for a certain label, the color green is returned and a warning is printed.
{% endraw %} {% raw %}
{% endraw %} {% raw %}

draw_box[source]

draw_box(image, box, color, thickness=2)

Draws a box on an image with a given color.

Arguments

image     : The image to draw on.
box       : A list of 4 elements (x1, y1, x2, y2).
color     : The color of the box.
thickness : The thickness of the lines to draw a box with.
{% endraw %} {% raw %}

draw_caption[source]

draw_caption(image, box, caption)

Draws a caption above the box in an image.

Arguments

image   : The image to draw on.
box     : A list of 4 elements (x1, y1, x2, y2).
caption : String containing the text to draw.
{% endraw %} {% raw %}

draw_boxes[source]

draw_boxes(image, boxes, color, thickness=2)

Draws boxes on an image with a given color.

Arguments

image     : The image to draw on.
boxes     : A [N, 4] matrix (x1, y1, x2, y2).
color     : The color of the boxes.
thickness : The thickness of the lines to draw boxes with.
{% endraw %} {% raw %}

draw_detections[source]

draw_detections(image, boxes, scores, labels, color=None, label_to_name=None, score_threshold=0.5)

Draws detections in an image.

Arguments

image           : The image to draw on.
boxes           : A [N, 4] matrix (x1, y1, x2, y2).
scores          : A list of N classification scores.
labels          : A list of N labels.
color           : The color of the boxes. By default the color from keras_retinanet.utils.colors.label_color will be used.
label_to_name   : (optional) Functor for mapping a label to a name.
score_threshold : Threshold used for determining what detections to draw.
{% endraw %} {% raw %}

draw_annotations[source]

draw_annotations(image, annotations, color=(0, 255, 0), label_to_name=None)

Draws annotations in an image.

Arguments

image         : The image to draw on.
annotations   : A [N, 5] matrix (x1, y1, x2, y2, label) or dictionary containing bboxes (shaped [N, 4]) and labels (shaped [N]).
color         : The color of the boxes. By default the color from keras_retinanet.utils.colors.label_color will be used.
label_to_name : (optional) Functor for mapping a label to a name.
{% endraw %} {% raw %}
{% endraw %}