fix(image_processor): return uint16 from LDM3D rgblike_to_depthmap#14225
Open
sergioperezcheco wants to merge 1 commit into
Open
fix(image_processor): return uint16 from LDM3D rgblike_to_depthmap#14225sergioperezcheco wants to merge 1 commit into
sergioperezcheco wants to merge 1 commit into
Conversation
VaeImageProcessorLDM3D.rgblike_to_depthmap combines two 8-bit channels into a 16-bit depth value (high*256 + low), but then cast the result back to the 8-bit input dtype, truncating it. numpy_to_depth builds a mode='I;16' PIL image from that depth map, which raised 'buffer is not large enough' once any value exceeded 255. Return torch.uint16 / np.uint16 unconditionally, matching the function's purpose and the downstream I;16 consumer. Adds a regression test for both the numpy and torch branches plus the numpy_to_depth path. Fixes huggingface#14206
sergioperezcheco
force-pushed
the
fix/ldm3d-depthmap-dtype
branch
from
July 18, 2026 17:43
044f21a to
8b98c66
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
VaeImageProcessorLDM3D.rgblike_to_depthmap combines two 8-bit channels into a 16-bit depth value (high*256 + low) but then cast the result back to the 8-bit input dtype, truncating any value above 255. The downstream numpy_to_depth feeds that depth map into PIL Image.fromarray with mode="I;16", which raises "buffer is not large enough" because the buffer is sized for uint16 but the values got clamped.
This returns torch.uint16 / np.uint16 unconditionally, matching the function's documented purpose and its only consumer. The commented-out uint16 lines right above the old return already flagged this as known-but-unfinished. Introduced by #12546 (the NumPy 2.0 overflow fix).
Adds a regression test covering the numpy and torch branches of rgblike_to_depthmap plus the full numpy_to_depth -> I;16 PIL path. All tests in tests/others/test_image_processor.py pass and ruff is clean.
Fixes #14206