LinHungShi / GCNetwork

118 stars 39 forks source link

DataType error in createGCNetwork #14

Open ChiFang opened 7 years ago

ChiFang commented 7 years ago

Issue Description: createGCNetwork throws an TypeError

my clone version(the newest): 684ad7ff4697a641601f583f0f3f6bcae25f7506

my cmd: python3 test.py -data data/test_256 -pspath result (the 'test_256' is the folder where i put my test pictures in 'left' and 'right',such as"./data/test/left/left_0.png"and "./data/test/right/right_0.png")

note:

  1. I find that you disable the "test_params.json" in parseArguments
  2. my test image is 256 x 256 3 channel color image

Error Output:

Use shared weight for first stage Traceback (most recent call last): File "test.py", line 62, in Predict() File "test.py", line 44, in Predict model = createGCNetwork(hp, tp, True) File "src/gcnetwork.py", line 166, in createGCNetwork cv = Lambda(getCostVolume, arguments = {'max_d':d/2}, output_shape = (d/2, None, None, num_filters * 2))(unifeatures) File "/usr/local/lib/python3.5/dist-packages/keras/engine/topology.py", line 602, in call output = self.call(inputs, kwargs) File "/usr/local/lib/python3.5/dist-packages/keras/layers/core.py", line 650, in call return self.function(inputs, arguments) File "src/gcnetwork.py", line 52, in getCostVolume right_tensor = K.spatial_2d_padding(right_tensor, padding=((0, 0), (max_d, 0))) File "/usr/local/lib/python3.5/dist-packages/keras/backend/tensorflow_backend.py", line 2020, in spatial_2d_padding return tf.pad(x, pattern) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/array_ops.py", line 1679, in pad return gen_array_ops._pad(tensor, paddings, name=name) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 1989, in _pad name=name) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py", line 589, in apply_op param_name=input_name) File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/framework/op_def_library.py", line 60, in _SatisfiesTypeConstraint ", ".join(dtypes.as_dtype(x).name for x in allowed_list))) TypeError: Value passed to parameter 'paddings' has DataType float32 not in list of allowed values: int32, int64

how can I solve it to finish the predict flow? thanks for any suggestion~~~

ChiFang commented 7 years ago

I find the root cause comes from cv = Lambda(_getCostVolume_, arguments = {'max_d':d/2}, output_shape = (d/2, None, None, num_filters * 2))(unifeatures)

the d/2 will be float and it make getCostVolume crash at right_tensor = K.spatial_2d_padding(right_tensor, padding=((0, 0), (max_d, 0)))

add max_d = int(max_d) at the top of getCostVolume will fix it