VITA-Group / GAN-Slimming

[ECCV 2020] "All-in-One GAN Compression by Unified Optimization" by Haotao Wang, Shupeng Gui, Haichuan Yang, Ji Liu, and Zhangyang Wang
MIT License
110 stars 23 forks source link

RuntimeError: Error(s) in loading state_dict for Generator: #7

Closed PatrickHaopc closed 3 years ago

PatrickHaopc commented 3 years ago

Thanks for your geart work! I have traind my cycle gan model with the official CycleGAN codes, but when I run gs.py the error showed : RuntimeError: Error(s) in loading state_dict for Generator: Missing key(s) in state_dict: "model.2.weight", "model.2.bias", "model.5.weight", "model.5.bias", "model.10.conv_block.2.weight", "model.10.conv_block.2.bias", "model.11.conv_block.2.weight", "model.11.conv_block.2.bias", "model.12.conv_block.2.weight", "model.12.conv_block.2.bias", "model.13.conv_block.2.weight", "model.13.conv_block.2.bias", "model.14.conv_block.2.weight", "model.14.conv_block.2.bias", "model.15.conv_block.2.weight", "model.15.conv_block.2.bias", "model.16.conv_block.2.weight", "model.16.conv_block.2.bias", "model.17.conv_block.2.weight", "model.17.conv_block.2.bias", "model.18.conv_block.2.weight", "model.18.conv_block.2.bias", "model.20.weight", "model.20.bias", "model.23.weight", "model.23.bias".

I didn't change the official cycle gan codes, and the options I trained my model is "python train.py --dataroot ./datasets/Task12_BBR2color --name BBR2color --model cycle_gan --pool_size 50 --no_dropout --gpu_ids 1 --preprocess scale_width_and_crop --load_size 1920 --crop_size 360 --batch_size 1 --display_port 2020" The pytorch version is 1.7

PatrickHaopc commented 3 years ago
      checkpoints_dir: ./checkpoints                 
            crop_size: 256                           
             dataroot: ./datasets/Task12_BBR            [default: None]
         dataset_mode: single                        
            direction: AtoB                          
      display_winsize: 256                           
                epoch: latest                        
                 eval: False                         
              gpu_ids: 0                             
            init_gain: 0.02                          
            init_type: normal                        
             input_nc: 3                             
              isTrain: False                            [default: None]
            load_iter: 0                                [default: 0]
            load_size: 1920                             [default: 256]
     max_dataset_size: inf                           
                model: test                          
         model_suffix:                               
           n_layers_D: 3                             
                 name: spot                             [default: experiment_name]
                  ndf: 64                            
                 netD: basic                         
                 netG: resnet_9blocks                
                  ngf: 64                            
           no_dropout: True                             [default: False]
              no_flip: False                         
                 norm: instance                      
             num_test: 50                            
          num_threads: 4                             
            output_nc: 3                             
                phase: test                          
           preprocess: scale_width                      [default: resize_and_crop]
          results_dir: ./results/                    
       serial_batches: False                         
               suffix:                               
              verbose: False                         

----------------- End ------------------- initialize network with normal model [TestModel] was created ---------- Networks initialized ------------- DataParallel( (module): ResnetGenerator( (model): Sequential( (0): ReflectionPad2d((3, 3, 3, 3)) (1): Conv2d(3, 64, kernel_size=(7, 7), stride=(1, 1)) (2): InstanceNorm2d(64, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): ReLU(inplace=True) (4): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1)) (5): InstanceNorm2d(128, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (6): ReLU(inplace=True) (7): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1)) (8): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (9): ReLU(inplace=True) (10): ResnetBlock( (conv_block): Sequential( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): ReLU(inplace=True) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (11): ResnetBlock( (conv_block): Sequential( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): ReLU(inplace=True) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (12): ResnetBlock( (conv_block): Sequential( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): ReLU(inplace=True) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (13): ResnetBlock( (conv_block): Sequential( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): ReLU(inplace=True) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (14): ResnetBlock( (conv_block): Sequential( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): ReLU(inplace=True) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (15): ResnetBlock( (conv_block): Sequential( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): ReLU(inplace=True) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (16): ResnetBlock( (conv_block): Sequential( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): ReLU(inplace=True) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (17): ResnetBlock( (conv_block): Sequential( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): ReLU(inplace=True) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (18): ResnetBlock( (conv_block): Sequential( (0): ReflectionPad2d((1, 1, 1, 1)) (1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (2): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (3): ReLU(inplace=True) (4): ReflectionPad2d((1, 1, 1, 1)) (5): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1)) (6): InstanceNorm2d(256, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) ) ) (19): ConvTranspose2d(256, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), output_padding=(1, 1)) (20): InstanceNorm2d(128, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (21): ReLU(inplace=True) (22): ConvTranspose2d(128, 64, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), output_padding=(1, 1)) (23): InstanceNorm2d(64, eps=1e-05, momentum=0.1, affine=False, track_running_stats=False) (24): ReLU(inplace=True) (25): ReflectionPad2d((3, 3, 3, 3)) (26): Conv2d(64, 3, kernel_size=(7, 7), stride=(1, 1)) (27): Tanh() ) ) ) [Network G] Total number of parameters : 11.378 M

PatrickHaopc commented 3 years ago

This is the printed network, I contrast with the models.py https://github.com/VITA-Group/GAN-Slimming/blob/master/models/models.py, the structure of generator is same