kuijiang94 / EEGAN

Edge Enhanced GAN For Remote Sensing Image Super-Resolution
92 stars 17 forks source link

AttributeError: 'builtin_function_or_method' object has no attribute 'get_shape' #5

Open themousepotato opened 4 years ago

themousepotato commented 4 years ago

Getting the following error on executing test.py:

WARNING:tensorflow:From test.py:17: The name tf.reset_default_graph is deprecated. Please use tf.compat.v1.reset_default_graph instead.

WARNING:tensorflow:From test.py:20: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

(720, 720, 3)
(1, 720, 720, 3)
Traceback (most recent call last):
  File "test.py", line 53, in <module>
    model = Model(x, is_training, 1)#16
  File "../TESTGAN.py", line 14, in __init__
    n,w,h,c = input.get_shape().as_list()
AttributeError: 'builtin_function_or_method' object has no attribute 'get_shape'

When I tried with tf.shape(input).as_list() instead of input.get_shape().as_list(), I got the following error:

WARNING:tensorflow:From test.py:17: The name tf.reset_default_graph is deprecated. Please use tf.compat.v1.reset_default_graph instead.

WARNING:tensorflow:From test.py:20: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

(720, 720, 3)
(1, 720, 720, 3)
Traceback (most recent call last):
  File "/home/navaneeth/anaconda3/envs/image-sr-tf/lib/python3.6/site-packages/tensorflow_core/python/framework/tensor_util.py", line 541, in make_tensor_proto
    str_values = [compat.as_bytes(x) for x in proto_values]
  File "/home/navaneeth/anaconda3/envs/image-sr-tf/lib/python3.6/site-packages/tensorflow_core/python/framework/tensor_util.py", line 541, in <listcomp>
    str_values = [compat.as_bytes(x) for x in proto_values]
  File "/home/navaneeth/anaconda3/envs/image-sr-tf/lib/python3.6/site-packages/tensorflow_core/python/util/compat.py", line 71, in as_bytes
    (bytes_or_text,))
TypeError: Expected binary or unicode string, got <built-in function input>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 53, in <module>
    model = Model(x, is_training, 1)#16
  File "../TESTGAN.py", line 14, in __init__
    n,w,h,c = tf.shape(input).as_list()
  File "/home/navaneeth/anaconda3/envs/image-sr-tf/lib/python3.6/site-packages/tensorflow_core/python/ops/array_ops.py", line 447, in shape
    return shape_internal(input, name, optimize=True, out_type=out_type)
  File "/home/navaneeth/anaconda3/envs/image-sr-tf/lib/python3.6/site-packages/tensorflow_core/python/ops/array_ops.py", line 471, in shape_internal
    input_tensor = ops.convert_to_tensor(input)
  File "/home/navaneeth/anaconda3/envs/image-sr-tf/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 1184, in convert_to_tensor
    return convert_to_tensor_v2(value, dtype, preferred_dtype, name)
  File "/home/navaneeth/anaconda3/envs/image-sr-tf/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 1242, in convert_to_tensor_v2
    as_ref=False)
  File "/home/navaneeth/anaconda3/envs/image-sr-tf/lib/python3.6/site-packages/tensorflow_core/python/framework/ops.py", line 1297, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/home/navaneeth/anaconda3/envs/image-sr-tf/lib/python3.6/site-packages/tensorflow_core/python/framework/constant_op.py", line 286, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/home/navaneeth/anaconda3/envs/image-sr-tf/lib/python3.6/site-packages/tensorflow_core/python/framework/constant_op.py", line 227, in constant
    allow_broadcast=True)
  File "/home/navaneeth/anaconda3/envs/image-sr-tf/lib/python3.6/site-packages/tensorflow_core/python/framework/constant_op.py", line 265, in _constant_impl
    allow_broadcast=allow_broadcast))
  File "/home/navaneeth/anaconda3/envs/image-sr-tf/lib/python3.6/site-packages/tensorflow_core/python/framework/tensor_util.py", line 545, in make_tensor_proto
    "supported type." % (type(values), values))
TypeError: Failed to convert object of type <class 'builtin_function_or_method'> to Tensor. Contents: <built-in function input>. Consider casting elements to a supported type.

Could you please suggest a workaround?

QunixZ commented 3 years ago

I met the same problem. Did you found the solution?

paugalles commented 3 years ago

This worked for me: In Model class within TESTGAN.py change the 14 line to n,w,h,c = x.get_shape().as_list() Then also change the words input to input_x or similar