Skip to content

Commit

Permalink
Convert all non-rgb images to rgb (#1976)
Browse files Browse the repository at this point in the history
  • Loading branch information
vancoykendall authored Nov 8, 2024
1 parent 6fd465e commit 41b504f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions torchtune/models/clip/_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,9 @@ 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":
if image.mode != "RGB":
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)

# Find the best canvas to fit the image without distortion
Expand Down

0 comments on commit 41b504f

Please sign in to comment.