tensorflow / models

Models and examples built with TensorFlow
Other
77.23k stars 45.75k forks source link

How to train the network for grayscale images? #4615

Closed jekasores closed 6 years ago

jekasores commented 6 years ago

Hi fellows!

I am trying to give a new input and annotation image for the code available in the turorial: http://warmspringwinds.github.io/tensorflow/tf-slim/2016/12/18/image-segmentation-with-tensorflow-using-cnns-and-conditional-random-fields/. My input image is in grayscale (250 x 180 px) and I normalized the annotation (250 x 180 px) between [0 1]. However, I can't make my code work for the new images. I am getting the following error:

182 loss, summary_string = sess.run([cross_entropy_sum, merged_summary_op],

--> 183 feed_dict=feed_dict_to_use)

InvalidArgumentError: logits and labels must be broadcastable: logits_size=[21504,2] labels_size=[29500,2] [[Node: softmax_cross_entropy_with_logits_sg = SoftmaxCrossEntropyWithLogits[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](softmax_cross_entropy_with_logits_sg/Reshape, softmax_cross_entropy_with_logits_sg/Reshape_1)]]

Can somebody help me? I am attaching the input image (2) and its annotation (1). norm-test-pdb001lm

test-mdb001lm

tensorflowbutler commented 6 years ago

Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks. What is the top-level directory of the model you are using Have I written custom code OS Platform and Distribution TensorFlow installed from TensorFlow version Bazel version CUDA/cuDNN version GPU model and memory Exact command to reproduce

hendaboudegga commented 6 years ago

hello, i work for a project of semantic segmentation of retinal blood vessels with tensorflow with the model mobileUnet and i have the same error as jekasores.

InvalidArgumentError (see above for traceback): logits and labels must be broadcastable: logits_size=[82944,2] labels_size=[90000,2] [[Node: softmax_cross_entropy_with_logits_sg = SoftmaxCrossEntropyWithLogits[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](softmax_cross_entropy_with_logits_sg/Reshape, softmax_cross_entropy_with_logits_sg/Reshape_1)]]

the input image is RGB with 300*300 size and the output is a binary image with the same size as input.

here is my folowing code: net_input = tf.placeholder(tf.float32,shape=[None,None,None,3]) net_output = tf.placeholder(tf.float32,shape=[None,None,None,num_classes]) losses = tf.nn.softmax_cross_entropy_with_logits(logits=network, labels=net_output) cost = tf.reduce_mean(losses)# define cost of our neural network

cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(logits=prediction, labels=y))

opt = tf.train.AdamOptimizer(args.learning_rate).minimize(cost) init = tf.initialize_allvariables() ,current=sess.run([opt,cost],feed_dict={net_input:input_image_batch, net_output:segmented_image_batch})

i am working on hp machine with intel core i7 3770 CPU, 3.4 GHZ with RAM 8Go. the OS installed is wind 8.1 Tensorflow version is 1.10.0. the cuda version is 9.0 and cuDNN is 7.0. the GPU NVIDIA Geforce GT 520.

Can someone help me, thanks.

karmel commented 6 years ago

It looks like there is a mismatch between the set of allowed labels and the output shape of your final layer. That said, this question is better asked on StackOverflow since it is not a bug or feature request. There is also a larger community that reads questions there.

If you think we've misinterpreted a bug, please comment again with a clear explanation, as well as all of the information requested in the issue template. Thanks!