-
Notifications
You must be signed in to change notification settings - Fork 74k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
decode_image return tensor without shape in python #9356
Comments
The @cwhipkey any comment here? |
I think the issue is that in the decode_image cond, one branch leads to decode_gif. decode_gif returns a 4-d tensor: [num_frames, height, width, channels], which is not the same as the 3-d tensor returned by decode_png and decode_jpeg. One possible fix would be to make decode_gif have an attribute controlling whether to handle animated gifs ,and use that in decode_image? (possibly also with an option? It's not clear to me someone would want to use decode_image with a mix of animated and non-animated images - so maybe just changing it would be fine?). +raingo and wicke |
We could definitely add "frame=None" which is without effect for png and jpg, but for gif will return all frames if None, of the given frame number if not None and the gif is animated. This would work for other animated formats if those become available. If frame != None we can set the rank to [None, None, None], maybe even [None, None, 3] -- not sure that'll help. |
@martinwicke I can send PR to add the
It makes the least changes to the code, and add some flexibility. Not sure if that is the best way to do it. |
I think the right way to fix this is to make the image resizing machinery not need static shape. I'll take a look at how difficult that is. |
Having decode_image sometimes return 4-d and sometimes return 3-d does not seem useful though - should it always just return frame 0 of a gif? (this was a change in behavior of decode_image when animated gif support was added) |
@cwhipkey It was a backwards incompatible change? |
No, I don't think so. DecodeGif always returned 4D tensor. decode_image in python was added after that, and always returned a 4D for GIF and 3D for png or jpg. So nm on what I wrote earlier about having it always return frame 0. |
CC: @girving |
I'm going to restrict my current change to unify |
|
thanks |
* Mostly implemented new data pipeline. * Changed DatasetReader record holding structure slightly. * Fixed using wrong value for iteration. * Some possibly working changes to reader. * May have fixed input problem. * Actually made the change intended in last commit. * Fixed minor bugs. * Fixed bug with annotation checking. * Removed static. * Fixed map bug. * Reverted lambda in TFRreader after discovering cause of bug. * Check for no annotation. * Might have fixed bug. * Fixed references to dataset. * Fixed self.self * Readded code accidentally removed previously, changed dimension to axi in annotation_pred = tf.argmax(...) because the dimension argument will be depricated in the future. * Changed call to next to call to sess.run. * Added resizing. * Fixed decoding based on tf bug tensorflow/tensorflow#9356. * Changed iteration getting method. * Fixed not reading in annotations and other minor fixes. * Actually fixed iterator getting in FCN.py * Train ops now set to work with tensors rather than placeholders. * Added trainable_var above saver. * Revert "Added trainable_var above saver." This reverts commit 6011e0b. * Revert "Train ops now set to work with tensors rather than placeholders." This reverts commit 6f12d7d. * Should work now using placeholders. * Might have fixed annotation shape. * Fixed _augment_image where annotation image was set to the same as image. * Added extra dimension to annotation. * Some minor changes to TFReader. * Fixed predict with new dataset workflow. * Slight change to TFRreader. * Fixed problem with SingleDataset. * Fixed referencing dataset rather than DatasetReader. * Changed Dataset Reader to also output filename. * Fixed multiple runs of predict_names. * Added Jupyter Notebook for viewing results * Fixed bug with not returning 'name' if image augmentation is off
* put training and validation loss in the same graph * Renamed file and changed read in details. * Changed read in details and pickle filename. * Fixed hardcoded data dir. * Change no. classes. * Change to see if it fixes something * removed log files from git * Added method for predictions. * Added printed messages to predict. * Fixed print * Fixed format string statements. * Changed resize to True for predict. * Fixed filename for saving * Added forgotten squeeze on pred in predict code. * Create predictions folder if it doesn't exist. * Slight updates to dropout and BatchDatsetReader * Added image augmentation. * Fixed usage of wrong name of FLAGS.dropout_keep_prob. * Fixed BatchDatasetReader and changed dropout_keep_value to dropout in FLAGS. * Fixed bug in BatchDatasetReader * Added back in an accidentally deleted line. * Fixed empty list/None check which is incompatible with Numpy. * Fixed call of np.concatenate * removed expand_dims for annotations. * Properly check if annotation_file is not None. * New reader (#2) * Mostly implemented new data pipeline. * Changed DatasetReader record holding structure slightly. * Fixed using wrong value for iteration. * Some possibly working changes to reader. * May have fixed input problem. * Actually made the change intended in last commit. * Fixed minor bugs. * Fixed bug with annotation checking. * Removed static. * Fixed map bug. * Reverted lambda in TFRreader after discovering cause of bug. * Check for no annotation. * Might have fixed bug. * Fixed references to dataset. * Fixed self.self * Readded code accidentally removed previously, changed dimension to axi in annotation_pred = tf.argmax(...) because the dimension argument will be depricated in the future. * Changed call to next to call to sess.run. * Added resizing. * Fixed decoding based on tf bug tensorflow/tensorflow#9356. * Changed iteration getting method. * Fixed not reading in annotations and other minor fixes. * Actually fixed iterator getting in FCN.py * Train ops now set to work with tensors rather than placeholders. * Added trainable_var above saver. * Revert "Added trainable_var above saver." This reverts commit 6011e0b. * Revert "Train ops now set to work with tensors rather than placeholders." This reverts commit 6f12d7d. * Should work now using placeholders. * Might have fixed annotation shape. * Fixed _augment_image where annotation image was set to the same as image. * Added extra dimension to annotation. * Some minor changes to TFReader. * Fixed predict with new dataset workflow. * Slight change to TFRreader. * Fixed problem with SingleDataset. * Fixed referencing dataset rather than DatasetReader. * Changed Dataset Reader to also output filename. * Fixed multiple runs of predict_names. * Added Jupyter Notebook for viewing results * Fixed bug with not returning 'name' if image augmentation is off
* put training and validation loss in the same graph * Renamed file and changed read in details. * Changed read in details and pickle filename. * Fixed hardcoded data dir. * Change no. classes. * Change to see if it fixes something * removed log files from git * Added method for predictions. * Added printed messages to predict. * Fixed print * Fixed format string statements. * Changed resize to True for predict. * Fixed filename for saving * Added forgotten squeeze on pred in predict code. * Create predictions folder if it doesn't exist. * Slight updates to dropout and BatchDatsetReader * Added image augmentation. * Fixed usage of wrong name of FLAGS.dropout_keep_prob. * Fixed BatchDatasetReader and changed dropout_keep_value to dropout in FLAGS. * Fixed bug in BatchDatasetReader * Added back in an accidentally deleted line. * Fixed empty list/None check which is incompatible with Numpy. * Fixed call of np.concatenate * removed expand_dims for annotations. * Properly check if annotation_file is not None. * Mostly implemented new data pipeline. * Changed DatasetReader record holding structure slightly. * Fixed using wrong value for iteration. * Some possibly working changes to reader. * May have fixed input problem. * Actually made the change intended in last commit. * Fixed minor bugs. * Fixed bug with annotation checking. * Removed static. * Fixed map bug. * Reverted lambda in TFRreader after discovering cause of bug. * Check for no annotation. * Might have fixed bug. * Fixed references to dataset. * Fixed self.self * Readded code accidentally removed previously, changed dimension to axi in annotation_pred = tf.argmax(...) because the dimension argument will be depricated in the future. * Changed call to next to call to sess.run. * Added resizing. * Fixed decoding based on tf bug tensorflow/tensorflow#9356. * Changed iteration getting method. * Fixed not reading in annotations and other minor fixes. * Actually fixed iterator getting in FCN.py * Train ops now set to work with tensors rather than placeholders. * Added trainable_var above saver. * Revert "Added trainable_var above saver." This reverts commit 6011e0b. * Revert "Train ops now set to work with tensors rather than placeholders." This reverts commit 6f12d7d. * Should work now using placeholders. * Might have fixed annotation shape. * Fixed _augment_image where annotation image was set to the same as image. * Added extra dimension to annotation. * Some minor changes to TFReader. * Fixed predict with new dataset workflow. * Slight change to TFRreader. * Fixed problem with SingleDataset. * Fixed referencing dataset rather than DatasetReader. * Changed Dataset Reader to also output filename. * Fixed multiple runs of predict_names. * Added Jupyter Notebook for viewing results * Update current FCN code
how to judge the format of the image ? |
I found the solution
add this to the top of your code. or
|
This worked for me. Thanks tf.enable_eager_execution() |
System Information
Describe the problem clearly
When I decode a jpeg file to a tensor with decode_jpeg, the code ran normally.
but if I use decode_image instead of decode_jpeg for more compatibilities, It raised a ValueError as follow.
Is It a bug?
Thanks
Source Code / Logs
output :
The text was updated successfully, but these errors were encountered: