Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: cannot import name 'imsave' #78

Open
ashishpatel26 opened this issue Nov 7, 2019 · 2 comments
Open

ImportError: cannot import name 'imsave' #78

ashishpatel26 opened this issue Nov 7, 2019 · 2 comments

Comments

@ashishpatel26
Copy link

ImportError: cannot import name 'imsave'

ImportError Traceback (most recent call last)
in
----> 1 from scipy.misc import imsave
2 from quiver_engine.server import launch
3
4
5 launch(model=model, input_folder='./img',port=7000)

ImportError: cannot import name 'imsave'

@christianversloot
Copy link

christianversloot commented Nov 29, 2019

Replace quiver_engine/file_utils.py with

import re
from os.path import relpath, abspath
from os import listdir

import imageio
from quiver_engine.util import deprocess_image

def save_layer_img(layer_outputs, layer_name, idx, temp_folder, input_path):
    filename = get_output_filename(layer_name, idx, temp_folder, input_path)
    imageio.imwrite(filename, deprocess_image(layer_outputs))
    return relpath(filename, abspath(temp_folder))

def get_output_filename(layer_name, z_idx, temp_folder, input_path):
    return '{}/{}_{}_{}.png'.format(temp_folder, layer_name, str(z_idx), input_path)

def list_img_files(input_folder):
    image_regex = re.compile(r'.*\.(jpg|png|gif)$')
    return [
        filename
        for filename in listdir(
            abspath(input_folder)
        )
        if image_regex.match(filename) is not None
    ]

Possibly, also run pip install imageio.

scipy.imsave has been removed since its deprecation quite some time ago, but was not yet replaced in this package. Imageio is the recommended replacement.

@Rainweic
Copy link

pip install scipy==1.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants