Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Module 'ResNet' has no attribute 'stages_and_names' #4964

Open
lix19937 opened this issue May 19, 2023 · 1 comment
Open

RuntimeError: Module 'ResNet' has no attribute 'stages_and_names' #4964

lix19937 opened this issue May 19, 2023 · 1 comment

Comments

@lix19937
Copy link

lix19937 commented May 19, 2023

Instructions To Reproduce the 🐛 Bug:

  1. Full runnable code or full changes you made:
  File "/opt/conda/envs/alpha_env/lib/python3.8/site-packages/torch/jit/_recursive.py", line 368, in create_methods_and_properties_from_stubs
    concrete_type._create_methods_and_properties(property_defs, property_rcbs, method_defs, method_rcbs, method_defaults)

RuntimeError: 
Module 'ResNet' has no attribute 'stages_and_names' (This attribute exists on the Python module, but we failed to convert Python type: 'list' to a TorchScript type. Could not infer type of list element: Cannot infer concrete type of torch.nn.Module. Its type was inferred; try adding a type annotation for the attribute.):

  File "/root/code/modeling/backbone/res2net.py", line 632

        if "stem" in self._out_features:
            outputs["stem"] = x
        for stage, name in self.stages_and_names:
                           ~~~~~~~~~~~~~~~~~~~~~ <--- HERE

            x = stage(x)
            if name in self._out_features:

ref #2734
https://detectron2.readthedocs.io/en/latest/tutorials/deployment.html#deployment-with-tracing-or-scripting not work !!!

Environment:

torch 1.10.2+cu113
detectron2 0.6

@lix19937 lix19937 changed the title Please read & provide the following RuntimeError: Module 'ResNet' has no attribute 'stages_and_names' May 19, 2023
@fumin
Copy link

fumin commented Jul 8, 2023

Hitting against this bug, too:

RuntimeError: 
Module 'ResNet' has no attribute 'stages' (This attribute exists on the Python module, but we failed to convert Python type: 'list' to a TorchScript type. Could not infer type of list element: Cannot infer concrete type of torch.nn.Module. Its type was inferred; try adding a type annotation for the attribute.):
  File "/usr/local/detectron2/detectron2/modeling/backbone/resnet.py", line 448
        if "stem" in self._out_features:
            outputs["stem"] = x
        for name, stage in zip(self.stage_names, self.stages):
                                                 ~~~~~~~~~~~ <--- HERE
            x = stage(x)
            if name in self._out_features:


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants