ValueError: zero-size array to reduction operation minimum which has no identity

I tried to save my cropped images using matplotlib, but I get an error like this

File "tools/script.py", line 165, in main
    out_when_no_box=args.out_when_no_box
  File "/home/user/project/vis.py", line 99, in vis_one_image
    plt.imsave('/home/user/data/masks/' + file_name + '_' + str(i) + '.png', crop_mask)
  File "/home/user/.local/lib/python3.5/site-packages/matplotlib/pyplot.py", line 2157, in imsave
    return matplotlib.image.imsave(fname, arr, **kwargs)
  File "/home/user/.local/lib/python3.5/site-packages/matplotlib/image.py", line 1418, in imsave
    image.set_data(arr)
  File "/home/user/.local/lib/python3.5/site-packages/matplotlib/image.py", line 646, in set_data
    if self._A.min() < 0 or high < self._A.max():
  File "/home/user/.local/lib/python3.5/site-packages/numpy/ma/core.py", line 5641, in min
    axis=axis, out=out, **kwargs).view(type(self))
  File "/home/user/.local/lib/python3.5/site-packages/numpy/core/_methods.py", line 34, in _amin
    return umr_minimum(a, axis, None, out, keepdims, initial, where)
ValueError: zero-size array to reduction operation minimum which has no identit
matplotlibsave-image
3 votesLP185.00
1 Answers
JO218.00
2

It's because of your cropped image. it is an empty array or has an empty dimention. Take a look at the shapes of them. You can't save an empty array as an image.

Reply
Couldn't find what you were looking for?and we will find an expert to answer.
How helpful was this page?