Skip to content

Commit

Permalink
convert rgba to rgb (#1678)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebsmothers authored Sep 25, 2024
1 parent 645e041 commit e1c2fec
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions torchtune/models/clip/_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e1c2fec

Please sign in to comment.