Raj-08 / tensorflow-object-contour-detection

A tensorflow implementation of object-contour-detection with fully convolutional encoder decoder network
MIT License
107 stars 40 forks source link

Output Size #12

Open lalo-remo93 opened 5 years ago

lalo-remo93 commented 5 years ago

Hi Raj,

First of all, thank you so much for sharing your code, it is great!

Do you know what modifications are needed so that the output image has the same height and width as the input image?

I tried changing the crop size in eval.py but it caused some reshaping issues in the deconvolution layers. For instance, when trying to change the crop size from 480x480 to 500x375 I get this error:

Traceback (most recent call last): File "U:\Python36\site-packages\tensorflow\python\framework\ops.py", line 1551, in _create_c_op c_op = c_api.TF_FinishOperation(op_desc) tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot reshape a tensor with 758016 elements to shape [786432,1] (786432 elements) for 'unpool_3/Reshape_2' (op: 'Reshape') with input shapes: [1,63,47,256], [2] and with input tensors computed as partial shapes: input[1] = [786432,1].

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "U:\ManWin\My Documents\Dissertation\TensorFlow 2_0 Migration CNN\eval.py", line 52, in pred = build_model(norm_image) File "U:\ManWin\My Documents\Dissertation\TensorFlow 2_0 Migration CNN\model_contour.py", line 61, in build_model unpool_3 = unpool_with_argmax(bn_deconv4, ind=pool3_indices, name="unpool_3") File "U:\ManWin\My Documents\Dissertation\TensorFlow 2_0 Migration CNN\ops.py", line 94, in unpool_with_argmax b = tf.reshape(b, [flat_input_size, 1]) File "U:\Python36\site-packages\tensorflow\python\ops\gen_array_ops.py", line 9093, in reshape "Reshape", tensor=tensor, shape=shape, name=name) File "U:\Python36\site-packages\tensorflow\python\framework\op_def_library.py", line 788, in _apply_op_helper op_def=op_def) File "U:\Python36\site-packages\tensorflow\python\util\deprecation.py", line 507, in new_func return func(*args, **kwargs) File "U:\Python36\site-packages\tensorflow\python\framework\ops.py", line 3296, in create_op op_def=op_def) File "U:\Python36\site-packages\tensorflow\python\framework\ops.py", line 1714, in init control_input_ops) File "U:\Python36\site-packages\tensorflow\python\framework\ops.py", line 1554, in _create_c_op raise ValueError(str(e)) ValueError: Cannot reshape a tensor with 758016 elements to shape [786432,1] (786432 elements) for 'unpool_3/Reshape_2' (op: 'Reshape') with input shapes: [1,63,47,256], [2] and with input tensors computed as partial shapes: input[1] = [786432,1].

Thank you in advance!

KoljaStrohm commented 5 years ago

I think the crop size has to be dividable by 32 otherwise the output shape of the skip connections will not fit with the shape of there target layers.