This repository has been archived by the owner on Oct 31, 2023. It is now read-only.
Fix repeatedly invoke build_detection_model error. #107
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
The reason
The variable
ResNet50StagesTo4
is a global generator expression, so when we build the model secondly, the code executes to Line 82for stage_spec in stage_specs:
andstage_specs
will return empty leading to do not add any stage. Finally,self._freeze_backbone
try to freeze the backbone by executingm = getattr(self, "layer" + str(stage_index))
firstly. At the moment, it will throw the AttributeErrorAttributeError: '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 bugs existing, so you need to review my solution. Thank you!