question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pretrained resnet conversion AttributeError

See original GitHub issue
[---------------------------------------------------------------------------]
AttributeError                            Traceback (most recent call last)
<ipython-input-4-2a0f9d424028> in <module>
      4 output_2d = model_2d(input_2d)
      5 
----> 6 model_3d = ACSConverter(model_2d)
      7 # once converted, model_3d is using ACSConv and capable of processing 3D volumes.
      8 B, C_in, D, H, W = (1, 3, 64, 64, 64)

~/miniconda3/envs/rENE/lib/python3.6/site-packages/ACSConv-0.1.0-py3.6.egg/acsconv/converters/acsconv_converter.py in __init__(self, model)
     27         """ Save the weights, convert the model to ACS counterpart, and then reload the weights """
     28         preserve_state_dict = model.state_dict()
---> 29         model = self.convert_module(model)
     30         model.load_state_dict(preserve_state_dict,strict=False) #
     31         self.model = model

~/miniconda3/envs/rENE/lib/python3.6/site-packages/ACSConv-0.1.0-py3.6.egg/acsconv/converters/base_converter.py in convert_module(self, module)
     24             if isinstance(child, nn.Conv2d):
     25                 arguments = nn.Conv2d.__init__.__code__.co_varnames[1:]
---> 26                 kwargs = {k: getattr(child, k) for k in arguments}
     27                 kwargs = self.convert_conv_kwargs(kwargs)
     28                 setattr(module, child_name, self.__class__.target_conv(**kwargs))

~/miniconda3/envs/rENE/lib/python3.6/site-packages/ACSConv-0.1.0-py3.6.egg/acsconv/converters/base_converter.py in <dictcomp>(.0)
     24             if isinstance(child, nn.Conv2d):
     25                 arguments = nn.Conv2d.__init__.__code__.co_varnames[1:]
---> 26                 kwargs = {k: getattr(child, k) for k in arguments}
     27                 kwargs = self.convert_conv_kwargs(kwargs)
     28                 setattr(module, child_name, self.__class__.target_conv(**kwargs))

~/miniconda3/envs/rENE/lib/python3.6/site-packages/torch/nn/modules/module.py in __getattr__(self, name)
    946                 return modules[name]
    947         raise AttributeError("'{}' object has no attribute '{}'".format(
--> 948             type(self).__name__, name))
    949 
    950     def __setattr__(self, name: str, value: Union[Tensor, 'Module']) -> None:

AttributeError: 'Conv2d' object has no attribute 'kernel_size_'

model_2d = resnet18(pretrained=True)

Pretrained resnet is not converted properly.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
seanywang0408commented, Apr 14, 2021

I assume the corresponding torch version is 1.8 for torchvision 0.9. It is indeed not compatible with our current codebase. We are going to update a compatible version for torch 1.8. You could either wait for the new codebase or downgrade the torch version to 1.0.

Sorry for the trouble.

0reactions
seanywang0408commented, Apr 19, 2021

@seanywang0408 Is it compatible with pytorch=1.4.0? My computing clusters are on CUDA=10.1, so I’m wondering if the repo’s compatible with a version of pytorch that’s compatible with CUDA 10.1. Thanks!

The repo is compatible with PyTorch 1.8 now. Welcome to try it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ResNet object has no attribute 'predict' - Stack Overflow
TLDR: I get an error called ModuleAttributeError that says the 'ResNet' module has no attribute 'predict'. The image is preprocessed here as ...
Read more >
Convert ResNet101 from TensorFlow to PyTorch #22 - GitHub
Dear @kitstar, I want to convert a ResNet V1 101 model (from ... I transfer the pretrained vgg16.ckpt in tensorflow to be used...
Read more >
speechbrain.pretrained.interfaces module - Read the Docs
Defines interfaces for simple inference with pretrained models ... It is, however, possible to convert a file from a higher sampling rate to...
Read more >
Transfer Learning in Keras with Computer Vision Models
A way to short-cut this process is to re-use the model weights from pre-trained models that were developed for standard computer vision ...
Read more >
AttributeError: 'VGG' object has no attribute 'copy' - vision
AttributeError : 'VGG' object has no attribute 'copy' ... self.pre_trained_model == 'VGG16': self.torch_model = models.vgg16(pretrained=True) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found