Skip to content

Commit

Permalink
[Fix]fix init when densehead contains dcn (#6625)
Browse files Browse the repository at this point in the history
* fix init when densehead contains dcn

* change to constant init
  • Loading branch information
jshilong authored and ZwwWayne committed Dec 14, 2021
1 parent bdf0096 commit 1260f29
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mmdet/models/dense_heads/base_dense_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from abc import ABCMeta, abstractmethod

import torch
from mmcv.cnn.utils.weight_init import constant_init
from mmcv.ops import batched_nms
from mmcv.runner import BaseModule, force_fp32

Expand All @@ -14,6 +15,14 @@ class BaseDenseHead(BaseModule, metaclass=ABCMeta):
def __init__(self, init_cfg=None):
super(BaseDenseHead, self).__init__(init_cfg)

def init_weights(self):
super(BaseDenseHead, self).init_weights()
# avoid init_cfg overwrite the initialization of `conv_offset`
for m in self.modules():
# DeformConv2dPack, ModulatedDeformConv2dPack
if hasattr(m, 'conv_offset'):
constant_init(m.conv_offset, 0)

@abstractmethod
def loss(self, **kwargs):
"""Compute losses of the head."""
Expand Down

0 comments on commit 1260f29

Please sign in to comment.