• Guoxia Wang's avatar
    Fix repeatedly invoke build_detection_model error. (#107) · 0527726b
    Guoxia Wang authored
    ## Bug
    When I repeatedly invoke build_detection_model function to build the model, I will get the error: `AttributeError: 'ResNet' object has no attribute 'layer1'`. 
    
    ## To Reproduce
    ```
    model = build_detection_model(cfg)
    model = build_detection_model(cfg)
    ```
    
    ## The reason
    The variable `ResNet50StagesTo4` is a global generator expression, so when we build the model secondly, the code executes to Line 82 `for stage_spec in stage_specs:` and `stage_specs` will return empty leading to do not add any stage. Finally, `self._freeze_backbone` try to freeze the backbone by executing `m = getattr(self, "layer" + str(stage_index))` firstly. At the moment, it will throw the AttributeError `AttributeError: 'ResNet' object has no attribute 'layer1'`.
    
    I guess you want to define ResNet50StagesTo4 as the tuple, so I try to fix by add tuple type qualifier.
    
    ## The solution
    Add the tuple type to `ResNet50StagesTo5`, `ResNet50StagesTo4`, `ResNet50FPNStagesTo5`, `ResNet101FPNStagesTo5`.
    
    I do not know whether there are similar bug existing, so you need to review my solution. Thank you!
    0527726b
Name
Last commit
Last update
.github/ISSUE_TEMPLATE Loading commit data...
configs Loading commit data...
demo Loading commit data...
maskrcnn_benchmark Loading commit data...
tests Loading commit data...
tools Loading commit data...
.flake8 Loading commit data...
.gitignore Loading commit data...
ABSTRACTIONS.md Loading commit data...
CODE_OF_CONDUCT.md Loading commit data...
CONTRIBUTING.md Loading commit data...
INSTALL.md Loading commit data...
LICENSE Loading commit data...
MODEL_ZOO.md Loading commit data...
README.md Loading commit data...
TROUBLESHOOTING.md Loading commit data...
setup.py Loading commit data...