---

title: visualization


keywords: fastai
sidebar: home_sidebar

summary: "API details."
description: "API details."
nb_path: "nbs/05_visualization.ipynb"
---
<!--

#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: nbs/05_visualization.ipynb
# command to build the docs after a change: nbdev_build_docs

-->

<div class="container" id="notebook-container">
        
    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">



<div class="output_text output_subarea output_execute_result">
<pre>&#39;\nCopyright 2017-2018 Fizyr (https://fizyr.com)\n\nLicensed under the Apache License, Version 2.0 (the &#34;License&#34;);\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 &#34;AS IS&#34; 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&#39;</pre>
</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="label_color" class="doc_header"><code>label_color</code><a href="https://github.com/aniketmaurya/chitra/tree/master/chitra/visualization.py#L27" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>label_color</code>(<strong><code>label</code></strong>)</p>
</blockquote>
<p>Return a color from a set of predefined colors. Contains 80 colors in total.</p>
<p>Args
    label: The label to get the color for.</p>
<p>Returns
    A list of three values representing a RGB color.</p>

<pre><code>If no color is defined for a certain label, the color green is returned and a warning is printed.</code></pre>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="draw_box" class="doc_header"><code>draw_box</code><a href="https://github.com/aniketmaurya/chitra/tree/master/chitra/visualization.py#L143" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>draw_box</code>(<strong><code>image</code></strong>, <strong><code>box</code></strong>, <strong><code>color</code></strong>, <strong><code>thickness</code></strong>=<em><code>2</code></em>)</p>
</blockquote>
<p>Draws a box on an image with a given color.</p>
<h1 id="Arguments">Arguments<a class="anchor-link" href="#Arguments"> </a></h1>
<pre><code>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.</code></pre>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="draw_caption" class="doc_header"><code>draw_caption</code><a href="https://github.com/aniketmaurya/chitra/tree/master/chitra/visualization.py#L156" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>draw_caption</code>(<strong><code>image</code></strong>, <strong><code>box</code></strong>, <strong><code>caption</code></strong>)</p>
</blockquote>
<p>Draws a caption above the box in an image.</p>
<h1 id="Arguments">Arguments<a class="anchor-link" href="#Arguments"> </a></h1>
<pre><code>image   : The image to draw on.
box     : A list of 4 elements (x1, y1, x2, y2).
caption : String containing the text to draw.</code></pre>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="draw_boxes" class="doc_header"><code>draw_boxes</code><a href="https://github.com/aniketmaurya/chitra/tree/master/chitra/visualization.py#L169" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>draw_boxes</code>(<strong><code>image</code></strong>, <strong><code>boxes</code></strong>, <strong><code>color</code></strong>, <strong><code>thickness</code></strong>=<em><code>2</code></em>)</p>
</blockquote>
<p>Draws boxes on an image with a given color.</p>
<h1 id="Arguments">Arguments<a class="anchor-link" href="#Arguments"> </a></h1>
<pre><code>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.</code></pre>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="draw_detections" class="doc_header"><code>draw_detections</code><a href="https://github.com/aniketmaurya/chitra/tree/master/chitra/visualization.py#L182" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>draw_detections</code>(<strong><code>image</code></strong>, <strong><code>boxes</code></strong>, <strong><code>scores</code></strong>, <strong><code>labels</code></strong>, <strong><code>color</code></strong>=<em><code>None</code></em>, <strong><code>label_to_name</code></strong>=<em><code>None</code></em>, <strong><code>score_threshold</code></strong>=<em><code>0.5</code></em>)</p>
</blockquote>
<p>Draws detections in an image.</p>
<h1 id="Arguments">Arguments<a class="anchor-link" href="#Arguments"> </a></h1>
<pre><code>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.</code></pre>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

<div class="output_wrapper">
<div class="output">

<div class="output_area">


<div class="output_markdown rendered_html output_subarea ">
<h4 id="draw_annotations" class="doc_header"><code>draw_annotations</code><a href="https://github.com/aniketmaurya/chitra/tree/master/chitra/visualization.py#L205" class="source_link" style="float:right">[source]</a></h4><blockquote><p><code>draw_annotations</code>(<strong><code>image</code></strong>, <strong><code>annotations</code></strong>, <strong><code>color</code></strong>=<em><code>(0, 255, 0)</code></em>, <strong><code>label_to_name</code></strong>=<em><code>None</code></em>)</p>
</blockquote>
<p>Draws annotations in an image.</p>
<h1 id="Arguments">Arguments<a class="anchor-link" href="#Arguments"> </a></h1>
<pre><code>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.</code></pre>

</div>

</div>

</div>
</div>

</div>
    {% endraw %}

    {% raw %}
    
<div class="cell border-box-sizing code_cell rendered">

</div>
    {% endraw %}

</div>
 

