From e1c2fecca7cafc9c00c62b06f5d2ac2978b05739 Mon Sep 17 00:00:00 2001 From: ebsmothers Date: Wed, 25 Sep 2024 09:25:22 -0700 Subject: [PATCH] convert rgba to rgb (#1678) --- torchtune/models/clip/_transform.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/torchtune/models/clip/_transform.py b/torchtune/models/clip/_transform.py index c975898244..533d27c865 100644 --- a/torchtune/models/clip/_transform.py +++ b/torchtune/models/clip/_transform.py @@ -163,6 +163,8 @@ def __call__( assert isinstance(image, Image.Image), "Input image must be a PIL image." # Make image torch.tensor((3, H, W), dtype=dtype), 0<=values<=1 + if hasattr(image, "mode") and image.mode == "RGBA": + image = image.convert("RGB") image = F.to_image(image) image = F.grayscale_to_rgb_image(image) image = F.to_dtype(image, dtype=self.dtype, scale=True)