summaryWriter add_image cant handle image format?

username: Daniel_Joseph
cooked: <p>I am trying to show the images(image shape is  [200<em>15</em>15] and i wanna just plot the first channel [1<em>15</em>15] the type is .mat) into the Tensorboard as follow :</p>
<pre><code class="lang-auto">
images, labels = next(iter(train_loader))
grid = torchvision.utils.make_grid(images[:,1,:,:])
writer.add_image('images', grid, 0)   # here is the error line 
writer.add_graph(model, images)
writer.close()

</code></pre>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/2X/e/e619633e67962e36574d99b1d22ebbe934c9be4a.png" data-download-href="https://discuss.pytorch.org/uploads/default/e619633e67962e36574d99b1d22ebbe934c9be4a" title="imgbelsi"><img src="https://discuss.pytorch.org/uploads/default/optimized/2X/e/e619633e67962e36574d99b1d22ebbe934c9be4a_2_690x388.png" alt="imgbelsi" data-base62-sha1="wPyd5e8F2sbWIzyeuYHLv2lm9Dk" width="690" height="388" srcset="https://discuss.pytorch.org/uploads/default/optimized/2X/e/e619633e67962e36574d99b1d22ebbe934c9be4a_2_690x388.png, https://discuss.pytorch.org/uploads/default/optimized/2X/e/e619633e67962e36574d99b1d22ebbe934c9be4a_2_1035x582.png 1.5x, https://discuss.pytorch.org/uploads/default/optimized/2X/e/e619633e67962e36574d99b1d22ebbe934c9be4a_2_1380x776.png 2x" data-dominant-color="2C2F30"><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">imgbelsi</span><span class="informations">1920×1080 398 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><br>
but I got this error :</p>
<pre><code class="lang-auto">
Traceback (most recent call last):
  File "/home/joseph/.vscode/extensions/ms-python.python-2019.5.18678/pythonFiles/ptvsd_launcher.py", line 43, in &lt;module&gt;
    main(ptvsdArgs)
  File "/home/joseph/.vscode/extensions/ms-python.python-2019.5.18678/pythonFiles/lib/python/ptvsd/__main__.py", line 434, in main
    run()
  File "/home/joseph/.vscode/extensions/ms-python.python-2019.5.18678/pythonFiles/lib/python/ptvsd/__main__.py", line 312, in run_file
    runpy.run_path(target, run_name='__main__')
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/runpy.py", line 252, in run_path
    return _run_module_code(code, init_globals, run_name, path_name)
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/joseph/Documents/HYM PhD 2019/Codes/SSH PRGS/hsicnnpio_18519_1/main.py", line 179, in &lt;module&gt;
    writer.add_image('images', grid, 0)
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/site-packages/tensorboardX/writer.py", line 412, in add_image
    self.file_writer.add_summary(image(tag, img_tensor), global_step, walltime)
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/site-packages/tensorboardX/summary.py", line 205, in image
    image = make_image(tensor, rescale=rescale)
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/site-packages/tensorboardX/summary.py", line 243, in make_image
    image = Image.fromarray(tensor)
  File "/home/joseph/anaconda2/envs/HYMenv/lib/python2.7/site-packages/PIL/Image.py", line 2431, in fromarray
    raise TypeError("Cannot handle this data type")
TypeError: Cannot handle this data type

</code></pre>
<p>Thanks in advance</p>