Skip to content

Fix np.byte dtype in dataset_readers.py — breaks PIL with NumPy 2.x#1330

Open
i-am-mushfiq wants to merge 1 commit into
graphdeco-inria:mainfrom
i-am-mushfiq:fix/numpy-uint8-dataset-readers
Open

Fix np.byte dtype in dataset_readers.py — breaks PIL with NumPy 2.x#1330
i-am-mushfiq wants to merge 1 commit into
graphdeco-inria:mainfrom
i-am-mushfiq:fix/numpy-uint8-dataset-readers

Conversation

@i-am-mushfiq
Copy link
Copy Markdown

Problem

scene/dataset_readers.py uses dtype=np.byte when constructing an RGB image array:

image = Image.fromarray(np.array(arr*255.0, dtype=np.byte), "RGB")

np.byte is a signed int8 type. Image.fromarray() expects unsigned uint8 for RGB images. This raises:

TypeError: Cannot handle this data type: (1, 1, 3), |i1

This error surfaces on NumPy 2.x, which enforces stricter dtype checking. On NumPy 1.x the signed type was silently accepted but still technically incorrect (values above 127 would overflow to negative).

Fix

image = Image.fromarray(np.array(arr*255.0, dtype=np.uint8), "RGB")

One character change: np.bytenp.uint8.

Impact

Affects anyone loading Blender synthetic (NeRF format) datasets (readNerfSyntheticInfo) with images that have an alpha channel, when using NumPy 2.x.

🤖 Generated with Claude Code

Image.fromarray() requires unsigned uint8 for RGB images. np.byte is
signed int8, which raises "Cannot handle this data type: |i1" under
NumPy 2.x (and silently produces wrong colors on NumPy 1.x).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant