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

ffhq-e cannot be converted from official model but ffhq-f made it #52

Open
XD666 opened this issue Feb 25, 2020 · 8 comments
Open

ffhq-e cannot be converted from official model but ffhq-f made it #52

XD666 opened this issue Feb 25, 2020 · 8 comments

Comments

@XD666
Copy link

XD666 commented Feb 25, 2020

Setting up TensorFlow plugin "fused_bias_act.cu": Preprocessing... Loading... Done.
Setting up TensorFlow plugin "upfirdn_2d.cu": Preprocessing... Loading... Done.
Traceback (most recent call last):
  File "convert_weight.py", line 214, in <module>
    state_dict = fill_statedict(state_dict, g_ema.vars, size)
  File "convert_weight.py", line 148, in fill_statedict
    convert_torgb(vars, f'G_synthesis/{reso}x{reso}/ToRGB', f'to_rgbs.{i}'),
  File "convert_weight.py", line 101, in update
    raise ValueError(f'Shape mismatch: {v.shape} vs {state_dict[k].shape}')
ValueError: Shape mismatch: torch.Size([1, 3, 256, 1, 1]) vs torch.Size([1, 3, 512, 1, 1])
`
@rosinality
Copy link
Owner

Added --channel_multiplier arguments to the convert_weight.py at c7c8fc7. Now you can use --channel_multiplier 1 options for converting config-e checkpoints.

@songyoyo
Copy link

@XD666 Hi, I'm also tring to convert the weight, but some errors ocurred. Can you share your implementation environment or the converted weight file (ffhq-f)? My e-mail is 610240943@qq.com. THANK YOU VERY MUCH!

@woctezuma
Copy link
Contributor

woctezuma commented Sep 18, 2020

First, thank you for providing this script to convert weights!

Second, it might be good to mention in the README --channel_multiplier 1 for people using config-e.

I have seen it mentioned in the help of:

!python convert_weight.py -h

but it was not super clear at that time.

@woctezuma
Copy link
Contributor

woctezuma commented Sep 18, 2020

Similarly, it takes some time to check the code and understand a few things which are not super clear from the command-line help.

usage: convert_weight.py [-h] --repo REPO [--gen] [--disc]
                         [--channel_multiplier CHANNEL_MULTIPLIER]
                         PATH

positional arguments:
  PATH

optional arguments:
  -h, --help            show this help message and exit
  --repo REPO
  --gen
  --disc
  --channel_multiplier CHANNEL_MULTIPLIER

For instance, that the script outputs an image with 3 rows:

  • images generated with TensorFlow, PyTorch, and the difference between the two,

img_concat = torch.cat((img_tf, img_pt, img_diff), dim=0)

output image

or that:

  • --repo is used to provide a path to the official StyleGAN2 repository with the dnnlib/ folder,
  • PATH is the absolute path to the TensorFlow weights.
  • --gen is a boolean flag to convert the generator,
  • --disc is a boolean flag to convert the discriminator.

@rosinality
Copy link
Owner

@woctezuma Yes...I will add some helps to command line arguments. I am quite lazy about that. 😅

@woctezuma
Copy link
Contributor

I can understand that. It is not the most interesting part of the work. However, your converter tool does more things than I would have expected, so I think that providing a bit of clarity helps shine some light on the optional (yet useful) stuff that you did. :)

@rosinality
Copy link
Owner

@woctezuma Added cli argument helps at f938922.

@woctezuma
Copy link
Contributor

Thank you very much! This will be super helpful!

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

4 participants