Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is inspired by #21, which wants a way to easily add a PNG as an image summary. The examples demonstrate how to do this.
FWIW I think this example is a very reasonable feature addition:
The rationale for closing #21 was that this sort of encoding is best left to the user. I disagree based on the following:
tensorboardX already uses a PIL.Image instance to encode a numpy array to PNG bytes
If given a PIL.Image instance, tensorboardX can skip the step of generating one from the numpy array (this is shown in the example)
If given a string value as the second argument to
writer.add_image
, tensorboardX can trivially callPIL.Image.open
and use that image instance to encode the PNG bytes for the summaryThis PR is valid as a stand-alone example, but I also hope it makes the case to support the following enhancements to
writer.add_image
:PIL.Image.open
I'm happy to implement those changes in another PR but I wanted to start this discussion with an example (useful in its own right).