Repository navigation
Add decode_image Op - #4222
Add decode_image Op#4222
Conversation
|
Can one of the admins verify this patch? |
| try_recover_truncated=None, acceptable_fraction=None, | ||
| name=None): | ||
| """Detects whether an image is a JPEG or PNG and decodes it to a uint8 tensor | ||
|
|
There was a problem hiding this comment.
Need to add more documentation here.
|
The |
|
I'm assuming that since this is still a WIP we should hold off on reviewing and testing it. Let me know if that isn't the case. |
|
@danmane That's correct. The current code works if you load the bytes of a file ahead of time, but would throw an error if you passed in code from a function like The current game plan is to write a Thanks! |
|
Any updates on this? |
|
@rohan100jain Waiting for feedback on #4338: I can close this in the meantime if you'd prefer. |
b70469d to
2f43274
Compare
|
@rohan100jain @danmane -
|
|
Thanks @samjabrahams ! Ping us when you think this is ready for a final review. |
9c9d7f8 to
d0e300c
Compare
|
@vrv ready for review! Couple of judgement calls:
|
|
@girving let me know if you have time to look at this. I worry that the variable shape output of this convenience op will make it inconvenient :), but maybe it'll be alright. Also, it might make sense to think about how to pass the options to decode_image in a better way -- otherwise the op's arguments are going to keep increasing to account for every image option that is added. |
|
The different shaped output definitely seems a bit clunky. Couple options (which may or may not be any less clunky):
For the growing number of parameters: I could use |
|
I can look at it, but could we squash it before the initial review? |
ff97246 to
dc4bf87
Compare
|
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
|
Jenkins, test this please. |
|
@mrry: The newly added |
|
Looks like it's a path issue: Edit: it probably isn't this, but I'll keep in the |
|
I assume it's because the working directory isn't what the test expects. (It looks like the similar code As a quick workaround, you might try adding |
* Update decode_image to use tf.substr * Update JPEG magic numbers * Add GIF functionality * Add GIF tests, documentation * Rearrange imports to be alphabetical
* Tests now use files in tensorflow/core/lib * decode_image now uses `cond` operations instead of a `case` * There is now only one substr Op for the header of the image contents It's not clean yet- we're still getting errors- just want to push this before I start making more changes.
337e0f6 to
30a964b
Compare
|
Jenkins, test this please. |
|
May need to rerun- the GPU test had an aneurysm when trying to |
|
Jenkins, test this please. |
|
@zffchen78 The Linux GPU build has twice failed during git fetch. Do you know what might be going wrong? |
|
The fact that it returns different tensors shapes based on the file format is not the 'usual' tensoflow way. |
|
@Mistobaan What fixed shape do the other image decode functions return? |
|
Right now |
|
Jenkins, test this please. |
|
@Mistobaan you can always
|
|
I'd prefer to either leave it as is or automatically squeeze the first dimension of the gif if it's a single frame (unfortunately that requires another |
|
If we want to add the optional squeeze to gif I think it can be done in a second pass. I'm going to merge for now. |
For #4009: Automatically detects whether the bytes passed in are JPEG, PNG, or neither and returns a
decode_jpegop,decode_pngop, or ValueError respectively.Before merging, need to hard-code the
imghdr.what()function, whose source is available as pure Python