titu1994 / Neural-Style-Transfer

Keras Implementation of Neural Style Transfer from the paper "A Neural Algorithm of Artistic Style" (http://arxiv.org/abs/1508.06576) in Keras 2.0+
Apache License 2.0
2.28k stars 482 forks source link

ImportError: cannot import name 'imread' from 'scipy.misc' #59

Closed f1am3d closed 5 years ago

f1am3d commented 5 years ago

py Network.py "./images/inputs/1.jpg" "./images/inputs/style.jpg" C:\Users\flamesoff\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\_distributor_init.py:32: UserWarning: loaded more than 1 DLL from .libs: C:\Users\flamesoff\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\.libs\libopenblas.IPBC74C7KURV7CB2PKT5Z5FNR3SIBV4J.gfortran-win_amd64.dll C:\Users\flamesoff\AppData\Local\Programs\Python\Python37\lib\site-packages\numpy\.libs\libopenblas.TXA6YQSD3GCQQC22GEQ54J2UDCXDXHWN.gfortran-win_amd64.dll stacklevel=1) Traceback (most recent call last): File "Network.py", line 5, in <module> from scipy.misc import imread, imresize, imsave, fromimage, toimage ImportError: cannot import name 'imread' from 'scipy.misc' (C:\Users\flamesoff\AppData\Local\Programs\Python\Python37\lib\site-packages\scipy\misc\__init__.py)

Everything is installed in accordance with requirements from readme.md.

titu1994 commented 5 years ago

Download the scripts again. You have an older version. The new one has scipy imports commented out.

f1am3d commented 5 years ago

@titu1994 I downloaded latest versions with conda.

tensorflow-gpu 1.13.1 scipy 1.3.0 keras-gpu 2.2.4 pillow 6.1.0 numpy 1.16.4 h5py 2.9.0

titu1994 commented 5 years ago

This issue was patched recently. Update the codebase, not the libraries. https://github.com/titu1994/Neural-Style-Transfer/blob/master/Network.py#L6

image

f1am3d commented 5 years ago

@titu1994 Please don't close issues before you get a successful response from the topic starter. That's not a professional way to resolve problems. If you close an issue it doesn't mean that it's resolved.

WARNING:tensorflow:From D:\Soft\Anaconda3\envs\nst\lib\site-packages\tensorflow\python\framework\op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
Traceback (most recent call last):
  File "D:\Soft\Anaconda3\envs\nst\lib\site-packages\tensorflow\python\framework\ops.py", line 1659, in _create_c_op
    c_op = c_api.TF_FinishOperation(op_desc)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Dimension 0 in both shapes must be equal, but are 565 and 400. Shapes are [565,400,3] and [400,565,3]. for 'concat' (op: 'ConcatV2') with input shapes: [1,565,400,3], [1,565,400,3], [1,400,565,3], [] and with computed input tensors: input[3] = <0>.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "inetwork.py", line 322, in <module>
    input_tensor = K.concatenate(image_tensors, axis=0)
  File "D:\Soft\Anaconda3\envs\nst\lib\site-packages\keras\backend\tensorflow_backend.py", line 1956, in concatenate
    return tf.concat([to_dense(x) for x in tensors], axis)
  File "D:\Soft\Anaconda3\envs\nst\lib\site-packages\tensorflow\python\util\dispatch.py", line 180, in wrapper
    return target(*args, **kwargs)
  File "D:\Soft\Anaconda3\envs\nst\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1256, in concat
    return gen_array_ops.concat_v2(values=values, axis=axis, name=name)
  File "D:\Soft\Anaconda3\envs\nst\lib\site-packages\tensorflow\python\ops\gen_array_ops.py", line 1149, in concat_v2
    "ConcatV2", values=values, axis=axis, name=name)
  File "D:\Soft\Anaconda3\envs\nst\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper
    op_def=op_def)
  File "D:\Soft\Anaconda3\envs\nst\lib\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func
    return func(*args, **kwargs)
  File "D:\Soft\Anaconda3\envs\nst\lib\site-packages\tensorflow\python\framework\ops.py", line 3300, in create_op
    op_def=op_def)
  File "D:\Soft\Anaconda3\envs\nst\lib\site-packages\tensorflow\python\framework\ops.py", line 1823, in __init__
    control_input_ops)
  File "D:\Soft\Anaconda3\envs\nst\lib\site-packages\tensorflow\python\framework\ops.py", line 1662, in _create_c_op
    raise ValueError(str(e))
ValueError: Dimension 0 in both shapes must be equal, but are 565 and 400. Shapes are [565,400,3] and [400,565,3]. for 'concat' (op: 'ConcatV2') with input shapes: [1,565,400,3], [1,565,400,3], [1,400,565,3], [] and with computed input tensors: input[3] = <0>.

Everything is installed git-pulled and there's a problem in your code again.

Running as this:

D:\Soft\Anaconda3\envs\nst\python.exe inetwork.py "D:\Documents\Projects\Neural\Neural-Style-Transfer\images\inputs\1.jpg" "D:\Documents\Projects\Neural\Neural-Style-Transfer\images\inputs\style.jpg" "result_" 
f1am3d commented 5 years ago

@titu1994 Also: Always specify the exact version of all dependencies that the application is stable with. Every good developer knows that updating the version of any dependencies can cause the application to break down. You haven't even written a version of Python that your application works with. Just nonsense.

titu1994 commented 5 years ago

@FlamesoFF Many points to raise here.

1) An issue is specific to its heading. Your issue was : "ImportError: cannot import name 'imread' from 'scipy.misc' #59". That was fixed by :

This issue was patched recently. Update the codebase, not the libraries.

I closed the issue immediately, because I already knew you did not have the latest code and therefore once you did, it would work properly. Therefore this issue was closed.

2) Your next error that popped up is entirely different in scope, and not even pertaining to the original issue. The correct way to handle this is to create another issue, not continue with the closed one.

3) This is a passion project. Do you see any label here saying "This project is supported by a team of full time employees of X company", cause I sure don't? Honestly, why do you expect a production level quality script and setup environment from a passion project?

4) Also, unless you didn't notice, or didn't care to check, I have been maintaining this project over the past 3 years, for free, without many contributions from external sources (though the few I received over the years are greatly appreciated). If you have such issues with the code, either try to fix it rather than just complain about it and lecture other people about writing a requirements.txt or explicitly stating a python version, or simply don't use it. Python 2 is dead. Python 3.4+ will run this just fine. Thousands of people over the years had no issue with this.

5) There are exactly 4 ways of running the scripts :

There's a full guide to the scripts in the readme, a full set of applications to run them with a GUI, and online GPU access via colab. How much more should I possibly do to make it less of a problem for people to run this code?


Seriously, I could not care less about resolving the bugs of this project due to library changes spanning 3+ years. If you peer into my github sometime, you'll note I have at least 90+ projects that I have to manage, all on my own time. The fact that I still keep this one updated, is solely due to the fact that it is enjoyable once in a while. Nothing else.

If you feel that this is "Such nonsense", by all means, use some other library for your needs.

Lastly, end rant, and the utils script has been patched to correct the issue you had.

f1am3d commented 5 years ago

@titu1994 I understand that you're full-time developer on your main job and this is your passionate project. But even full-time job is not a excuse for not providing dependencies version in requirements.txt. Only today I saw that you have added requirements.txt - thank you for that.

Your next error that popped up is entirely different in scope, and not even pertaining to the original issue. The correct way to handle this is to create another issue, not continue with the closed one.

Okay, I will open another if it will still has place after update.

This is a passion project. Do you see any label here saying "This project is supported by a team of full time employees of X company", cause I sure don't? Honestly, why do you expect a production level quality script and setup environment from a passion project?

I'm not expect production level quality, I only expect basic project description.

If you have such issues with the code, either try to fix it rather than just complain about it and lecture other people about writing a requirements.txt or explicitly stating a python version, or simply don't use it.

It's not a complaining. It's a question. Otherwise how I'm suppose to know what exact versions should be used for stable app work?

If you feel that this is "Such nonsense", by all means, use some other library for your needs.

Sorry for that. No offense here, man. You're project is good, but I only wanted to give couple of tips about how to document projects for people.

f1am3d commented 5 years ago

@titu1994 Well, after installing requirements with pip install -r requirements.txt inside the same conda environment, that I used before, everything started to work.