blob: 5101bf4ba14b65bd8270c3758444acca4700fd1e [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<title>Image API — mxnet documentation</title>
<link crossorigin="anonymous" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="../../_static/basic.css" rel="stylesheet" type="text/css"/>
<link href="../../_static/pygments.css" rel="stylesheet" type="text/css"/>
<link href="../../_static/mxnet.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../',
VERSION: '',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script src="../../_static/jquery-1.11.1.js" type="text/javascript"></script>
<script src="../../_static/underscore.js" type="text/javascript"></script>
<script src="../../_static/searchtools_custom.js" type="text/javascript"></script>
<script src="../../_static/doctools.js" type="text/javascript"></script>
<script src="../../_static/selectlang.js" type="text/javascript"></script>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
<script type="text/javascript"> jQuery(function() { Search.loadIndex("/searchindex.js"); Search.init();}); </script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new
Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-96378503-1', 'auto');
ga('send', 'pageview');
</script>
<!-- -->
<!-- <script type="text/javascript" src="../../_static/jquery.js"></script> -->
<!-- -->
<!-- <script type="text/javascript" src="../../_static/underscore.js"></script> -->
<!-- -->
<!-- <script type="text/javascript" src="../../_static/doctools.js"></script> -->
<!-- -->
<!-- <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> -->
<!-- -->
<link href="../../genindex.html" rel="index" title="Index"/>
<link href="../../search.html" rel="search" title="Search">
<link href="index.html" rel="up" title="MXNet - Python API">
<link href="optimization.html" rel="next" title="Optimization: initialize and update weights"/>
<link href="io.html" rel="prev" title="Data Loading API"/>
<link href="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-icon.png" rel="icon" type="image/png"/>
</link></link></link></head>
<body role="document"><!-- Previous Navbar Layout
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="../../" class="navbar-brand">
<img src="http://data.mxnet.io/theme/mxnet.png">
</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul id="navbar" class="navbar navbar-left">
<li> <a href="../../get_started/index.html">Get Started</a> </li>
<li> <a href="../../tutorials/index.html">Tutorials</a> </li>
<li> <a href="../../how_to/index.html">How To</a> </li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">Packages <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="../../packages/python/index.html">
Python
</a></li>
<li><a href="../../packages/r/index.html">
R
</a></li>
<li><a href="../../packages/julia/index.html">
Julia
</a></li>
<li><a href="../../packages/c++/index.html">
C++
</a></li>
<li><a href="../../packages/scala/index.html">
Scala
</a></li>
<li><a href="../../packages/perl/index.html">
Perl
</a></li>
</ul>
</li>
<li> <a href="../../system/index.html">System</a> </li>
<li>
<form class="" role="search" action="../../search.html" method="get" autocomplete="off">
<div class="form-group inner-addon left-addon">
<i class="glyphicon glyphicon-search"></i>
<input type="text" name="q" class="form-control" placeholder="Search">
</div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form> </li>
</ul>
<ul id="navbar" class="navbar navbar-right">
<li> <a href="../../index.html"><span class="flag-icon flag-icon-us"></span></a> </li>
<li> <a href="../..//zh/index.html"><span class="flag-icon flag-icon-cn"></span></a> </li>
</ul>
</div>
</div>
</div>
Previous Navbar Layout End -->
<div class="navbar navbar-fixed-top">
<div class="container" id="navContainer">
<div class="innder" id="header-inner">
<h1 id="logo-wrap">
<a href="../../" id="logo"><img src="http://data.mxnet.io/theme/mxnet.png"/></a>
</h1>
<nav class="nav-bar" id="main-nav">
<a class="main-nav-link" href="../../get_started/install.html">Install</a>
<a class="main-nav-link" href="../../tutorials/index.html">Tutorials</a>
<a class="main-nav-link" href="../../how_to/index.html">How To</a>
<span id="dropdown-menu-position-anchor">
<a aria-expanded="true" aria-haspopup="true" class="main-nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">API <span class="caret"></span></a>
<ul class="dropdown-menu" id="package-dropdown-menu">
<li><a class="main-nav-link" href="../../api/python/index.html">Python</a></li>
<li><a class="main-nav-link" href="../../api/scala/index.html">Scala</a></li>
<li><a class="main-nav-link" href="../../api/r/index.html">R</a></li>
<li><a class="main-nav-link" href="../../api/julia/index.html">Julia</a></li>
<li><a class="main-nav-link" href="../../api/c++/index.html">C++</a></li>
<li><a class="main-nav-link" href="../../api/perl/index.html">Perl</a></li>
</ul>
</span>
<a class="main-nav-link" href="../../architecture/index.html">Architecture</a>
<!-- <a class="main-nav-link" href="../../community/index.html">Community</a> -->
<a class="main-nav-link" href="https://github.com/dmlc/mxnet">Github</a>
<span id="dropdown-menu-position-anchor-version" style="position: relative"><a href="#" class="main-nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">Versions(master)<span class="caret"></span></a><ul id="package-dropdown-menu" class="dropdown-menu"><li><a class="main-nav-link" href=http://mxnet.incubator.apache.org/test/>v0.10.14</a></li><li><a class="main-nav-link" href=http://mxnet.incubator.apache.org/test/versions/0.10/index.html>0.10</a></li><li><a class="main-nav-link" href=http://mxnet.incubator.apache.org/test/versions/master/index.html>master</a></li></ul></span></nav>
<script> function getRootPath(){ return "../../" } </script>
<div class="burgerIcon dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button"></a>
<ul class="dropdown-menu dropdown-menu-right" id="burgerMenu">
<li><a href="../../get_started/install.html">Install</a></li>
<li><a href="../../tutorials/index.html">Tutorials</a></li>
<li><a href="../../how_to/index.html">How To</a></li>
<li class="dropdown-submenu">
<a href="#" tabindex="-1">API</a>
<ul class="dropdown-menu">
<li><a href="../../api/python/index.html" tabindex="-1">Python</a>
</li>
<li><a href="../../api/scala/index.html" tabindex="-1">Scala</a>
</li>
<li><a href="../../api/r/index.html" tabindex="-1">R</a>
</li>
<li><a href="../../api/julia/index.html" tabindex="-1">Julia</a>
</li>
<li><a href="../../api/c++/index.html" tabindex="-1">C++</a>
</li>
<li><a href="../../api/perl/index.html" tabindex="-1">Perl</a>
</li>
</ul>
</li>
<li><a href="../../architecture/index.html">Architecture</a></li>
<li><a class="main-nav-link" href="https://github.com/dmlc/mxnet">Github</a></li>
<li id="dropdown-menu-position-anchor-version-mobile" class="dropdown-submenu" style="position: relative"><a href="#" tabindex="-1">Versions(master)</a><ul class="dropdown-menu"><li><a tabindex="-1" href=http://mxnet.incubator.apache.org/test/>v0.10.14</a></li><li><a tabindex="-1" href=http://mxnet.incubator.apache.org/test/versions/0.10/index.html>0.10</a></li><li><a tabindex="-1" href=http://mxnet.incubator.apache.org/test/versions/master/index.html>master</a></li></ul></li></ul>
</div>
<div class="plusIcon dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button"><span aria-hidden="true" class="glyphicon glyphicon-plus"></span></a>
<ul class="dropdown-menu dropdown-menu-right" id="plusMenu"></ul>
</div>
<div id="search-input-wrap">
<form action="../../search.html" autocomplete="off" class="" method="get" role="search">
<div class="form-group inner-addon left-addon">
<i class="glyphicon glyphicon-search"></i>
<input class="form-control" name="q" placeholder="Search" type="text"/>
</div>
<input name="check_keywords" type="hidden" value="yes"/>
<input name="area" type="hidden" value="default"/>
</form>
<div id="search-preview"></div>
</div>
<div id="searchIcon">
<span aria-hidden="true" class="glyphicon glyphicon-search"></span>
</div>
<!-- <div id="lang-select-wrap"> -->
<!-- <label id="lang-select-label"> -->
<!-- <\!-- <i class="fa fa-globe"></i> -\-> -->
<!-- <span></span> -->
<!-- </label> -->
<!-- <select id="lang-select"> -->
<!-- <option value="en">Eng</option> -->
<!-- <option value="zh">中文</option> -->
<!-- </select> -->
<!-- </div> -->
<!-- <a id="mobile-nav-toggle">
<span class="mobile-nav-toggle-bar"></span>
<span class="mobile-nav-toggle-bar"></span>
<span class="mobile-nav-toggle-bar"></span>
</a> -->
</div>
</div>
</div>
<div class="container">
<div class="row">
<div aria-label="main navigation" class="sphinxsidebar leftsidebar" role="navigation">
<div class="sphinxsidebarwrapper">
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Python Documents</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="index.html#table-of-contents">Table of contents</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="ndarray.html">NDArray API</a></li>
<li class="toctree-l3"><a class="reference internal" href="symbol.html">Symbol API</a></li>
<li class="toctree-l3"><a class="reference internal" href="module.html">Module API</a></li>
<li class="toctree-l3"><a class="reference internal" href="gluon.html">Gluon Package</a></li>
<li class="toctree-l3"><a class="reference internal" href="rnn.html">RNN Cell API</a></li>
<li class="toctree-l3"><a class="reference internal" href="kvstore.html">KVStore API</a></li>
<li class="toctree-l3"><a class="reference internal" href="io.html">Data Loading API</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">Image API</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#overview">Overview</a></li>
<li class="toctree-l4"><a class="reference internal" href="#image-processing-functions">Image processing functions</a></li>
<li class="toctree-l4"><a class="reference internal" href="#image-iterators">Image iterators</a></li>
<li class="toctree-l4"><a class="reference internal" href="#api-reference">API Reference</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="optimization.html">Optimization: initialize and update weights</a></li>
<li class="toctree-l3"><a class="reference internal" href="callback.html">Callback API</a></li>
<li class="toctree-l3"><a class="reference internal" href="metric.html">Evaluation Metric API</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../r/index.html">R Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../julia/index.html">Julia Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../c++/index.html">C++ Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../scala/index.html">Scala Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../perl/index.html">Perl Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../how_to/index.html">HowTo Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/index.html">System Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../tutorials/index.html">Tutorials</a></li>
</ul>
</div>
</div>
<div class="content">
<div class="section" id="image-api">
<span id="image-api"></span><h1>Image API<a class="headerlink" href="#image-api" title="Permalink to this headline"></a></h1>
<div class="section" id="overview">
<span id="overview"></span><h2>Overview<a class="headerlink" href="#overview" title="Permalink to this headline"></a></h2>
<p>This document summarizes supporting functions and iterators to read and process
images provided in</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%"/>
<col width="90%"/>
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#module-mxnet.image" title="mxnet.image"><code class="xref py py-obj docutils literal"><span class="pre">mxnet.image</span></code></a></td>
<td>Image Iterators and image augmentation functions</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="image-processing-functions">
<span id="image-processing-functions"></span><h2>Image processing functions<a class="headerlink" href="#image-processing-functions" title="Permalink to this headline"></a></h2>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%"/>
<col width="90%"/>
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.imdecode" title="mxnet.image.imdecode"><code class="xref py py-obj docutils literal"><span class="pre">image.imdecode</span></code></a></td>
<td>Decode an image to an NDArray.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.scale_down" title="mxnet.image.scale_down"><code class="xref py py-obj docutils literal"><span class="pre">image.scale_down</span></code></a></td>
<td>Scales down crop size if it’s larger than image size.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.resize_short" title="mxnet.image.resize_short"><code class="xref py py-obj docutils literal"><span class="pre">image.resize_short</span></code></a></td>
<td>Resizes shorter edge to size.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.fixed_crop" title="mxnet.image.fixed_crop"><code class="xref py py-obj docutils literal"><span class="pre">image.fixed_crop</span></code></a></td>
<td>Crop src at fixed location, and (optionally) resize it to size.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.random_crop" title="mxnet.image.random_crop"><code class="xref py py-obj docutils literal"><span class="pre">image.random_crop</span></code></a></td>
<td>Randomly crop <cite>src</cite> with <cite>size</cite> (width, height).</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.center_crop" title="mxnet.image.center_crop"><code class="xref py py-obj docutils literal"><span class="pre">image.center_crop</span></code></a></td>
<td>Crops the image <cite>src</cite> to the given <cite>size</cite> by trimming on all four sides and preserving the center of the image.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.color_normalize" title="mxnet.image.color_normalize"><code class="xref py py-obj docutils literal"><span class="pre">image.color_normalize</span></code></a></td>
<td>Normalize src with mean and std.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.random_size_crop" title="mxnet.image.random_size_crop"><code class="xref py py-obj docutils literal"><span class="pre">image.random_size_crop</span></code></a></td>
<td>Randomly crop src with size.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="image-iterators">
<span id="image-iterators"></span><h2>Image iterators<a class="headerlink" href="#image-iterators" title="Permalink to this headline"></a></h2>
<p>Iterators support loading image from binary <code class="docutils literal"><span class="pre">Record</span> <span class="pre">IO</span></code> and raw image files.</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%"/>
<col width="90%"/>
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.ImageIter" title="mxnet.image.ImageIter"><code class="xref py py-obj docutils literal"><span class="pre">image.ImageIter</span></code></a></td>
<td>Image data iterator with a large number of augmentation choices.</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data_iter</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">image</span><span class="o">.</span><span class="n">ImageIter</span><span class="p">(</span><span class="n">batch_size</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">data_shape</span><span class="o">=</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">224</span><span class="p">,</span> <span class="mi">224</span><span class="p">),</span> <span class="n">label_width</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
<span class="go"> path_imglist='data/custom.lst')</span>
<span class="gp">>>> </span><span class="n">data_iter</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">data_iter</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">d</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="gp">... </span> <span class="k">print</span><span class="p">(</span><span class="n">d</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
<span class="gp">>>> </span><span class="c1"># we can apply lots of augmentations as well</span>
<span class="gp">>>> </span><span class="n">data_iter</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">image</span><span class="o">.</span><span class="n">ImageIter</span><span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">224</span><span class="p">,</span> <span class="mi">224</span><span class="p">),</span> <span class="n">path_imglist</span><span class="o">=</span><span class="s1">'data/custom.lst'</span><span class="p">,</span>
<span class="go"> rand_crop=resize=True, rand_mirror=True, mean=True,</span>
<span class="go"> brightness=0.1, contrast=0.1, saturation=0.1, hue=0.1,</span>
<span class="go"> pca_noise=0.1, rand_gray=0.05)</span>
<span class="gp">>>> </span><span class="n">data</span> <span class="o">=</span> <span class="n">data_iter</span><span class="o">.</span><span class="n">next</span><span class="p">()</span>
<span class="gp">>>> </span><span class="c1"># specify augmenters manually is also supported</span>
<span class="gp">>>> </span><span class="n">data_iter</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">image</span><span class="o">.</span><span class="n">ImageIter</span><span class="p">(</span><span class="mi">32</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">224</span><span class="p">,</span> <span class="mi">224</span><span class="p">),</span> <span class="n">path_rec</span><span class="o">=</span><span class="s1">'data/caltech.rec'</span><span class="p">,</span>
<span class="go"> path_imgidx='data/caltech.idx', shuffle=True,</span>
<span class="go"> aug_list=[mx.image.HorizontalFlipAug(0.5),</span>
<span class="go"> mx.image.ColorJitterAug(0.1, 0.1, 0.1)])</span>
</pre></div>
</div>
<p>We use helper function to initialize augmenters</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%"/>
<col width="90%"/>
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.CreateAugmenter" title="mxnet.image.CreateAugmenter"><code class="xref py py-obj docutils literal"><span class="pre">image.CreateAugmenter</span></code></a></td>
<td>Creates an augmenter list.</td>
</tr>
</tbody>
</table>
<p>A list of supporting augmenters</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%"/>
<col width="90%"/>
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.Augmenter" title="mxnet.image.Augmenter"><code class="xref py py-obj docutils literal"><span class="pre">image.Augmenter</span></code></a></td>
<td>Image Augmenter base class</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.ResizeAug" title="mxnet.image.ResizeAug"><code class="xref py py-obj docutils literal"><span class="pre">image.ResizeAug</span></code></a></td>
<td>Make resize shorter edge to size augmenter.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.ForceResizeAug" title="mxnet.image.ForceResizeAug"><code class="xref py py-obj docutils literal"><span class="pre">image.ForceResizeAug</span></code></a></td>
<td>Force resize to size regardless of aspect ratio</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.RandomCropAug" title="mxnet.image.RandomCropAug"><code class="xref py py-obj docutils literal"><span class="pre">image.RandomCropAug</span></code></a></td>
<td>Make random crop augmenter</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.RandomSizedCropAug" title="mxnet.image.RandomSizedCropAug"><code class="xref py py-obj docutils literal"><span class="pre">image.RandomSizedCropAug</span></code></a></td>
<td>Make random crop with random resizing and random aspect ratio jitter augmenter.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.CenterCropAug" title="mxnet.image.CenterCropAug"><code class="xref py py-obj docutils literal"><span class="pre">image.CenterCropAug</span></code></a></td>
<td>Make center crop augmenter.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.RandomOrderAug" title="mxnet.image.RandomOrderAug"><code class="xref py py-obj docutils literal"><span class="pre">image.RandomOrderAug</span></code></a></td>
<td>Apply list of augmenters in random order</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.BrightnessJitterAug" title="mxnet.image.BrightnessJitterAug"><code class="xref py py-obj docutils literal"><span class="pre">image.BrightnessJitterAug</span></code></a></td>
<td>Random brightness jitter augmentation.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.ContrastJitterAug" title="mxnet.image.ContrastJitterAug"><code class="xref py py-obj docutils literal"><span class="pre">image.ContrastJitterAug</span></code></a></td>
<td>Random contrast jitter augmentation.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.SaturationJitterAug" title="mxnet.image.SaturationJitterAug"><code class="xref py py-obj docutils literal"><span class="pre">image.SaturationJitterAug</span></code></a></td>
<td>Random saturation jitter augmentation.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.HueJitterAug" title="mxnet.image.HueJitterAug"><code class="xref py py-obj docutils literal"><span class="pre">image.HueJitterAug</span></code></a></td>
<td>Random hue jitter augmentation.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.ColorJitterAug" title="mxnet.image.ColorJitterAug"><code class="xref py py-obj docutils literal"><span class="pre">image.ColorJitterAug</span></code></a></td>
<td>Apply random brightness, contrast and saturation jitter in random order.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.LightingAug" title="mxnet.image.LightingAug"><code class="xref py py-obj docutils literal"><span class="pre">image.LightingAug</span></code></a></td>
<td>Add PCA based noise.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.ColorNormalizeAug" title="mxnet.image.ColorNormalizeAug"><code class="xref py py-obj docutils literal"><span class="pre">image.ColorNormalizeAug</span></code></a></td>
<td>Mean and std normalization.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.RandomGrayAug" title="mxnet.image.RandomGrayAug"><code class="xref py py-obj docutils literal"><span class="pre">image.RandomGrayAug</span></code></a></td>
<td>Randomly convert to gray image.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.HorizontalFlipAug" title="mxnet.image.HorizontalFlipAug"><code class="xref py py-obj docutils literal"><span class="pre">image.HorizontalFlipAug</span></code></a></td>
<td>Random horizontal flip.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.CastAug" title="mxnet.image.CastAug"><code class="xref py py-obj docutils literal"><span class="pre">image.CastAug</span></code></a></td>
<td>Cast to float32</td>
</tr>
</tbody>
</table>
<p>Similar to <code class="docutils literal"><span class="pre">ImageIter</span></code>, <code class="docutils literal"><span class="pre">ImageDetIter</span></code> is designed for <code class="docutils literal"><span class="pre">Object</span> <span class="pre">Detection</span></code> tasks.</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%"/>
<col width="90%"/>
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.ImageDetIter" title="mxnet.image.ImageDetIter"><code class="xref py py-obj docutils literal"><span class="pre">image.ImageDetIter</span></code></a></td>
<td>Image iterator with a large number of augmentation choices for detection.</td>
</tr>
</tbody>
</table>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">data_iter</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">image</span><span class="o">.</span><span class="n">ImageDetIter</span><span class="p">(</span><span class="n">batch_size</span><span class="o">=</span><span class="mi">4</span><span class="p">,</span> <span class="n">data_shape</span><span class="o">=</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">224</span><span class="p">,</span> <span class="mi">224</span><span class="p">),</span>
<span class="go"> path_imglist='data/train.lst')</span>
<span class="gp">>>> </span><span class="n">data_iter</span><span class="o">.</span><span class="n">reset</span><span class="p">()</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">data_iter</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">d</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="gp">... </span> <span class="n">l</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">label</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="gp">... </span> <span class="k">print</span><span class="p">(</span><span class="n">d</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
<span class="gp">... </span> <span class="k">print</span><span class="p">(</span><span class="n">l</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span>
</pre></div>
</div>
<p>Unlike object classification with fixed label_width, object count may vary from
image to image. Thus we have special format for object detection labels.
Usually the <code class="docutils literal"><span class="pre">lst</span></code> file generated by <code class="docutils literal"><span class="pre">tools/im2rec.py</span></code> is a list of</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">index_0</span> <span class="n">label_0</span> <span class="n">image_path_0</span>
<span class="n">index_1</span> <span class="n">label_1</span> <span class="n">image_path_1</span>
</pre></div>
</div>
<p>Where <code class="docutils literal"><span class="pre">label_N</span></code> is a number a of fixed-width vector.
The format of label used in object detection is a variable length vector</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">A</span> <span class="n">B</span> <span class="p">[</span><span class="n">header</span><span class="p">]</span> <span class="p">[(</span><span class="n">object0</span><span class="p">),</span> <span class="p">(</span><span class="n">object1</span><span class="p">),</span> <span class="o">...</span> <span class="p">(</span><span class="n">objectN</span><span class="p">)]</span>
</pre></div>
</div>
<p>Where A is the width of header, B is the width of each object.
Header is optional and used for inserting helper information such as (width, height).
Each object is usually 5 or 6 numbers describing the object properties, for example:
[id, xmin, ymin, xmax, ymax, difficulty]
Putting all together, we have a <code class="docutils literal"><span class="pre">lst</span></code> file for object detection:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="mi">0</span> <span class="mi">2</span> <span class="mi">5</span> <span class="mi">640</span> <span class="mi">480</span> <span class="mi">1</span> <span class="mf">0.1</span> <span class="mf">0.2</span> <span class="mf">0.8</span> <span class="mf">0.9</span> <span class="mi">2</span> <span class="mf">0.5</span> <span class="mf">0.3</span> <span class="mf">0.6</span> <span class="mf">0.8</span> <span class="n">data</span><span class="o">/</span><span class="n">xxx</span><span class="o">.</span><span class="n">jpg</span>
<span class="mi">1</span> <span class="mi">2</span> <span class="mi">5</span> <span class="mi">480</span> <span class="mi">640</span> <span class="mi">3</span> <span class="mf">0.05</span> <span class="mf">0.16</span> <span class="mf">0.75</span> <span class="mf">0.9</span> <span class="n">data</span><span class="o">/</span><span class="n">xxx</span><span class="o">.</span><span class="n">jpg</span>
<span class="mi">2</span> <span class="mi">2</span> <span class="mi">5</span> <span class="mi">500</span> <span class="mi">600</span> <span class="mi">2</span> <span class="mf">0.6</span> <span class="mf">0.1</span> <span class="mf">0.7</span> <span class="mf">0.5</span> <span class="mi">0</span> <span class="mf">0.1</span> <span class="mf">0.3</span> <span class="mf">0.2</span> <span class="mf">0.4</span> <span class="mi">3</span> <span class="mf">0.25</span> <span class="mf">0.25</span> <span class="mf">0.3</span> <span class="mf">0.3</span> <span class="n">data</span><span class="o">/</span><span class="n">xxx</span><span class="o">.</span><span class="n">jpg</span>
<span class="o">...</span>
</pre></div>
</div>
<p>A helper function to initialize Augmenters for <code class="docutils literal"><span class="pre">Object</span> <span class="pre">detection</span></code> task</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%"/>
<col width="90%"/>
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.CreateDetAugmenter" title="mxnet.image.CreateDetAugmenter"><code class="xref py py-obj docutils literal"><span class="pre">image.CreateDetAugmenter</span></code></a></td>
<td>Create augmenters for detection.</td>
</tr>
</tbody>
</table>
<p>Since <code class="docutils literal"><span class="pre">Detection</span></code> task is sensitive to object localization, any modification
to image that introduced localization shift will require correction to label,
and a list of augmenters specific for <code class="docutils literal"><span class="pre">Object</span> <span class="pre">detection</span></code> is provided</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%"/>
<col width="90%"/>
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.DetBorrowAug" title="mxnet.image.DetBorrowAug"><code class="xref py py-obj docutils literal"><span class="pre">image.DetBorrowAug</span></code></a></td>
<td>Borrow standard augmenter from image classification.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.DetRandomSelectAug" title="mxnet.image.DetRandomSelectAug"><code class="xref py py-obj docutils literal"><span class="pre">image.DetRandomSelectAug</span></code></a></td>
<td>Randomly select one augmenter to apply, with chance to skip all.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.DetHorizontalFlipAug" title="mxnet.image.DetHorizontalFlipAug"><code class="xref py py-obj docutils literal"><span class="pre">image.DetHorizontalFlipAug</span></code></a></td>
<td>Random horizontal flipping.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.image.DetRandomCropAug" title="mxnet.image.DetRandomCropAug"><code class="xref py py-obj docutils literal"><span class="pre">image.DetRandomCropAug</span></code></a></td>
<td>Random cropping with constraints</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.image.DetRandomPadAug" title="mxnet.image.DetRandomPadAug"><code class="xref py py-obj docutils literal"><span class="pre">image.DetRandomPadAug</span></code></a></td>
<td>Random padding augmenter.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="api-reference">
<span id="api-reference"></span><h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to this headline"></a></h2>
<script src="../../_static/js/auto_module_index.js" type="text/javascript"></script><span class="target" id="module-mxnet.image"></span><p>Image Iterators and image augmentation functions</p>
<dl class="class">
<dt id="mxnet.image.ImageIter">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">ImageIter</code><span class="sig-paren">(</span><em>batch_size</em>, <em>data_shape</em>, <em>label_width=1</em>, <em>path_imgrec=None</em>, <em>path_imglist=None</em>, <em>path_root=None</em>, <em>path_imgidx=None</em>, <em>shuffle=False</em>, <em>part_index=0</em>, <em>num_parts=1</em>, <em>aug_list=None</em>, <em>imglist=None</em>, <em>data_name='data'</em>, <em>label_name='softmax_label'</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageIter" title="Permalink to this definition"></a></dt>
<dd><p>Image data iterator with a large number of augmentation choices.
This iterator supports reading from both .rec files and raw image files.</p>
<p>To load input images from .rec files, use <cite>path_imgrec</cite> parameter and to load from raw image
files, use <cite>path_imglist</cite> and <cite>path_root</cite> parameters.</p>
<p>To use data partition (for distributed training) or shuffling, specify <cite>path_imgidx</cite> parameter.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>batch_size</strong> (<em>int</em>) – Number of examples per batch.</li>
<li><strong>data_shape</strong> (<em>tuple</em>) – Data shape in (channels, height, width) format.
For now, only RGB image with 3 channels is supported.</li>
<li><strong>label_width</strong> (<em>int</em><em>, </em><em>optional</em>) – Number of labels per example. The default label width is 1.</li>
<li><strong>path_imgrec</strong> (<em>str</em>) – Path to image record file (.rec).
Created with tools/im2rec.py or bin/im2rec.</li>
<li><strong>path_imglist</strong> (<em>str</em>) – Path to image list (.lst).
Created with tools/im2rec.py or with custom script.
Format: Tab separated record of index, one or more labels and relative_path_from_root.</li>
<li><strong>imglist</strong> (<em>list</em>) – A list of images with the label(s).
Each item is a list [imagelabel: float or list of float, imgpath].</li>
<li><strong>path_root</strong> (<em>str</em>) – Root folder of image files.</li>
<li><strong>path_imgidx</strong> (<em>str</em>) – Path to image index file. Needed for partition and shuffling when using .rec source.</li>
<li><strong>shuffle</strong> (<em>bool</em>) – Whether to shuffle all images at the start of each iteration or not.
Can be slow for HDD.</li>
<li><strong>part_index</strong> (<em>int</em>) – Partition index.</li>
<li><strong>num_parts</strong> (<em>int</em>) – Total number of partitions.</li>
<li><strong>data_name</strong> (<em>str</em>) – Data name for provided symbols.</li>
<li><strong>label_name</strong> (<em>str</em>) – Label name for provided symbols.</li>
<li><strong>kwargs</strong> – More arguments for creating augmenter. See mx.image.CreateAugmenter.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="mxnet.image.ImageIter.reset">
<code class="descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageIter.reset" title="Permalink to this definition"></a></dt>
<dd><p>Resets the iterator to the beginning of the data.</p>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.ImageIter.next_sample">
<code class="descname">next_sample</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageIter.next_sample" title="Permalink to this definition"></a></dt>
<dd><p>Helper function for reading in next sample.</p>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.ImageIter.next">
<code class="descname">next</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageIter.next" title="Permalink to this definition"></a></dt>
<dd><p>Returns the next batch of data.</p>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.ImageIter.check_data_shape">
<code class="descname">check_data_shape</code><span class="sig-paren">(</span><em>data_shape</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageIter.check_data_shape" title="Permalink to this definition"></a></dt>
<dd><p>Checks if the input data shape is valid</p>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.ImageIter.check_valid_image">
<code class="descname">check_valid_image</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageIter.check_valid_image" title="Permalink to this definition"></a></dt>
<dd><p>Checks if the input data is valid</p>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.ImageIter.imdecode">
<code class="descname">imdecode</code><span class="sig-paren">(</span><em>s</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageIter.imdecode" title="Permalink to this definition"></a></dt>
<dd><p>Decodes a string or byte string to an NDArray.
See mx.img.imdecode for more details.</p>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.ImageIter.read_image">
<code class="descname">read_image</code><span class="sig-paren">(</span><em>fname</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageIter.read_image" title="Permalink to this definition"></a></dt>
<dd><p>Reads an input image <cite>fname</cite> and returns the decoded raw bytes.</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">dataIter</span><span class="o">.</span><span class="n">read_image</span><span class="p">(</span><span class="s1">'Face.jpg'</span><span class="p">)</span> <span class="c1"># returns decoded raw bytes.</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.ImageIter.augmentation_transform">
<code class="descname">augmentation_transform</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageIter.augmentation_transform" title="Permalink to this definition"></a></dt>
<dd><p>Transforms input data with specified augmentation.</p>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.ImageIter.postprocess_data">
<code class="descname">postprocess_data</code><span class="sig-paren">(</span><em>datum</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageIter.postprocess_data" title="Permalink to this definition"></a></dt>
<dd><p>Final postprocessing step before image is loaded into the batch.</p>
</dd></dl>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.imdecode">
<code class="descclassname">image.</code><code class="descname">imdecode</code><span class="sig-paren">(</span><em>buf</em>, <em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.imdecode" title="Permalink to this definition"></a></dt>
<dd><p>Decode an image to an NDArray.</p>
<p>Note: <cite>imdecode</cite> uses OpenCV (not the CV2 Python library).
MXNet must have been built with OpenCV for <cite>imdecode</cite> to work.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>buf</strong> (<em>str/bytes</em><em> or </em><em>numpy.ndarray</em>) – Binary image data as string or numpy ndarray.</li>
<li><strong>flag</strong> (<em>int</em><em>, </em><em>optional</em><em>, </em><em>default=1</em>) – 1 for three channel color output. 0 for grayscale output.</li>
<li><strong>to_rgb</strong> (<em>int</em><em>, </em><em>optional</em><em>, </em><em>default=1</em>) – 1 for RGB formatted output (MXNet default). 0 for BGR formatted output (OpenCV default).</li>
<li><strong>out</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a><em>, </em><em>optional</em>) – Output buffer. Use <cite>None</cite> for automatic allocation.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An <cite>NDArray</cite> containing the image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray">NDArray</a></p>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Example</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"flower.jpg"</span><span class="p">,</span> <span class="s1">'rb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">fp</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">str_image</span> <span class="o">=</span> <span class="n">fp</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="n">image</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">img</span><span class="o">.</span><span class="n">imdecode</span><span class="p">(</span><span class="n">str_image</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">image</span>
<span class="go"><ndarray 224x224x3="" @cpu(0)=""></ndarray></span>
</pre></div>
</div>
<p>Set <cite>flag</cite> parameter to 0 to get grayscale output</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"flower.jpg"</span><span class="p">,</span> <span class="s1">'rb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">fp</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">str_image</span> <span class="o">=</span> <span class="n">fp</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="n">image</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">img</span><span class="o">.</span><span class="n">imdecode</span><span class="p">(</span><span class="n">str_image</span><span class="p">,</span> <span class="n">flag</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">image</span>
<span class="go"><ndarray 224x224x1="" @cpu(0)=""></ndarray></span>
</pre></div>
</div>
<p>Set <cite>to_rgb</cite> parameter to 0 to get output in OpenCV format (BGR)</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"flower.jpg"</span><span class="p">,</span> <span class="s1">'rb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">fp</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">str_image</span> <span class="o">=</span> <span class="n">fp</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="n">image</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">img</span><span class="o">.</span><span class="n">imdecode</span><span class="p">(</span><span class="n">str_image</span><span class="p">,</span> <span class="n">to_rgb</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">image</span>
<span class="go"><ndarray 224x224x3="" @cpu(0)=""></ndarray></span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.scale_down">
<code class="descclassname">image.</code><code class="descname">scale_down</code><span class="sig-paren">(</span><em>src_size</em>, <em>size</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.scale_down" title="Permalink to this definition"></a></dt>
<dd><p>Scales down crop size if it’s larger than image size.</p>
<p>If width/height of the crop is larger than the width/height of the image,
sets the width/height to the width/height of the image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>src_size</strong> (<em>tuple of int</em>) – Size of the image in (width, height) format.</li>
<li><strong>size</strong> (<em>tuple of int</em>) – Size of the crop in (width, height) format.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">A tuple containing the scaled crop size in (width, height) format.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">tuple of int</p>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Example</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">src_size</span> <span class="o">=</span> <span class="p">(</span><span class="mi">640</span><span class="p">,</span><span class="mi">480</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">size</span> <span class="o">=</span> <span class="p">(</span><span class="mi">720</span><span class="p">,</span><span class="mi">120</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">new_size</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">img</span><span class="o">.</span><span class="n">scale_down</span><span class="p">(</span><span class="n">src_size</span><span class="p">,</span> <span class="n">size</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">new_size</span>
<span class="go">(640,106)</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.resize_short">
<code class="descclassname">image.</code><code class="descname">resize_short</code><span class="sig-paren">(</span><em>src</em>, <em>size</em>, <em>interp=2</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.resize_short" title="Permalink to this definition"></a></dt>
<dd><p>Resizes shorter edge to size.</p>
<p>Note: <cite>resize_short</cite> uses OpenCV (not the CV2 Python library).
MXNet must have been built with OpenCV for <cite>resize_short</cite> to work.</p>
<p>Resizes the original image by setting the shorter edge to size
and setting the longer edge accordingly.
Resizing function is called from OpenCV.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>src</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – The original image.</li>
<li><strong>size</strong> (<em>int</em>) – The length to be set for the shorter edge.</li>
<li><strong>interp</strong> (<em>int</em><em>, </em><em>optional</em><em>, </em><em>default=2</em>) – Interpolation method used for resizing the image.
Possible values:
0: Nearest Neighbors Interpolation.
1: Bilinear interpolation.
2: Area-based (resampling using pixel area relation). It may be a
preferred method for image decimation, as it gives moire-free
results. But when the image is zoomed, it is similar to the Nearest
Neighbors method. (used by default).
3: Bicubic interpolation over 4x4 pixel neighborhood.
4: Lanczos interpolation over 8x8 pixel neighborhood.
9: Cubic for enlarge, area for shrink, bilinear for others
10: Random select from interpolation method metioned above.
Note:
When shrinking an image, it will generally look best with AREA-based
interpolation, whereas, when enlarging an image, it will generally look best
with Bicubic (slow) or Bilinear (faster but still looks OK).
More details can be found in the documentation of OpenCV, please refer to
<a class="reference external" href="http://docs.opencv.org/master/da/d54/group__imgproc__transform.html">http://docs.opencv.org/master/da/d54/group__imgproc__transform.html</a>.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An ‘NDArray’ containing the resized image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray">NDArray</a></p>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Example</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"flower.jpeg"</span><span class="p">,</span> <span class="s1">'rb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">fp</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">str_image</span> <span class="o">=</span> <span class="n">fp</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="n">image</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">img</span><span class="o">.</span><span class="n">imdecode</span><span class="p">(</span><span class="n">str_image</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">image</span>
<span class="go"><ndarray 2321x3482x3="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">size</span> <span class="o">=</span> <span class="mi">640</span>
<span class="gp">>>> </span><span class="n">new_image</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">img</span><span class="o">.</span><span class="n">resize_short</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="n">size</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">new_image</span>
<span class="go"><ndarray 2321x3482x3="" @cpu(0)=""></ndarray></span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.fixed_crop">
<code class="descclassname">image.</code><code class="descname">fixed_crop</code><span class="sig-paren">(</span><em>src</em>, <em>x0</em>, <em>y0</em>, <em>w</em>, <em>h</em>, <em>size=None</em>, <em>interp=2</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.fixed_crop" title="Permalink to this definition"></a></dt>
<dd><p>Crop src at fixed location, and (optionally) resize it to size.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>src</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – Input image</li>
<li><strong>x0</strong> (<em>int</em>) – Left boundary of the cropping area</li>
<li><strong>y0</strong> (<em>int</em>) – Top boundary of the cropping area</li>
<li><strong>w</strong> (<em>int</em>) – Width of the cropping area</li>
<li><strong>h</strong> (<em>int</em>) – Height of the cropping area</li>
<li><strong>size</strong> (<em>tuple of</em><em> (</em><em>w</em><em>, </em><em>h</em><em>)</em><em></em>) – Optional, resize to new size after cropping</li>
<li><strong>interp</strong> (<em>int</em><em>, </em><em>optional</em><em>, </em><em>default=2</em>) – Interpolation method. See resize_short for details.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An <cite>NDArray</cite> containing the cropped image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray">NDArray</a></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.random_crop">
<code class="descclassname">image.</code><code class="descname">random_crop</code><span class="sig-paren">(</span><em>src</em>, <em>size</em>, <em>interp=2</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.random_crop" title="Permalink to this definition"></a></dt>
<dd><p>Randomly crop <cite>src</cite> with <cite>size</cite> (width, height).
Upsample result if <cite>src</cite> is smaller than <cite>size</cite>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>src</strong> (Source image <cite>NDArray</cite>) – </li>
<li><strong>size</strong> (Size of the crop formatted as (width, height). If the <cite>size</cite> is larger) – than the image, then the source image is upsampled to <cite>size</cite> and returned.</li>
<li><strong>interp</strong> (<em>int</em><em>, </em><em>optional</em><em>, </em><em>default=2</em>) – Interpolation method. See resize_short for details.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><ul class="simple">
<li><em>NDArray</em> – An <cite>NDArray</cite> containing the cropped image.</li>
<li><em>Tuple</em> – A tuple (x, y, width, height) where (x, y) is top-left position of the crop in the
original image and (width, height) are the dimensions of the cropped image.</li>
</ul>
</p>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Example</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">im</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">cv2</span><span class="o">.</span><span class="n">imread</span><span class="p">(</span><span class="s2">"flower.jpg"</span><span class="p">))</span>
<span class="gp">>>> </span><span class="n">cropped_im</span><span class="p">,</span> <span class="n">rect</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">image</span><span class="o">.</span><span class="n">random_crop</span><span class="p">(</span><span class="n">im</span><span class="p">,</span> <span class="p">(</span><span class="mi">100</span><span class="p">,</span> <span class="mi">100</span><span class="p">))</span>
<span class="gp">>>> </span><span class="nb">print</span> <span class="n">cropped_im</span>
<span class="go"><ndarray 100x100x1="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="nb">print</span> <span class="n">rect</span>
<span class="go">(20, 21, 100, 100)</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.center_crop">
<code class="descclassname">image.</code><code class="descname">center_crop</code><span class="sig-paren">(</span><em>src</em>, <em>size</em>, <em>interp=2</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.center_crop" title="Permalink to this definition"></a></dt>
<dd><p>Crops the image <cite>src</cite> to the given <cite>size</cite> by trimming on all four
sides and preserving the center of the image. Upsamples if <cite>src</cite> is smaller
than <cite>size</cite>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This requires MXNet to be compiled with USE_OPENCV.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>src</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – Binary source image data.</li>
<li><strong>size</strong> (<em>list</em><em> or </em><em>tuple of int</em>) – The desired output image size.</li>
<li><strong>interp</strong> (<em>int</em><em>, </em><em>optional</em><em>, </em><em>default=2</em>) – Interpolation method. See resize_short for details.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><ul class="simple">
<li><em>NDArray</em> – The cropped image.</li>
<li><em>Tuple</em> – (x, y, width, height) where x, y are the positions of the crop in the
original image and width, height the dimensions of the crop.</li>
</ul>
</p>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Example</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s2">"flower.jpg"</span><span class="p">,</span> <span class="s1">'rb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">fp</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">str_image</span> <span class="o">=</span> <span class="n">fp</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="gp">...</span>
<span class="gp">>>> </span><span class="n">image</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">image</span><span class="o">.</span><span class="n">imdecode</span><span class="p">(</span><span class="n">str_image</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">image</span>
<span class="go"><ndarray 2321x3482x3="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">cropped_image</span><span class="p">,</span> <span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">width</span><span class="p">,</span> <span class="n">height</span><span class="p">)</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">image</span><span class="o">.</span><span class="n">center_crop</span><span class="p">(</span><span class="n">image</span><span class="p">,</span> <span class="p">(</span><span class="mi">1000</span><span class="p">,</span> <span class="mi">500</span><span class="p">))</span>
<span class="gp">>>> </span><span class="n">cropped_image</span>
<span class="go"><ndarray 500x1000x3="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">width</span><span class="p">,</span> <span class="n">height</span>
<span class="go">(1241, 910, 1000, 500)</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.color_normalize">
<code class="descclassname">image.</code><code class="descname">color_normalize</code><span class="sig-paren">(</span><em>src</em>, <em>mean</em>, <em>std=None</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.color_normalize" title="Permalink to this definition"></a></dt>
<dd><p>Normalize src with mean and std.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>src</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – Input image</li>
<li><strong>mean</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – RGB mean to be subtracted</li>
<li><strong>std</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – RGB standard deviation to be divided</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">An <cite>NDArray</cite> containing the normalized image.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray">NDArray</a></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.random_size_crop">
<code class="descclassname">image.</code><code class="descname">random_size_crop</code><span class="sig-paren">(</span><em>src</em>, <em>size</em>, <em>min_area</em>, <em>ratio</em>, <em>interp=2</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.random_size_crop" title="Permalink to this definition"></a></dt>
<dd><p>Randomly crop src with size. Randomize area and aspect ratio.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>src</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – Input image</li>
<li><strong>size</strong> (<em>tuple of</em><em> (</em><em>int</em><em>, </em><em>int</em><em>)</em><em></em>) – Size of the crop formatted as (width, height).</li>
<li><strong>min_area</strong> (<em>int</em>) – Minimum area to be maintained after cropping</li>
<li><strong>ratio</strong> (<em>tuple of</em><em> (</em><em>float</em><em>, </em><em>float</em><em>)</em><em></em>) – Aspect ratio range as (min_aspect_ratio, max_aspect_ratio)</li>
<li><strong>interp</strong> (<em>int</em><em>, </em><em>optional</em><em>, </em><em>default=2</em>) – Interpolation method. See resize_short for details.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last"><ul class="simple">
<li><em>NDArray</em> – An <cite>NDArray</cite> containing the cropped image.</li>
<li><em>Tuple</em> – A tuple (x, y, width, height) where (x, y) is top-left position of the crop in the
original image and (width, height) are the dimensions of the cropped image.</li>
</ul>
</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.Augmenter">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">Augmenter</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.Augmenter" title="Permalink to this definition"></a></dt>
<dd><p>Image Augmenter base class</p>
<dl class="method">
<dt id="mxnet.image.Augmenter.dumps">
<code class="descname">dumps</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.Augmenter.dumps" title="Permalink to this definition"></a></dt>
<dd><p>Saves the Augmenter to string</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">JSON formatted string that describes the Augmenter.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.ResizeAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">ResizeAug</code><span class="sig-paren">(</span><em>size</em>, <em>interp=2</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ResizeAug" title="Permalink to this definition"></a></dt>
<dd><p>Make resize shorter edge to size augmenter.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> (<em>int</em>) – The length to be set for the shorter edge.</li>
<li><strong>interp</strong> (<em>int</em><em>, </em><em>optional</em><em>, </em><em>default=2</em>) – Interpolation method. See resize_short for details.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.ForceResizeAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">ForceResizeAug</code><span class="sig-paren">(</span><em>size</em>, <em>interp=2</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ForceResizeAug" title="Permalink to this definition"></a></dt>
<dd><p>Force resize to size regardless of aspect ratio</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> (<em>tuple of</em><em> (</em><em>int</em><em>, </em><em>int</em><em>)</em><em></em>) – The desired size as in (width, height)</li>
<li><strong>interp</strong> (<em>int</em><em>, </em><em>optional</em><em>, </em><em>default=2</em>) – Interpolation method. See resize_short for details.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.RandomCropAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">RandomCropAug</code><span class="sig-paren">(</span><em>size</em>, <em>interp=2</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.RandomCropAug" title="Permalink to this definition"></a></dt>
<dd><p>Make random crop augmenter</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> (<em>int</em>) – The length to be set for the shorter edge.</li>
<li><strong>interp</strong> (<em>int</em><em>, </em><em>optional</em><em>, </em><em>default=2</em>) – Interpolation method. See resize_short for details.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.RandomSizedCropAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">RandomSizedCropAug</code><span class="sig-paren">(</span><em>size</em>, <em>min_area</em>, <em>ratio</em>, <em>interp=2</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.RandomSizedCropAug" title="Permalink to this definition"></a></dt>
<dd><p>Make random crop with random resizing and random aspect ratio jitter augmenter.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> (<em>tuple of</em><em> (</em><em>int</em><em>, </em><em>int</em><em>)</em><em></em>) – Size of the crop formatted as (width, height).</li>
<li><strong>min_area</strong> (<em>int</em>) – Minimum area to be maintained after cropping</li>
<li><strong>ratio</strong> (<em>tuple of</em><em> (</em><em>float</em><em>, </em><em>float</em><em>)</em><em></em>) – Aspect ratio range as (min_aspect_ratio, max_aspect_ratio)</li>
<li><strong>interp</strong> (<em>int</em><em>, </em><em>optional</em><em>, </em><em>default=2</em>) – Interpolation method. See resize_short for details.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.CenterCropAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">CenterCropAug</code><span class="sig-paren">(</span><em>size</em>, <em>interp=2</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.CenterCropAug" title="Permalink to this definition"></a></dt>
<dd><p>Make center crop augmenter.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>size</strong> (<em>list</em><em> or </em><em>tuple of int</em>) – The desired output image size.</li>
<li><strong>interp</strong> (<em>int</em><em>, </em><em>optional</em><em>, </em><em>default=2</em>) – Interpolation method. See resize_short for details.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.RandomOrderAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">RandomOrderAug</code><span class="sig-paren">(</span><em>ts</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.RandomOrderAug" title="Permalink to this definition"></a></dt>
<dd><p>Apply list of augmenters in random order</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>ts</strong> (<em>list of augmenters</em>) – A series of augmenters to be applied in random order</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.BrightnessJitterAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">BrightnessJitterAug</code><span class="sig-paren">(</span><em>brightness</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.BrightnessJitterAug" title="Permalink to this definition"></a></dt>
<dd><p>Random brightness jitter augmentation.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>brightness</strong> (<em>float</em>) – The brightness jitter ratio range, [0, 1]</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.ContrastJitterAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">ContrastJitterAug</code><span class="sig-paren">(</span><em>contrast</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ContrastJitterAug" title="Permalink to this definition"></a></dt>
<dd><p>Random contrast jitter augmentation.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>contrast</strong> (<em>float</em>) – The contrast jitter ratio range, [0, 1]</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.SaturationJitterAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">SaturationJitterAug</code><span class="sig-paren">(</span><em>saturation</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.SaturationJitterAug" title="Permalink to this definition"></a></dt>
<dd><p>Random saturation jitter augmentation.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>saturation</strong> (<em>float</em>) – The saturation jitter ratio range, [0, 1]</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.HueJitterAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">HueJitterAug</code><span class="sig-paren">(</span><em>hue</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.HueJitterAug" title="Permalink to this definition"></a></dt>
<dd><p>Random hue jitter augmentation.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>hue</strong> (<em>float</em>) – The hue jitter ratio range, [0, 1]</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.ColorJitterAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">ColorJitterAug</code><span class="sig-paren">(</span><em>brightness</em>, <em>contrast</em>, <em>saturation</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ColorJitterAug" title="Permalink to this definition"></a></dt>
<dd><p>Apply random brightness, contrast and saturation jitter in random order.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>brightness</strong> (<em>float</em>) – The brightness jitter ratio range, [0, 1]</li>
<li><strong>contrast</strong> (<em>float</em>) – The contrast jitter ratio range, [0, 1]</li>
<li><strong>saturation</strong> (<em>float</em>) – The saturation jitter ratio range, [0, 1]</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.LightingAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">LightingAug</code><span class="sig-paren">(</span><em>alphastd</em>, <em>eigval</em>, <em>eigvec</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.LightingAug" title="Permalink to this definition"></a></dt>
<dd><p>Add PCA based noise.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>alphastd</strong> (<em>float</em>) – Noise level</li>
<li><strong>eigval</strong> (<em>3x1 np.array</em>) – Eigen values</li>
<li><strong>eigvec</strong> (<em>3x3 np.array</em>) – Eigen vectors</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.ColorNormalizeAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">ColorNormalizeAug</code><span class="sig-paren">(</span><em>mean</em>, <em>std</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ColorNormalizeAug" title="Permalink to this definition"></a></dt>
<dd><p>Mean and std normalization.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>mean</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – RGB mean to be subtracted</li>
<li><strong>std</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – RGB standard deviation to be divided</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.RandomGrayAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">RandomGrayAug</code><span class="sig-paren">(</span><em>p</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.RandomGrayAug" title="Permalink to this definition"></a></dt>
<dd><p>Randomly convert to gray image.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>p</strong> (<em>float</em>) – Probability to convert to grayscale</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.HorizontalFlipAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">HorizontalFlipAug</code><span class="sig-paren">(</span><em>p</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.HorizontalFlipAug" title="Permalink to this definition"></a></dt>
<dd><p>Random horizontal flip.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>p</strong> (<em>float</em>) – Probability to flip image horizontally</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.CastAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">CastAug</code><a class="headerlink" href="#mxnet.image.CastAug" title="Permalink to this definition"></a></dt>
<dd><p>Cast to float32</p>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.CreateAugmenter">
<code class="descclassname">image.</code><code class="descname">CreateAugmenter</code><span class="sig-paren">(</span><em>data_shape</em>, <em>resize=0</em>, <em>rand_crop=False</em>, <em>rand_resize=False</em>, <em>rand_mirror=False</em>, <em>mean=None</em>, <em>std=None</em>, <em>brightness=0</em>, <em>contrast=0</em>, <em>saturation=0</em>, <em>hue=0</em>, <em>pca_noise=0</em>, <em>rand_gray=0</em>, <em>inter_method=2</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.CreateAugmenter" title="Permalink to this definition"></a></dt>
<dd><p>Creates an augmenter list.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>data_shape</strong> (<em>tuple of int</em>) – shape for output data</li>
<li><strong>resize</strong> (<em>int</em>) – resize shorter edge if larger than 0 at the begining</li>
<li><strong>rand_resize</strong> (<em>float</em>) – [0, 1], probability to apply random resizing</li>
<li><strong>rand_gray</strong> (<em>float</em>) – [0, 1], probability to convert to grayscale for all channels</li>
<li><strong>rand_mirror</strong> (<em>bool</em>) – whether apply horizontal flip to image with probability 0.5</li>
<li><strong>mean</strong> (<em>np.ndarray</em><em> or </em><em>None</em>) – mean pixel values for [r, g, b]</li>
<li><strong>std</strong> (<em>np.ndarray</em><em> or </em><em>None</em>) – standard deviations for [r, g, b]</li>
<li><strong>brightness</strong> (<em>float</em>) – brightness jittering range (percent)</li>
<li><strong>contrast</strong> (<em>float</em>) – contrast jittering range</li>
<li><strong>saturation</strong> (<em>float</em>) – saturation jittering range</li>
<li><strong>hue</strong> (<em>float</em>) – hue jittering range</li>
<li><strong>pca_noise</strong> (<em>float</em>) – pca noise level</li>
<li><strong>inter_method</strong> (<em>int</em><em>, </em><em>default=2</em><em>(</em><em>Area-based</em><em>)</em><em></em>) – <p>interpolation method for all resizing operations</p>
<p>Possible values:
0: Nearest Neighbors Interpolation.
1: Bilinear interpolation.
2: Area-based (resampling using pixel area relation). It may be a
preferred method for image decimation, as it gives moire-free
results. But when the image is zoomed, it is similar to the Nearest
Neighbors method. (used by default).
3: Bicubic interpolation over 4x4 pixel neighborhood.
4: Lanczos interpolation over 8x8 pixel neighborhood.
9: Cubic for enlarge, area for shrink, bilinear for others
10: Random select from interpolation method metioned above.
Note:
When shrinking an image, it will generally look best with AREA-based
interpolation, whereas, when enlarging an image, it will generally look best
with Bicubic (slow) or Bilinear (faster but still looks OK).</p>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of creating multiple augmenters</span>
<span class="gp">>>> </span><span class="n">augs</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">image</span><span class="o">.</span><span class="n">CreateAugmenter</span><span class="p">(</span><span class="n">data_shape</span><span class="o">=</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">300</span><span class="p">,</span> <span class="mi">300</span><span class="p">),</span> <span class="n">rand_mirror</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">mean</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">brightness</span><span class="o">=</span><span class="mf">0.125</span><span class="p">,</span> <span class="n">contrast</span><span class="o">=</span><span class="mf">0.125</span><span class="p">,</span> <span class="n">rand_gray</span><span class="o">=</span><span class="mf">0.05</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">saturation</span><span class="o">=</span><span class="mf">0.125</span><span class="p">,</span> <span class="n">pca_noise</span><span class="o">=</span><span class="mf">0.05</span><span class="p">,</span> <span class="n">inter_method</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
<span class="gp">>>> </span><span class="c1"># dump the details</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">aug</span> <span class="ow">in</span> <span class="n">augs</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">aug</span><span class="o">.</span><span class="n">dumps</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.ImageDetIter">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">ImageDetIter</code><span class="sig-paren">(</span><em>batch_size</em>, <em>data_shape</em>, <em>path_imgrec=None</em>, <em>path_imglist=None</em>, <em>path_root=None</em>, <em>path_imgidx=None</em>, <em>shuffle=False</em>, <em>part_index=0</em>, <em>num_parts=1</em>, <em>aug_list=None</em>, <em>imglist=None</em>, <em>data_name='data'</em>, <em>label_name='label'</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageDetIter" title="Permalink to this definition"></a></dt>
<dd><p>Image iterator with a large number of augmentation choices for detection.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>aug_list</strong> (<em>list</em><em> or </em><em>None</em>) – augmenter list for generating distorted images</li>
<li><strong>batch_size</strong> (<em>int</em>) – Number of examples per batch.</li>
<li><strong>data_shape</strong> (<em>tuple</em>) – Data shape in (channels, height, width) format.
For now, only RGB image with 3 channels is supported.</li>
<li><strong>path_imgrec</strong> (<em>str</em>) – Path to image record file (.rec).
Created with tools/im2rec.py or bin/im2rec.</li>
<li><strong>path_imglist</strong> (<em>str</em>) – Path to image list (.lst).
Created with tools/im2rec.py or with custom script.
Format: Tab separated record of index, one or more labels and relative_path_from_root.</li>
<li><strong>imglist</strong> (<em>list</em>) – A list of images with the label(s).
Each item is a list [imagelabel: float or list of float, imgpath].</li>
<li><strong>path_root</strong> (<em>str</em>) – Root folder of image files.</li>
<li><strong>path_imgidx</strong> (<em>str</em>) – Path to image index file. Needed for partition and shuffling when using .rec source.</li>
<li><strong>shuffle</strong> (<em>bool</em>) – Whether to shuffle all images at the start of each iteration or not.
Can be slow for HDD.</li>
<li><strong>part_index</strong> (<em>int</em>) – Partition index.</li>
<li><strong>num_parts</strong> (<em>int</em>) – Total number of partitions.</li>
<li><strong>data_name</strong> (<em>str</em>) – Data name for provided symbols.</li>
<li><strong>label_name</strong> (<em>str</em>) – name for detection labels</li>
<li><strong>kwargs</strong> – More arguments for creating augmenter. See mx.image.CreateDetAugmenter.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="mxnet.image.ImageDetIter.reshape">
<code class="descname">reshape</code><span class="sig-paren">(</span><em>data_shape=None</em>, <em>label_shape=None</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageDetIter.reshape" title="Permalink to this definition"></a></dt>
<dd><p>Reshape iterator for data_shape or label_shape.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>data_shape</strong> (<em>tuple</em><em> or </em><em>None</em>) – reshape the data_shape to the new shape if not None</li>
<li><strong>label_shape</strong> (<em>tuple</em><em> or </em><em>None</em>) – reshape label shape to new shape if not None</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.ImageDetIter.next">
<code class="descname">next</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageDetIter.next" title="Permalink to this definition"></a></dt>
<dd><p>Override the function for returning next batch.</p>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.ImageDetIter.augmentation_transform">
<code class="descname">augmentation_transform</code><span class="sig-paren">(</span><em>data</em>, <em>label</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageDetIter.augmentation_transform" title="Permalink to this definition"></a></dt>
<dd><p>Override Transforms input data with specified augmentations.</p>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.ImageDetIter.check_label_shape">
<code class="descname">check_label_shape</code><span class="sig-paren">(</span><em>label_shape</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageDetIter.check_label_shape" title="Permalink to this definition"></a></dt>
<dd><p>Checks if the new label shape is valid</p>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.ImageDetIter.draw_next">
<code class="descname">draw_next</code><span class="sig-paren">(</span><em>color=None</em>, <em>thickness=2</em>, <em>mean=None</em>, <em>std=None</em>, <em>clip=True</em>, <em>waitKey=None</em>, <em>window_name='draw_next'</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageDetIter.draw_next" title="Permalink to this definition"></a></dt>
<dd><p>Display next image with bounding boxes drawn.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>color</strong> (<em>tuple</em>) – Bounding box color in RGB, use None for random color</li>
<li><strong>thickness</strong> (<em>int</em>) – Bounding box border thickness</li>
<li><strong>mean</strong> (<em>True</em><em> or </em><em>numpy.ndarray</em>) – Compensate for the mean to have better visual effect</li>
<li><strong>std</strong> (<em>True</em><em> or </em><em>numpy.ndarray</em>) – Revert standard deviations</li>
<li><strong>clip</strong> (<em>bool</em>) – If true, clip to [0, 255] for better visual effect</li>
<li><strong>waitKey</strong> (<em>None</em><em> or </em><em>int</em>) – Hold the window for waitKey milliseconds if set, skip ploting if None</li>
<li><strong>window_name</strong> (<em>str</em>) – Plot window name if waitKey is set.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first"></p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last">numpy.ndarray</p>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># use draw_next to get images with bounding boxes drawn</span>
<span class="gp">>>> </span><span class="n">iterator</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">image</span><span class="o">.</span><span class="n">ImageDetIter</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">600</span><span class="p">,</span> <span class="mi">600</span><span class="p">),</span> <span class="n">path_imgrec</span><span class="o">=</span><span class="s1">'train.rec'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">image</span> <span class="ow">in</span> <span class="n">iterator</span><span class="o">.</span><span class="n">draw_next</span><span class="p">(</span><span class="n">waitKey</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="gp">... </span> <span class="c1"># display image</span>
<span class="gp">>>> </span><span class="c1"># or let draw_next display using cv2 module</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">image</span> <span class="ow">in</span> <span class="n">iterator</span><span class="o">.</span><span class="n">draw_next</span><span class="p">(</span><span class="n">waitKey</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">window_name</span><span class="o">=</span><span class="s1">'disp'</span><span class="p">):</span>
<span class="gp">... </span> <span class="k">pass</span>
</pre></div>
</div>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.ImageDetIter.sync_label_shape">
<code class="descname">sync_label_shape</code><span class="sig-paren">(</span><em>it</em>, <em>verbose=False</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.ImageDetIter.sync_label_shape" title="Permalink to this definition"></a></dt>
<dd><p>Synchronize label shape with the input iterator. This is useful when
train/validation iterators have different label padding.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>it</strong> (<a class="reference internal" href="#mxnet.image.ImageDetIter" title="mxnet.image.ImageDetIter"><em>ImageDetIter</em></a>) – The other iterator to synchronize</li>
<li><strong>verbose</strong> (<em>bool</em>) – Print verbose log if true</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first">The synchronized other iterator, the internal label shape is updated as well.</p>
</td>
</tr>
<tr class="field-odd field"><th class="field-name">Return type:</th><td class="field-body"><p class="first last"><a class="reference internal" href="#mxnet.image.ImageDetIter" title="mxnet.image.ImageDetIter">ImageDetIter</a></p>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">train_iter</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">image</span><span class="o">.</span><span class="n">ImageDetIter</span><span class="p">(</span><span class="mi">32</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">300</span><span class="p">,</span> <span class="mi">300</span><span class="p">),</span> <span class="n">path_imgrec</span><span class="o">=</span><span class="s1">'train.rec'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">val_iter</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">image</span><span class="o">.</span><span class="n">ImageDetIter</span><span class="p">(</span><span class="mi">32</span><span class="p">,</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">300</span><span class="p">,</span> <span class="mi">300</span><span class="p">),</span> <span class="n">path</span><span class="o">.</span><span class="n">imgrec</span><span class="o">=</span><span class="s1">'val.rec'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">train_iter</span><span class="o">.</span><span class="n">label_shape</span>
<span class="go">(30, 6)</span>
<span class="gp">>>> </span><span class="n">val_iter</span><span class="o">.</span><span class="n">label_shape</span>
<span class="go">(25, 6)</span>
<span class="gp">>>> </span><span class="n">val_iter</span> <span class="o">=</span> <span class="n">train_iter</span><span class="o">.</span><span class="n">sync_label_shape</span><span class="p">(</span><span class="n">val_iter</span><span class="p">,</span> <span class="n">verbose</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">train_iter</span><span class="o">.</span><span class="n">label_shape</span>
<span class="go">(30, 6)</span>
<span class="gp">>>> </span><span class="n">val_iter</span><span class="o">.</span><span class="n">label_shape</span>
<span class="go">(30, 6)</span>
</pre></div>
</div>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.DetAugmenter">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">DetAugmenter</code><span class="sig-paren">(</span><em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.DetAugmenter" title="Permalink to this definition"></a></dt>
<dd><p>Detection base augmenter</p>
<dl class="method">
<dt id="mxnet.image.DetAugmenter.dumps">
<code class="descname">dumps</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.DetAugmenter.dumps" title="Permalink to this definition"></a></dt>
<dd><p>Saves the Augmenter to string</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">JSON formatted string that describes the Augmenter.</td>
</tr>
<tr class="field-even field"><th class="field-name">Return type:</th><td class="field-body">str</td>
</tr>
</tbody>
</table>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.DetBorrowAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">DetBorrowAug</code><span class="sig-paren">(</span><em>augmenter</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.DetBorrowAug" title="Permalink to this definition"></a></dt>
<dd><p>Borrow standard augmenter from image classification.
Which is good once you know label won’t be affected after this augmenter.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>augmenter</strong> (<em>mx.image.Augmenter</em>) – The borrowed standard augmenter which has no effect on label</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.DetRandomSelectAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">DetRandomSelectAug</code><span class="sig-paren">(</span><em>aug_list</em>, <em>skip_prob=0</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.DetRandomSelectAug" title="Permalink to this definition"></a></dt>
<dd><p>Randomly select one augmenter to apply, with chance to skip all.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>aug_list</strong> (<em>list of DetAugmenter</em>) – The random selection will be applied to one of the augmenters</li>
<li><strong>skip_prob</strong> (<em>float</em>) – The probability to skip all augmenters and return input directly</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.DetHorizontalFlipAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">DetHorizontalFlipAug</code><span class="sig-paren">(</span><em>p</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.DetHorizontalFlipAug" title="Permalink to this definition"></a></dt>
<dd><p>Random horizontal flipping.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>p</strong> (<em>float</em>) – chance [0, 1] to flip</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.DetRandomCropAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">DetRandomCropAug</code><span class="sig-paren">(</span><em>min_object_covered=0.1</em>, <em>aspect_ratio_range=(0.75</em>, <em>1.33)</em>, <em>area_range=(0.05</em>, <em>1.0)</em>, <em>min_eject_coverage=0.3</em>, <em>max_attempts=50</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.DetRandomCropAug" title="Permalink to this definition"></a></dt>
<dd><p>Random cropping with constraints</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>min_object_covered</strong> (<em>float</em><em>, </em><em>default=0.1</em>) – The cropped area of the image must contain at least this fraction of
any bounding box supplied. The value of this parameter should be non-negative.
In the case of 0, the cropped area does not need to overlap any of the
bounding boxes supplied.</li>
<li><strong>min_eject_coverage</strong> (<em>float</em><em>, </em><em>default=0.3</em>) – The minimum coverage of cropped sample w.r.t its original size. With this
constraint, objects that have marginal area after crop will be discarded.</li>
<li><strong>aspect_ratio_range</strong> (<em>tuple of floats</em><em>, </em><em>default=</em><em>(</em><em>0.75</em><em>, </em><em>1.33</em><em>)</em><em></em>) – The cropped area of the image must have an aspect ratio = width / height
within this range.</li>
<li><strong>area_range</strong> (<em>tuple of floats</em><em>, </em><em>default=</em><em>(</em><em>0.05</em><em>, </em><em>1.0</em><em>)</em><em></em>) – The cropped area of the image must contain a fraction of the supplied
image within in this range.</li>
<li><strong>max_attempts</strong> (<em>int</em><em>, </em><em>default=50</em>) – Number of attempts at generating a cropped/padded region of the image of the
specified constraints. After max_attempts failures, return the original image.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="class">
<dt id="mxnet.image.DetRandomPadAug">
<em class="property">class </em><code class="descclassname">mxnet.image.</code><code class="descname">DetRandomPadAug</code><span class="sig-paren">(</span><em>aspect_ratio_range=(0.75</em>, <em>1.33)</em>, <em>area_range=(1.0</em>, <em>3.0)</em>, <em>max_attempts=50</em>, <em>pad_val=(128</em>, <em>128</em>, <em>128)</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.DetRandomPadAug" title="Permalink to this definition"></a></dt>
<dd><p>Random padding augmenter.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>aspect_ratio_range</strong> (<em>tuple of floats</em><em>, </em><em>default=</em><em>(</em><em>0.75</em><em>, </em><em>1.33</em><em>)</em><em></em>) – The padded area of the image must have an aspect ratio = width / height
within this range.</li>
<li><strong>area_range</strong> (<em>tuple of floats</em><em>, </em><em>default=</em><em>(</em><em>1.0</em><em>, </em><em>3.0</em><em>)</em><em></em>) – The padded area of the image must be larger than the original area</li>
<li><strong>max_attempts</strong> (<em>int</em><em>, </em><em>default=50</em>) – Number of attempts at generating a padded region of the image of the
specified constraints. After max_attempts failures, return the original image.</li>
<li><strong>pad_val</strong> (<em>float</em><em> or </em><em>tuple of float</em><em>, </em><em>default=</em><em>(</em><em>128</em><em>, </em><em>128</em><em>, </em><em>128</em><em>)</em><em></em>) – pixel value to be filled when padding is enabled.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>
<dl class="method">
<dt id="mxnet.image.CreateDetAugmenter">
<code class="descclassname">image.</code><code class="descname">CreateDetAugmenter</code><span class="sig-paren">(</span><em>data_shape</em>, <em>resize=0</em>, <em>rand_crop=0</em>, <em>rand_pad=0</em>, <em>rand_gray=0</em>, <em>rand_mirror=False</em>, <em>mean=None</em>, <em>std=None</em>, <em>brightness=0</em>, <em>contrast=0</em>, <em>saturation=0</em>, <em>pca_noise=0</em>, <em>hue=0</em>, <em>inter_method=2</em>, <em>min_object_covered=0.1</em>, <em>aspect_ratio_range=(0.75</em>, <em>1.33)</em>, <em>area_range=(0.05</em>, <em>3.0)</em>, <em>min_eject_coverage=0.3</em>, <em>max_attempts=50</em>, <em>pad_val=(128</em>, <em>128</em>, <em>128)</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.image.CreateDetAugmenter" title="Permalink to this definition"></a></dt>
<dd><p>Create augmenters for detection.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>data_shape</strong> (<em>tuple of int</em>) – shape for output data</li>
<li><strong>resize</strong> (<em>int</em>) – resize shorter edge if larger than 0 at the begining</li>
<li><strong>rand_crop</strong> (<em>float</em>) – [0, 1], probability to apply random cropping</li>
<li><strong>rand_pad</strong> (<em>float</em>) – [0, 1], probability to apply random padding</li>
<li><strong>rand_gray</strong> (<em>float</em>) – [0, 1], probability to convert to grayscale for all channels</li>
<li><strong>rand_mirror</strong> (<em>bool</em>) – whether apply horizontal flip to image with probability 0.5</li>
<li><strong>mean</strong> (<em>np.ndarray</em><em> or </em><em>None</em>) – mean pixel values for [r, g, b]</li>
<li><strong>std</strong> (<em>np.ndarray</em><em> or </em><em>None</em>) – standard deviations for [r, g, b]</li>
<li><strong>brightness</strong> (<em>float</em>) – brightness jittering range (percent)</li>
<li><strong>contrast</strong> (<em>float</em>) – contrast jittering range</li>
<li><strong>saturation</strong> (<em>float</em>) – saturation jittering range</li>
<li><strong>hue</strong> (<em>float</em>) – hue jittering range</li>
<li><strong>pca_noise</strong> (<em>float</em>) – pca noise level</li>
<li><strong>inter_method</strong> (<em>int</em><em>, </em><em>default=2</em><em>(</em><em>Area-based</em><em>)</em><em></em>) – <p>interpolation method for all resizing operations</p>
<p>Possible values:
0: Nearest Neighbors Interpolation.
1: Bilinear interpolation.
2: Area-based (resampling using pixel area relation). It may be a
preferred method for image decimation, as it gives moire-free
results. But when the image is zoomed, it is similar to the Nearest
Neighbors method. (used by default).
3: Bicubic interpolation over 4x4 pixel neighborhood.
4: Lanczos interpolation over 8x8 pixel neighborhood.
9: Cubic for enlarge, area for shrink, bilinear for others
10: Random select from interpolation method metioned above.
Note:
When shrinking an image, it will generally look best with AREA-based
interpolation, whereas, when enlarging an image, it will generally look best
with Bicubic (slow) or Bilinear (faster but still looks OK).</p>
</li>
<li><strong>min_object_covered</strong> (<em>float</em>) – The cropped area of the image must contain at least this fraction of
any bounding box supplied. The value of this parameter should be non-negative.
In the case of 0, the cropped area does not need to overlap any of the
bounding boxes supplied.</li>
<li><strong>min_eject_coverage</strong> (<em>float</em>) – The minimum coverage of cropped sample w.r.t its original size. With this
constraint, objects that have marginal area after crop will be discarded.</li>
<li><strong>aspect_ratio_range</strong> (<em>tuple of floats</em>) – The cropped area of the image must have an aspect ratio = width / height
within this range.</li>
<li><strong>area_range</strong> (<em>tuple of floats</em>) – The cropped area of the image must contain a fraction of the supplied
image within in this range.</li>
<li><strong>max_attempts</strong> (<em>int</em>) – Number of attempts at generating a cropped/padded region of the image of the
specified constraints. After max_attempts failures, return the original image.</li>
<li><strong>pad_val</strong> (<em>float</em>) – pixel value to be filled when padding is enabled. pad_val will automatically
be subtracted by mean and divided by std if applicable.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="c1"># An example of creating multiple augmenters</span>
<span class="gp">>>> </span><span class="n">augs</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">image</span><span class="o">.</span><span class="n">CreateDetAugmenter</span><span class="p">(</span><span class="n">data_shape</span><span class="o">=</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">300</span><span class="p">,</span> <span class="mi">300</span><span class="p">),</span> <span class="n">rand_crop</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">rand_pad</span><span class="o">=</span><span class="mf">0.5</span><span class="p">,</span> <span class="n">rand_mirror</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">mean</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">brightness</span><span class="o">=</span><span class="mf">0.125</span><span class="p">,</span> <span class="n">contrast</span><span class="o">=</span><span class="mf">0.125</span><span class="p">,</span>
<span class="gp">... </span> <span class="n">saturation</span><span class="o">=</span><span class="mf">0.125</span><span class="p">,</span> <span class="n">pca_noise</span><span class="o">=</span><span class="mf">0.05</span><span class="p">,</span> <span class="n">inter_method</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">min_object_covered</span><span class="o">=</span><span class="p">[</span><span class="mf">0.3</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">,</span> <span class="mf">0.9</span><span class="p">],</span>
<span class="gp">... </span> <span class="n">area_range</span><span class="o">=</span><span class="p">(</span><span class="mf">0.3</span><span class="p">,</span> <span class="mf">3.0</span><span class="p">))</span>
<span class="gp">>>> </span><span class="c1"># dump the details</span>
<span class="gp">>>> </span><span class="k">for</span> <span class="n">aug</span> <span class="ow">in</span> <span class="n">augs</span><span class="p">:</span>
<span class="gp">... </span> <span class="n">aug</span><span class="o">.</span><span class="n">dumps</span><span class="p">()</span>
</pre></div>
</div>
</dd></dl>
<script>auto_index("api-reference");</script></div>
</div>
<div class="container">
<div class="footer">
<p> © 2015-2017 DMLC. All rights reserved. </p>
</div>
</div>
</div>
<div aria-label="main navigation" class="sphinxsidebar rightsidebar" role="navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Image API</a><ul>
<li><a class="reference internal" href="#overview">Overview</a></li>
<li><a class="reference internal" href="#image-processing-functions">Image processing functions</a></li>
<li><a class="reference internal" href="#image-iterators">Image iterators</a></li>
<li><a class="reference internal" href="#api-reference">API Reference</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div> <!-- pagename != index -->
<script crossorigin="anonymous" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="../../_static/js/sidebar.js" type="text/javascript"></script>
<script src="../../_static/js/search.js" type="text/javascript"></script>
<script src="../../_static/js/navbar.js" type="text/javascript"></script>
<script src="../../_static/js/clipboard.min.js" type="text/javascript"></script>
<script src="../../_static/js/copycode.js" type="text/javascript"></script>
<script type="text/javascript">
$('body').ready(function () {
$('body').css('visibility', 'visible');
});
</script>
</div></body>
</html>