facebookresearch / facebookresearch/detectron2
RuntimeError: Module 'ResNet' has no attribute 'stages_and_names'
- Dominant language
- Python
- Stars
- 34.7k
- Forks
- 7.9k
- PR merge metrics
- No merged PRs in 30d
Description
## 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 https://github.com/facebookresearch/detectron2/issues/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
Contributor guide
Research direction
Start with modeling/backbone/res2net.py around line 632, where ResNet iterates over stages_and_names, then review the TorchScript failure in torch/jit/_recursive.py and the deployment documentation linked in the issue. Reproduce with torch 1.10.2+cu113 and detectron2 0.6; done means the reported model can be scripted without the stages_and_names conversion error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100