odegeasslbc / FastGAN-pytorch

Official implementation of the paper "Towards Faster and Stabilized GAN Training for High-fidelity Few-shot Image Synthesis" in ICLR 2021
GNU General Public License v3.0
600 stars 100 forks source link

generate_video.py #5

Closed corlangerak closed 3 years ago

corlangerak commented 3 years ago

Hi I am very new to coding and GAN's so please correct or help me out if I am doing something silly... I Trained FastGAN until 30000.pth When I go in to my training results and try to python generate_video.py

I got: python generate_video.py Traceback (most recent call last): File "generate_video.py", line 182, in <module> net.load_state_dict(torch.load(ckpt_path)['g']) File "/home/paperspace/miniconda3/envs/fastGAN/lib/python3.8/site-packages/torch/serialization.py", line 581, in load with _open_file_like(f, 'rb') as opened_file: File "/home/paperspace/miniconda3/envs/fastGAN/lib/python3.8/site-packages/torch/serialization.py", line 230, in _open_file_like return _open_file(name_or_buffer, mode) File "/home/paperspace/miniconda3/envs/fastGAN/lib/python3.8/site-packages/torch/serialization.py", line 211, in _init_ super(_open_file, self).__init__(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: './time_1024_1/models/180000.pth'

I looked inside the code and changed './time_1024_1/models/180000.pth' to my file path. But then this message came up: python generate_video.py Traceback (most recent call last): File "generate_video.py", line 182, in <module> net.load_state_dict(torch.load(ckpt_path)['g']) File "/home/paperspace/miniconda3/envs/fastGAN/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1051, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for Generator: size mismatch for init.init.0.weight_orig: copying a param with shape torch.Size([256, 2048, 4, 4]) from checkpoint, the shape in current model is torch.Size([100, 2048, 4, 4]). size mismatch for init.init.0.weight_v: copying a param with shape torch.Size([4096]) from checkpoint, the shape in current model is torch.Size([1600]).

I would really like to generate a video for a project I am doing. Again I am very new to this, I also not sure how I should find out what commands python generate_video.py needs....

All help would be very much appreciated, have a good day!

odegeasslbc commented 3 years ago

Please refer to this line in "generate_video.py" which initializes the model: https://github.com/odegeasslbc/FastGAN-pytorch/blob/2a2e8d9d13ac01111645502cc903b7bff0031dc4/scripts/generate_video.py#L181

You may want to change the above line to match what you defined the model in "train.py": https://github.com/odegeasslbc/FastGAN-pytorch/blob/2a2e8d9d13ac01111645502cc903b7bff0031dc4/train.py#L100

According to the error code you post, the model size is mismatched, which means: during training, in train.py, you configured the model to have a particular size, but in generate_video.py, you did not make the same configuration.