Scipy.misc.imshow RuntimeError ('Failed to view image')

I am testing scipy.misc.imshow and I got a RuntimeError: image view failed .

I am using Python3.4 and running it on CentOS 7.

import scipy.misc
img = scipy.misc.imread('Data/cat.jpg')
assert len(img.shape) == 3
img_resized = scipy.misc.imresize(img, (224, 224))
img_answer = (img_resized/255.0).astype('float32')
scipy.misc.imshow(img_answer)

And I have an error:

sh: see: command not found
Traceback (most recent call last):
  File "/usr/local/pycharm/helpers/pydev/pydev_run_in_console.py", line 71, in <module>
    globals = run_file(file, None, None)
  File "/usr/local/pycharm/helpers/pydev/pydev_run_in_console.py", line 31, in run_file
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/usr/local/pycharm/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/root/PycharmProjects/myVQA/testgood.py", line 6, in <module>
    scipy.misc.imshow(img_answer)
  File "/usr/lib64/python3.4/site-packages/scipy/misc/pilutil.py", line 442, in imshow
    raise RuntimeError('Could not execute image viewer.')
RuntimeError: Could not execute image viewer.

It says that the team was seenot found. Where is the team seeinstalled on CentOS7 located? How can I fix the problem?

I tried adding SCIPY_PIL_IMAGE_VIEWER=/bin/eogin /etc/profile but it doesn't seem to help.

+4
source share
3 answers

matplotlib.pyplot SciPy imshow.

import scipy.misc
img = scipy.misc.imread('Data/cat.jpg')
assert len(img.shape) == 3
img_resized = scipy.misc.imresize(img, (224, 224))
img_answer = (img_resized/255.0).astype('float32')

import matplotlib.pyplot as plt
plt.imshow(np.uint8(img_tinted))
plt.show()

Source image = > Output image

P.S. plt.imshow(img_tinted), , unit8. , np.uint8 , plt.imshow(np.uint8(img_tinted))

np.uint8

enter image description here

+5

:

1 /etc/profile

SCIPY_PIL_IMAGE_VIEWER=/bin/eog
export SCIPY_PIL_IMAGE_VIEWER

2

SCIPY_PIL_IMAGE_VIEWER,

cmd = os.environ.get('SCIPY_PIL_IMAGE_VIEWER', 'see')

SCIPY_PIL_IMAGE_VIEWER

+1

( , matplotlib):

from os import environ
environ['SCIPY_PIL_IMAGE_VIEWER'] = {your image viewer pgm} # e.g. C:/IrfanView/i_view32.exe

scipy imshow().

0

Source: https://habr.com/ru/post/1658750/


All Articles