NVlabs / stylegan2-ada

StyleGAN2 with adaptive discriminator augmentation (ADA) - Official TensorFlow implementation
https://arxiv.org/abs/2006.06676
Other
1.8k stars 500 forks source link

ValueError: Too many dimensions #75

Open ramnoob opened 3 years ago

ramnoob commented 3 years ago

Thx great GAN! Run python train.py, I get an error. "ValueError: Too many dimensions: 3 > 2."

Exporting sample images... Traceback (most recent call last): File "train.py", line 561, in <module> main() File "train.py", line 553, in main run_training(**vars(args)) File "train.py", line 451, in run_training training_loop.training_loop(**training_options) File "C:\Users\ramwi\Desktop\sGANada\training\training_loop.py", line 136, in training_loop save_image_grid(grid_reals, os.path.join(run_dir, 'reals.png'), drange=[0,255], grid_size=grid_size) File "C:\Users\ramwi\Desktop\sGANada\training\training_loop.py", line 77, in save_image_grid PIL.Image.fromarray(images, {3: 'RGB', 1: 'L'}[C]).save(filename) File "C:\Users\ramwi\anaconda3\envs\styleGAN2\lib\site-packages\PIL\Image.py", line 2776, in fromarray raise ValueError(f"Too many dimensions: {ndim} > {ndmax}.") ValueError: Too many dimensions: 3 > 2.

I expected the image size to be too large and fixed it, but 64x64size does not solve the problem! Is there any other way to solve this problem?

robgon-art commented 3 years ago

@ramnoob,

I'm seeing the same problem. Are you using RGB or grayscale images? I'm using grayscale...

robgon-art commented 3 years ago

Yep, there's a bug in training_loop.c for training with grayscale images.

Here's a temporary fix: 76| # images = images.reshape(gh * H, gw * W, C) 77| images = images.reshape(gh * H, gw * W)

This works now for grayscale but will break RGB, so the shape needs to be set conditionally...

robgon-art commented 3 years ago

FYI: I fixed it for real here: https://github.com/robgon-art/stylegan2-ada/tree/fix_grayscale

Needs testing...