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.26k stars 481 forks source link

Error in line 320 INetwork.py (Expected int32, got variable) #39

Closed wottpal closed 7 years ago

wottpal commented 7 years ago

I am using the latest versions of tensorflow-gpu (0.12.1) and keras (2.0.5) but don't get your scripts to work properly :(

This is the output I am getting (arguments generated by your script-helper):

python INetwork.py "C:\Users\wottpal\Desktop\Neural Style Transfer\Images\uniturm_jena.jpg" "C:\Users\wottpal\Desktop\Neural Style Transfer\Images\cathedral-of-socialism-1919.jpg" "" --image_size 400 --content_weight 0.025 --style_weight 1.0 --total_variation_weight 8.5E-05 --style_scale 1 --num_iter 10 --rescale_image "False" --rescale_method "bicubic" --maintain_aspect_ratio "True" --content_layer "conv5_2" --init_image "content" --pool_type "max" --preserve_color "False" --min_improvement 0 --model "vgg16" --content_loss_type 0
Using TensorFlow backend.
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cublas64_80.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cudnn64_5.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cufft64_80.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library nvcuda.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library curand64_80.dll locally
Traceback (most recent call last):
  File "INetwork.py", line 320, in <module>
    input_tensor = K.concatenate(image_tensors, axis=0)
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\keras\backend\tensorflow_backend.py", line 1721, in concatenate
    return tf.concat([to_dense(x) for x in tensors], axis)
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1075, in concat
    dtype=dtypes.int32).get_shape(
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 669, in convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\constant_op.py", line 176, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\constant_op.py", line 165, in constant
    tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 367, in make_tensor_proto
    _AssertCompatible(values, dtype)
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 302, in _AssertCompatible
    (dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected int32, got <tensorflow.python.ops.variables.Variable object at 0x00000279CD505A90> of type 'Variable' instead.
titu1994 commented 7 years ago

You have to provide an absolute path to the destination. It can be a path to your directory itself, but it must be an absolute path.

To set it, select a directory and file name without it's extension using the Destination Path button.

wottpal commented 7 years ago

I've tried this but getting the same result? What do I miss?

C:\Users\wottpal\Desktop\Neural Style Transfer\Script>python INetwork.py "C:\Users\wottpal\Desktop\Neural Style Transfer\Images\uniturm_jena.jpg" "C:\Users\wottpal\Desktop\Neural Style Transfer\Images\cathedral-of-socialism-1919.jpg" "C:\Users\wottpal\Desktop\Neural Style Transfer\Images\test" --image_size 400 --content_weight 0.025 --style_weight 1.0 --total_variation_weight 8.5E-05 --style_scale 1 --num_iter 10 --rescale_image "False" --rescale_method "bicubic" --maintain_aspect_ratio "True" --content_layer "conv5_2" --init_image "content" --pool_type "max" --preserve_color "False" --min_improvement 0 --model "vgg16" --content_loss_type 0
Using TensorFlow backend.
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cublas64_80.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cudnn64_5.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cufft64_80.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library nvcuda.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library curand64_80.dll locally
Traceback (most recent call last):
  File "INetwork.py", line 320, in <module>
    input_tensor = K.concatenate(image_tensors, axis=0)
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\keras\backend\tensorflow_backend.py", line 1721, in concatenate
    return tf.concat([to_dense(x) for x in tensors], axis)
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\ops\array_ops.py", line 1075, in concat
    dtype=dtypes.int32).get_shape(
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 669, in convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\constant_op.py", line 176, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\constant_op.py", line 165, in constant
    tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 367, in make_tensor_proto
    _AssertCompatible(values, dtype)
  File "C:\Users\wottpal\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\framework\tensor_util.py", line 302, in _AssertCompatible
    (dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected int32, got <tensorflow.python.ops.variables.Variable object at 0x000002499F954A90> of type 'Variable' instead.

Same with "C:\Users\wottpal\Desktop\Neural Style Transfer\Images\" and "C:\Users\wottpal\Desktop\Neural Style Transfer\Images" as destination.