keplr-io / quiver

Interactive convnet features visualization for Keras
https://keplr-io.github.io/quiver/
MIT License
1.77k stars 223 forks source link

ImportError: cannot import name 'imsave' #78

Open ashishpatel26 opened 5 years ago

ashishpatel26 commented 5 years ago

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 commented 4 years ago

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 commented 4 years ago

pip install scipy==1.2.1