jakeret / tf_unet

Generic U-Net Tensorflow implementation for image segmentation
GNU General Public License v3.0
1.9k stars 748 forks source link

error with crop_and_concat and tf.slice #172

Closed neurmch closed 5 years ago

neurmch commented 6 years ago

InvalidArgumentError (see above for traceback): Expected begin[2] in [0, 283], but got -1 [[Node: Slice_1 = Slice[Index=DT_INT32, T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](Relu_3, Slice_1/begin, Slice_1/size)]]

I don't know what's the trouble with my dataset.

def crop_and_concat(x1,x2): x1_shape = tf.shape(x1) x2_shape = tf.shape(x2)

offsets for the top left corner of the crop

offsets = [0, (x1_shape[1] - x2_shape[1]) // 2, (x1_shape[2] - x2_shape[2]) // 2, 0]
size = [-1, x2_shape[1], x2_shape[2], -1]
x1_crop = tf.slice(x1, offsets, size)
return tf.concat([x1_crop, x2], 3)   
neurmch commented 6 years ago

this error is solved,but another error occurs.when I use retinal database ,ValueError: could not broadcast input array from shape (584,565,3) into shape (584,565).

jakeret commented 6 years ago

The code has a bug which occurs if one the number of pixels of input image (nx or ny) has an odd number

jakeret commented 6 years ago

In the second case it seems that an RGB image is being loaded into gray scale data

zyl200846 commented 5 years ago

this error is solved,but another error occurs.when I use retinal database ,ValueError: could not broadcast input array from shape (584,565,3) into shape (584,565).

@neurmch hello, may I know how do you fix the problem you mentioned above?