Skip to content

Image Preprocessing corrupts some greyscale images #10437

Closed
@alexzubiaga

Description

@alexzubiaga

While training an Inception Model with a mix of color and greyscale images I've noticed that some of the greyscale images were loosing most of the details when loading them with flow_from_directory.

The cause is the RGB conversion from Pillow used in load_img as described in this issue Pillow-2574

In my case the suggested workaround fixed the conversion.

This is the code I've used to handle the RGB conversion:

if img.mode != 'RGB':
    if img.mode == 'I':
        from PIL import ImageMath
        img = ImageMath.eval('im/256', {'im': img})
    img = img.convert('RGB')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions