bupt-ai-cz / BCI

BCI: Breast Cancer Immunohistochemical Image Generation through Pyramid Pix2pix
Other
182 stars 17 forks source link

AttributeError: 'Sequential' object has no attribute 'model' #7

Closed rabiaedayilmaz closed 7 months ago

rabiaedayilmaz commented 1 year ago

I have test images, downloaded BCI pretrained model and use the following command:

!python test.py --dataroot /kaggle/input/bci-img2img/BCI_for_GrandChallenge-20230210T115047Z-001/BCI_for_GrandChallenge/test --gpu_ids 0

However, I get an AttributeError, here is the output:

/bin/bash: /opt/conda/lib/libtinfo.so.6: no version information available (required by /bin/bash)
----------------- Options ---------------
             aspect_ratio: 1.0                           
               batch_size: 2                             
          checkpoints_dir: ./checkpoints                 
                crop_size: 256                           
                 dataroot: /kaggle/input/bci-img2img/BCI_for_GrandChallenge-20230210T115047Z-001/BCI_for_GrandChallenge/test    [default: ./datasets/BCI]
             dataset_mode: aligned                       
                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: 320                           
         max_dataset_size: inf                           
                    model: pix2pix                       
               n_layers_D: 3                             
                     name: pyramidpix2pix                
                      ndf: 64                            
                     netD: basic                         
                     netG: resnet_9blocks                
                      ngf: 64                            
               no_dropout: False                         
                  no_flip: False                         
                     norm: batch                         
                 num_test: 1000                          
              num_threads: 4                             
                output_nc: 3                             
                  pattern: L1_L2_L3_L4                   
                    phase: test                          
               preprocess: scale_width_and_midcrop       
              results_dir: ./results/                    
           serial_batches: False                         
                   suffix:                               
                  verbose: False                         
----------------- End -------------------
dataset [AlignedDataset] was created
initialize network with normal
model [Pix2PixModel] was created
loading the model from ./checkpoints/pyramidpix2pix/latest_net_G.pth
Traceback (most recent call last):
  File "test.py", line 47, in <module>
    model.setup(opt)               # regular setup: load and print networks; create schedulers
  File "/kaggle/working/BCI-main/PyramidPix2pix/models/base_model.py", line 88, in setup
    self.load_networks(load_suffix)
  File "/kaggle/working/BCI-main/PyramidPix2pix/models/base_model.py", line 198, in load_networks
    self.__patch_instance_norm_state_dict(state_dict, net, key.split('.'))
  File "/kaggle/working/BCI-main/PyramidPix2pix/models/base_model.py", line 174, in __patch_instance_norm_state_dict
    self.__patch_instance_norm_state_dict(state_dict, getattr(module, key), keys, i + 1)
  File "/kaggle/working/BCI-main/PyramidPix2pix/models/base_model.py", line 174, in __patch_instance_norm_state_dict
    self.__patch_instance_norm_state_dict(state_dict, getattr(module, key), keys, i + 1)
  File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1208, in __getattr__
    type(self).__name__, name))
AttributeError: 'Sequential' object has no attribute 'model'

Could someone help me with this? Thank you!

SantJay commented 1 year ago

Hello, may I ask which version of PyTorch you are using? If you are using a version of PyTorch that is too high, it may cause problems with model loading. We tested with PyTorch version 1.4.0 and did not encounter the problem you described. Therefore, we recommend that you try changing the PyTorch version and try again, hoping to solve your problem.

ccitachi commented 1 year ago

I have the same problem. my Pytorch version is 3.80. How can I fix this without changing my Pytorch version.

Geek-LX commented 1 year ago

I have the same problem. my Pytorch version is 3.80. How can I fix this without changing my Pytorch version.

xliuPhd commented 1 year ago

I have the same problem. my Pytorch version is 3.80. How can I fix this without changing my Pytorch version.