Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-RGB images with --img_channels option #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mdraw
Copy link

@mdraw mdraw commented May 31, 2019

The expected number of image channels can now be expressed through the
--img_channels option. This option changes the generator and
discriminator architectures to generate/expect the given channel count
and changes the data loading mechanism to expect and - if necessary -
convert images to have this number of channels.

  • Fixes the issue with occasional grayscale images in RGB photo data sets
    reported in I have met this error when run train.py ... #5 because if --img_channels=3 (default), grayscale images
    are automatically converted to RGB in preprocessing.
  • Adds support for training with grayscale images, as requested in I have met this error when run train.py ... #5.
  • Should make it easier to implement training with multi-channel images that
    have more than 3 channels (which I'm planning to try soon).
  • Enables training with RGB data sets in grayscale mode by simply setting
    --img_channels=1.

Disclaimer: I have not tested my changes with the usual data sets for image synthesis. I have only tried it with two small toy data sets: one of RGB images and one of grayscale images. My test trainings run without errors and the generated data visualization works, but my trainings don't converge yet and probably need some hyperparameter tuning (the discriminator loss is at 0 very often).

The expected number of image channels can now be expressed through the
"--img_channels" option. This option changes the generator and
discriminator architectures to generate/expect the given channel count
and changes the data loading mechanism to expect and - if necessary -
convert images to have this number of channels.

- Fixes the issue with occasional grayscale images in RGB photo data sets
  reported in akanimax#5 because if --img_channels=3 (default), grayscale images
  are automatically converted to RGB in preprocessing.
- Adds support for training with grayscale images, as requested in akanimax#5.
- Makes it easier to implement training with multi-channel images that
  have more than 3 channels (which I'm planning to try soon).
- Enables training with RGB data sets in grayscale mode by simply setting
  --img_channels=1.
@akanimax
Copy link
Owner

akanimax commented Jun 2, 2019

@mdraw, Thanks a lot for the PR.
I'll review it in a couple of days. Thanks again!

Best regards,
@akanimax

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants