Skip to content

Commit

Permalink
fix gardcam error using in mmdet (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
hhaAndroid committed May 17, 2023
1 parent a3b6ae1 commit 1e5372e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions mmyolo/utils/boxam_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,10 @@ def __call__(self, *args, **kwargs):
if self.is_need_loss:
# Maybe this is a direction that can be optimized
# self.detector.init_weights()

self.detector.bbox_head.head_module.training = True
if hasattr(self.detector.bbox_head, 'head_module'):
self.detector.bbox_head.head_module.training = True
else:
self.detector.bbox_head.training = True
if hasattr(self.detector.bbox_head, 'featmap_sizes'):
# Prevent the model algorithm error when calculating loss
self.detector.bbox_head.featmap_sizes = None
Expand All @@ -219,7 +221,10 @@ def __call__(self, *args, **kwargs):

return [loss]
else:
self.detector.bbox_head.head_module.training = False
if hasattr(self.detector.bbox_head, 'head_module'):
self.detector.bbox_head.head_module.training = False
else:
self.detector.bbox_head.training = False
with torch.no_grad():
results = self.detector.test_step(self.input_data)
return results
Expand Down

0 comments on commit 1e5372e

Please sign in to comment.