-
Notifications
You must be signed in to change notification settings - Fork 366
reading .png not working #220
Copy link
Copy link
Open
Description
Great work and thank you for putting the model and code open source!
If you read .png images into PIL, they might have either 3 or 4 channels, depending if they are transparent.
If a 4 channel .png-Image is used as input_images in:
results = pipeline(
prompt=instruction,
input_images=input_images,
I get an error.
To fix it, add .convert("RGB") after reading in the PIL-Image. e.g. in the preprocess-function.
def preprocess(input_image_path: List[str] = []) -> Tuple[str, str, List[Image.Image]]:
"""Preprocess the input images."""
# Process input images
input_images = []
if input_image_path:
if isinstance(input_image_path, str):
input_image_path = [input_image_path]
if len(input_image_path) == 1 and os.path.isdir(input_image_path[0]):
input_images = [Image.open(os.path.join(input_image_path[0], f)).convert("RGB")
for f in os.listdir(input_image_path[0])]
else:
input_images = [Image.open(path).convert("RGB") for path in input_image_path]
input_images = [ImageOps.exif_transpose(img) for img in input_images]
return input_images
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels