본문 바로가기

Data-science/deep learning

[pytorch] stylegan2 pretrained model load error

728x90

에러가 났다. pretrained model 못쓰는건가... 좌절중일때! repository에 정답이 있었다. god hub!

RuntimeError: Error(s) in loading state_dict for Generator:
        Missing key(s) in state_dict: "noises.noise_0", "noises.noise_1", "noises.noise_2", "noises.noise_3", "noises.noise_4", "noises.noise_5", "noises.noise_6", "noises.noise_7", "noises.noise_8", "noises.noise_9", "noises.noise_10", "noises.noise_11", "noises.noise_12". 

runpy.py",

훌륭한 질문, 훌륭한 답변!

 

코드 수정 후

g_optim, d_optim의 경우 strict를 줄 경우 에러가 난다. train.py의 load_state_dict 부분을 아래와 같이 수정해주면 된다.

        generator.load_state_dict(ckpt["g"], strict=False)
        discriminator.load_state_dict(ckpt["d"], strict=False)
        g_ema.load_state_dict(ckpt["g_ema"], strict=False)

        g_optim.load_state_dict(ckpt["g_optim"])
        d_optim.load_state_dict(ckpt["d_optim"])

github.com/rosinality/stylegan2-pytorch/issues/71

 

Pretrained 256 ffhq model missing noise keys in state_dict · Issue #71 · rosinality/stylegan2-pytorch

Trying to generate images using the 256x256 model linked in the readme I get the following error RuntimeError: Error(s) in loading state_dict for Generator: Missing key(s) in state_dict: "nois...

github.com