yenchenlin / pix2pix-tensorflow

TensorFlow implementation of "Image-to-Image Translation Using Conditional Adversarial Networks".
MIT License
939 stars 300 forks source link

Change image loading for grayscale support #34

Open joschkazj opened 6 years ago

joschkazj commented 6 years ago

I tried training the model for grayscale input and was having similar issues as mentioned in #12, setting input_c_dim=1 and output_c_dim=1 did not work for me

model = pix2pix(sess, image_size=args.fine_size, batch_size=args.batch_size,
                        output_size=args.fine_size, dataset_name=args.dataset_name,
                        checkpoint_dir=args.checkpoint_dir, sample_dir=args.sample_dir,
                        input_c_dim=1, output_c_dim=1)

After investigating the issue, I changed the image loading function which made the optional reshaping

if (self.is_grayscale):
    batch_images = np.array(batch).astype(np.float32)[:, :, :, None]
else:
    batch_images = np.array(batch).astype(np.float32)

obsolete.