Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Color conversion #343

Open
AzazelHD opened this issue Jun 26, 2021 · 0 comments
Open

Color conversion #343

AzazelHD opened this issue Jun 26, 2021 · 0 comments
Labels
image Related to images

Comments

@AzazelHD
Copy link

AzazelHD commented Jun 26, 2021

Hey guys. I have recently gone into a ML project and using ImageDataGenerator class to augment my image dataset

However, I think the color conversion done in BatchFromFilesMixin, when calling load_img from .utils should not be done there, but on ImageDataGenerator class.

The reasons I have is people, like me in this case, may want to write their own custom transformations for images. I know there is the preprocessing_function argument, but that doesn't solve all problems.

Check the following:

My dataset has both rgb and rgba images. In my case, I wanna add a random background to png images. I can't using ImageDataGenerator class due to the color conversion. And I can't also set color_mode to rgba because then it I won't know which images hadn't background at the beggining.

The easiest way to fix this for my particular case is removing the lines from load_img where the color conversion is done, so the image ImageDataGenerator class recieves, is the image as it is. If it has 1 channel, then 1 channel. If it has 3, then 3, and if it has 4, then 4.

Please correct me if I am wrong and also please if you know another way that allows me making this kind of augmentation

I am aware that if keras doesn't control the channels on ImageDataGenerator class, then the user must take care of it, so it matches the input layer shape of the model

@AzazelHD AzazelHD added the image Related to images label Jun 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
image Related to images
Projects
None yet
Development

No branches or pull requests

1 participant