Skip to content

Commit 6f8ce5b

Browse files
committed
fixed Pillow RGB convertion for transform_image function
1 parent 988f324 commit 6f8ce5b

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def image_path() -> str:
2121
@pytest.fixture()
2222
def image_obj(image_path) -> Image:
2323
"""return a PIL image"""
24-
return Image.open(image_path).convert("RGB")
24+
return Image.open(image_path)
2525

2626

2727
@pytest.fixture()

utils/image.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def transform_image(
4848
transform_level: TransformationLevel = TransformationLevel.ALL,
4949
) -> torch.Tensor:
5050
"""Transform and normalize a PIL image into a torch tensor ranging values from 0 to 1"""
51+
img = img.convert("RGB")
5152

5253
image_tensor = v2.Compose(
5354
get_transformations_pipeline(width, height, transform_level)

0 commit comments

Comments
 (0)