fix: preserve image alpha in distributed collection

This commit is contained in:
Robert Wojciechowski
2026-10-10 05:59:52 +00:00
parent 32ac027e0e
commit 213d491f06
3 changed files with 280 additions and 6 deletions
+3 -1
View File
@@ -125,7 +125,9 @@ def _decode_canonical_png_tensor(image_payload):
try:
with Image.open(io.BytesIO(png_bytes)) as img:
img = img.convert("RGB")
# PNG callbacks must retain alpha just like local IMAGE tensors.
has_alpha = "A" in img.getbands() or "transparency" in img.info
img = img.convert("RGBA" if has_alpha else "RGB")
tensor = pil_to_tensor(img)
return ensure_contiguous(tensor)
except Exception as exc: