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

Grayscale images #93

Open
povolann opened this issue Mar 29, 2023 · 0 comments
Open

Grayscale images #93

povolann opened this issue Mar 29, 2023 · 0 comments

Comments

@povolann
Copy link

Hi, I am trying to use EG3D for grayscale images.
When I was using the original
image = image[:, :, np.newaxis] # HW => HWC
it didn't work for me. It gave me this error:

Exception has occurred: AssertionError
Wrong size for dimension 1: got 6, expected 2
  File "/home/anya/Programs/eg3d/eg3d/torch_utils/misc.py", line 97, in assert_shape
    raise AssertionError(f'Wrong size for dimension {idx}: got {size}, expected {ref_size}')
  File "/home/anya/Programs/eg3d/eg3d/training/networks_stylegan2.py", line 621, in forward
    misc.assert_shape(img, [None, self.img_channels, self.resolution, self.resolution]) # where does the img come from?
  File "/home/anya/Programs/eg3d/eg3d/training/dual_discriminator.py", line 164, in forward
    x, img = block(x, img, **block_kwargs)
  File "/home/anya/Programs/eg3d/eg3d/torch_utils/misc.py", line 218, in print_module_summary
    outputs = module(*inputs)
  File "/home/anya/Programs/eg3d/eg3d/training/training_loop.py", line 178, in training_loop
    misc.print_module_summary(D, [img, c])
  File "/home/anya/Programs/eg3d/eg3d/train.py", line 52, in subprocess_fn
    training_loop.training_loop(rank=rank, **c)
  File "/home/anya/Programs/eg3d/eg3d/train.py", line 101, in launch_training
    subprocess_fn(rank=0, c=c, temp_dir=temp_dir)
  File "/home/anya/Programs/eg3d/eg3d/train.py", line 402, in main
    launch_training(c=c, desc=desc, outdir=opts.outdir, dry_run=opts.dry_run)
  File "/home/anya/Programs/eg3d/eg3d/train.py", line 407, in <module>
    main() # pylint: disable=no-value-for-parameter
AssertionError: Wrong size for dimension 1: got 6, expected 2 

Therefore, I changed it to
image = np.stack((image,)*3, axis=-1) # HW => HWC, but C is not 1, but 3
so I treat the images as RGB, but I was hoping to change the code to work with the images like grayscale and I got confused about the used dimensions/tensor shapes.
I have tried to change the img_channels here to 32 * 1 (assuming that the original 32 * 3 had 3 for RGB), but then it doesn't fit with other shapes later in the code which seems to be connected to the triplane size, not the RGB colour. I guess I need to keep the triplane representation (which I guess stands for the 3D geometry, not colour)...
If anyone could explain me a bit more I would be glad. Thank you :)

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

No branches or pull requests

1 participant