Chart / graph library for pyTorch?

username: pumplerod
cooked: <p>Is there a chart library module for pytorch which might allow for some of the functionality found in matplotlib?</p>
<p>I ask because I am currently using matplotlib to generate a radar chart, which I then use as a sample’s input image to my torch network.  The matplotlib portion of this, creating a chart for each sample, is very slow and currently has a memory leak I can’t pin down.  Ideally I would much prefer to be able to generate the chart images directly from the tensors.</p>
<p>For reference, here is a snapshot of 200 samples from my data set where I create an image to then use in a CNN.<br>
<div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/3/e/3e8612a35c56b7a5fb6ac48b37bce3a668f3b1eb.png" data-download-href="https://discuss.pytorch.org/uploads/default/3e8612a35c56b7a5fb6ac48b37bce3a668f3b1eb" title="sample_image_grid"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/3/e/3e8612a35c56b7a5fb6ac48b37bce3a668f3b1eb_2_690x348.png" alt="sample_image_grid" data-base62-sha1="8V6QSgPCqa17rXnyKS3mkzy7JrB" width="690" height="348" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/3/e/3e8612a35c56b7a5fb6ac48b37bce3a668f3b1eb_2_690x348.png, https://discuss.pytorch.org/uploads/default/original/3X/3/e/3e8612a35c56b7a5fb6ac48b37bce3a668f3b1eb.png 1.5x, https://discuss.pytorch.org/uploads/default/original/3X/3/e/3e8612a35c56b7a5fb6ac48b37bce3a668f3b1eb.png 2x" data-dominant-color="3C3A06"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">sample_image_grid</span><span class="informations">704×356 227 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>

username: ptrblck
cooked: <p>I don’t know how the data is created but would assume that numpy is used under the hood. If so, you could check which numpy operators are used there and try to port them to PyTorch (assuming all operations are supported) and could then use a GPU.</p>

username: pumplerod
cooked: <p>That’s a good idea <a class="mention" href="/u/ptrblck">@ptrblck</a>.  I can get as far as using tensors to create the values being fed into the pyplot.plot() method, but I haven’t gone digging to figure out how it “fills in” the defined area.  It seems like pytorch might be particularly well suited for some traditional graphics tasks so I had hope that someone might already have a library which could generate and render polygonal surfaces.</p>

username: ptrblck
cooked: <p>I’m not sure if PyTorch’s strength could shine in filling polygons, if you don’t need to differentiate through these operations (assuming they are even differentiable). You could take a look at e.g. <code>Kornia</code> which might provide similar methods already. CC <a class="mention" href="/u/edgarriba">@edgarriba</a></p>

username: pumplerod
cooked: <p>Kornia looks interesting.  I’ve also found VisPy which looks like it might be a good solution for using the GPU to turn my data into images, but the documentation is very lacking and may still be too early in development to actually get something working.</p>
<p>If anyone else has experience with techniques for converting data into an image to be used with pyTorch training I would love to investigate.  Unfortunately my data set is far too large to pre-convert the data, so it needs to be done with the loader and collate_fn.  keeping the data on the GPU is the most ideal solution.</p>

username: edgarriba
cooked: <p>we have added recently some drawing utilities in kornia. See e.g <a href="https://kornia.readthedocs.io/en/latest/utils.html#kornia.utils.draw_line" rel="noopener nofollow ugc"><code>draw_line</code></a> or <a href="https://kornia.readthedocs.io/en/latest/utils.html#kornia.utils.draw_rectangle" rel="noopener nofollow ugc"><code>draw_rectangle</code></a>.</p>
<p>We still miss fill polygon – contributions are welcomed <img src="https://discuss.pytorch.org/images/emoji/apple/slight_smile.png?v=10" title=":slight_smile:" class="emoji" alt=":slight_smile:"></p>