Optional 16‑bit sample logging (true 16‑bit PNGs, TB previews stay 8‑bit) for unconditional example #12602
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.
Related to #12596
Purpose
Allow users to optionally export 16-bit evaluation samples (PNG) from the unconditional training example while keeping TensorBoard previews 8-bit and avoiding silent dtype conversions.
Changes
_prepare_sample_images: clamps/scales NHWC float [0,1] to uint8/uint16 arrays; also builds an 8-bit preview for TensorBoard._log_sample_images: logs previews to TensorBoard and uploads true 16-bit PNGs to W&B via file paths.--image_bit_depthwith choices{8, 16}(default8). Explicit guards raiseValueErrorfor unsupported depths/dtypes.BytesIOis avoided becausewandb.Imagedoes not reliably accept it."RGB;16B"/"RGBA;16B"and byteswap to satisfy Pillow’s big-endian expectation.global_step(matches scalar metrics).Behavior/UX
--image_bit_depth 16is set:uint8/uint16or are in an unsupported layout.Limitations (intentional to keep scope small)
torchvisiontypically brings Pillow in.Notes for reviewers
";16B"and byteswap.Follow-ups (out of scope here)
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?