elvisyjlin / AttGAN-PyTorch

AttGAN PyTorch Arbitrary Facial Attribute Editing: Only Change What You Want
MIT License
248 stars 61 forks source link

Pre-trained weights don't work and Neither Does other Scripts? #23

Closed EoinKenny closed 3 years ago

EoinKenny commented 3 years ago

Hi I have found that the pre-trained weights do not work with the scripts here. The weights do not match the Generator.

In addition, I trained the model from scratch, with

CUDA_VISIBLE_DEVICES=0 \
python train.py \
--data CelebA-HQ \
--img_size 256 \
--shortcut_layers 1 \
--inject_layers 1 \
--experiment_name 256_shortcut1_inject1_none_hq \
--gpu \
--multi_gpu

and when I tried to run

CUDA_VISIBLE_DEVICES=0 \
python test.py \
--experiment_name 128_shortcut1_inject1_none \
--test_int 1.0 \
--gpu

it I got this error

Find model of latest epoch: output/128_shortcut1_inject1_none/checkpoint/weights.49.pth
Traceback (most recent call last):
  File "test.py", line 80, in <module>
    attgan.load(find_model(join('output', args.experiment_name, 'checkpoint'), args.load_epoch))
  File "/home/people/16206131/reproduce_attgan/attgan.py", line 270, in load
    self.G.load_state_dict(states['G'])
  File "/home/people/16206131/reproduce_attgan/attgan/lib64/python3.6/site-packages/torch/nn/modules/module.py", line 845, in load_state_dict
    self.__class__.__name__, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for Generator:
        Missing key(s) in state_dict: "enc_layers.0.layers.0.weight", "enc_layers.0.layers.1.weight", "enc_layers.0.layers.1.bias", "enc_layers.0.layers.1.ru$
        Unexpected key(s) in state_dict: "module.enc_layers.0.layers.0.weight", "module.enc_layers.0.layers.1.weight", "module.enc_layers.0.layers.1.bias", "$