We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG]bug in ConvFCBBoxHead's init cfg.
https://github.com/open-mmlab/mmdetection/blob/c88509cb9a73d6bd1edcba64eb924d3cf3cfe85d/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py#L103

This line will override initializers for fc_cls and fc_reg because they are also nn.Linear. 
Or is it what's intended? But I see the old way to initialize fc_cls and fc_reg is using Normal.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py`
Content:
```
1 # Copyright (c) OpenMMLab. All rights reserved.
2 import torch.nn as nn
3 from mmcv.cnn import ConvModule
4 
5 from mmdet.models.builder import HEADS
6 from mmdet.models.utils import build_linear_layer
7 from .bbox_head import BBoxHead
8 
9 
10 @HEADS.register_module()
11 class ConvFCBBoxHead(BBoxHead):
12     r"""More general bbox head, with shared conv and fc layers and two optional
13     separated branches.
14 
15     .. code-block:: none
16 
17                                     /-> cls convs -> cls fcs -> cls
18         shared convs -> shared fcs
19                                     \-> reg convs -> reg fcs -> reg
20     """  # noqa: W605
21 
22     def __init__(self,
23                  num_shared_convs=0,
24                  num_shared_fcs=0,
25                  num_cls_convs=0,
26                  num_cls_fcs=0,
27                  num_reg_convs=0,
28                  num_reg_fcs=0,
29                  conv_out_channels=256,
30                  fc_out_channels=1024,
31                  conv_cfg=None,
32                  norm_cfg=None,
33                  init_cfg=None,
34                  *args,
35                  **kwargs):
36         super(ConvFCBBoxHead, self).__init__(
37             *args, init_cfg=init_cfg, **kwargs)
38         assert (num_shared_convs + num_shared_fcs + num_cls_convs +
39                 num_cls_fcs + num_reg_convs + num_reg_fcs > 0)
40         if num_cls_convs > 0 or num_reg_convs > 0:
41             assert num_shared_fcs == 0
42         if not self.with_cls:
43             assert num_cls_convs == 0 and num_cls_fcs == 0
44         if not self.with_reg:
45             assert num_reg_convs == 0 and num_reg_fcs == 0
46         self.num_shared_convs = num_shared_convs
47         self.num_shared_fcs = num_shared_fcs
48         self.num_cls_convs = num_cls_convs
49         self.num_cls_fcs = num_cls_fcs
50         self.num_reg_convs = num_reg_convs
51         self.num_reg_fcs = num_reg_fcs
52         self.conv_out_channels = conv_out_channels
53         self.fc_out_channels = fc_out_channels
54         self.conv_cfg = conv_cfg
55         self.norm_cfg = norm_cfg
56 
57         # add shared convs and fcs
58         self.shared_convs, self.shared_fcs, last_layer_dim = \
59             self._add_conv_fc_branch(
60                 self.num_shared_convs, self.num_shared_fcs, self.in_channels,
61                 True)
62         self.shared_out_channels = last_layer_dim
63 
64         # add cls specific branch
65         self.cls_convs, self.cls_fcs, self.cls_last_dim = \
66             self._add_conv_fc_branch(
67                 self.num_cls_convs, self.num_cls_fcs, self.shared_out_channels)
68 
69         # add reg specific branch
70         self.reg_convs, self.reg_fcs, self.reg_last_dim = \
71             self._add_conv_fc_branch(
72                 self.num_reg_convs, self.num_reg_fcs, self.shared_out_channels)
73 
74         if self.num_shared_fcs == 0 and not self.with_avg_pool:
75             if self.num_cls_fcs == 0:
76                 self.cls_last_dim *= self.roi_feat_area
77             if self.num_reg_fcs == 0:
78                 self.reg_last_dim *= self.roi_feat_area
79 
80         self.relu = nn.ReLU(inplace=True)
81         # reconstruct fc_cls and fc_reg since input channels are changed
82         if self.with_cls:
83             if self.custom_cls_channels:
84                 cls_channels = self.loss_cls.get_cls_channels(self.num_classes)
85             else:
86                 cls_channels = self.num_classes + 1
87             self.fc_cls = build_linear_layer(
88                 self.cls_predictor_cfg,
89                 in_features=self.cls_last_dim,
90                 out_features=cls_channels)
91         if self.with_reg:
92             out_dim_reg = (4 if self.reg_class_agnostic else 4 *
93                            self.num_classes)
94             self.fc_reg = build_linear_layer(
95                 self.reg_predictor_cfg,
96                 in_features=self.reg_last_dim,
97                 out_features=out_dim_reg)
98 
99         if init_cfg is None:
100             self.init_cfg += [
101                 dict(
102                     type='Xavier',
103                     layer='Linear',
104                     override=[
105                         dict(name='shared_fcs'),
106                         dict(name='cls_fcs'),
107                         dict(name='reg_fcs')
108                     ])
109             ]
110 
111     def _add_conv_fc_branch(self,
112                             num_branch_convs,
113                             num_branch_fcs,
114                             in_channels,
115                             is_shared=False):
116         """Add shared or separable branch.
117 
118         convs -> avg pool (optional) -> fcs
119         """
120         last_layer_dim = in_channels
121         # add branch specific conv layers
122         branch_convs = nn.ModuleList()
123         if num_branch_convs > 0:
124             for i in range(num_branch_convs):
125                 conv_in_channels = (
126                     last_layer_dim if i == 0 else self.conv_out_channels)
127                 branch_convs.append(
128                     ConvModule(
129                         conv_in_channels,
130                         self.conv_out_channels,
131                         3,
132                         padding=1,
133                         conv_cfg=self.conv_cfg,
134                         norm_cfg=self.norm_cfg))
135             last_layer_dim = self.conv_out_channels
136         # add branch specific fc layers
137         branch_fcs = nn.ModuleList()
138         if num_branch_fcs > 0:
139             # for shared branch, only consider self.with_avg_pool
140             # for separated branches, also consider self.num_shared_fcs
141             if (is_shared
142                     or self.num_shared_fcs == 0) and not self.with_avg_pool:
143                 last_layer_dim *= self.roi_feat_area
144             for i in range(num_branch_fcs):
145                 fc_in_channels = (
146                     last_layer_dim if i == 0 else self.fc_out_channels)
147                 branch_fcs.append(
148                     nn.Linear(fc_in_channels, self.fc_out_channels))
149             last_layer_dim = self.fc_out_channels
150         return branch_convs, branch_fcs, last_layer_dim
151 
152     def forward(self, x):
153         # shared part
154         if self.num_shared_convs > 0:
155             for conv in self.shared_convs:
156                 x = conv(x)
157 
158         if self.num_shared_fcs > 0:
159             if self.with_avg_pool:
160                 x = self.avg_pool(x)
161 
162             x = x.flatten(1)
163 
164             for fc in self.shared_fcs:
165                 x = self.relu(fc(x))
166         # separate branches
167         x_cls = x
168         x_reg = x
169 
170         for conv in self.cls_convs:
171             x_cls = conv(x_cls)
172         if x_cls.dim() > 2:
173             if self.with_avg_pool:
174                 x_cls = self.avg_pool(x_cls)
175             x_cls = x_cls.flatten(1)
176         for fc in self.cls_fcs:
177             x_cls = self.relu(fc(x_cls))
178 
179         for conv in self.reg_convs:
180             x_reg = conv(x_reg)
181         if x_reg.dim() > 2:
182             if self.with_avg_pool:
183                 x_reg = self.avg_pool(x_reg)
184             x_reg = x_reg.flatten(1)
185         for fc in self.reg_fcs:
186             x_reg = self.relu(fc(x_reg))
187 
188         cls_score = self.fc_cls(x_cls) if self.with_cls else None
189         bbox_pred = self.fc_reg(x_reg) if self.with_reg else None
190         return cls_score, bbox_pred
191 
192 
193 @HEADS.register_module()
194 class Shared2FCBBoxHead(ConvFCBBoxHead):
195 
196     def __init__(self, fc_out_channels=1024, *args, **kwargs):
197         super(Shared2FCBBoxHead, self).__init__(
198             num_shared_convs=0,
199             num_shared_fcs=2,
200             num_cls_convs=0,
201             num_cls_fcs=0,
202             num_reg_convs=0,
203             num_reg_fcs=0,
204             fc_out_channels=fc_out_channels,
205             *args,
206             **kwargs)
207 
208 
209 @HEADS.register_module()
210 class Shared4Conv1FCBBoxHead(ConvFCBBoxHead):
211 
212     def __init__(self, fc_out_channels=1024, *args, **kwargs):
213         super(Shared4Conv1FCBBoxHead, self).__init__(
214             num_shared_convs=4,
215             num_shared_fcs=1,
216             num_cls_convs=0,
217             num_cls_fcs=0,
218             num_reg_convs=0,
219             num_reg_fcs=0,
220             fc_out_channels=fc_out_channels,
221             *args,
222             **kwargs)
223
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py b/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py
--- a/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py
+++ b/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py
@@ -97,10 +97,16 @@
                 out_features=out_dim_reg)
 
         if init_cfg is None:
+            # when init_cfg is None,
+            # It has been set to
+            # [[dict(type='Normal', std=0.01, override=dict(name='fc_cls'))],
+            #  [dict(type='Normal', std=0.001, override=dict(name='fc_reg'))]
+            # after `super(ConvFCBBoxHead, self).__init__()`
+            # we only need to append additional configuration
+            # for `shared_fcs`, `cls_fcs` and `reg_fcs`
             self.init_cfg += [
                 dict(
                     type='Xavier',
-                    layer='Linear',
                     override=[
                         dict(name='shared_fcs'),
                         dict(name='cls_fcs'),

{"golden_diff": "diff --git a/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py b/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py\n--- a/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py\n+++ b/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py\n@@ -97,10 +97,16 @@\n                 out_features=out_dim_reg)\n \n         if init_cfg is None:\n+            # when init_cfg is None,\n+            # It has been set to\n+            # [[dict(type='Normal', std=0.01, override=dict(name='fc_cls'))],\n+            #  [dict(type='Normal', std=0.001, override=dict(name='fc_reg'))]\n+            # after `super(ConvFCBBoxHead, self).__init__()`\n+            # we only need to append additional configuration\n+            # for `shared_fcs`, `cls_fcs` and `reg_fcs`\n             self.init_cfg += [\n                 dict(\n                     type='Xavier',\n-                    layer='Linear',\n                     override=[\n                         dict(name='shared_fcs'),\n                         dict(name='cls_fcs'),\n", "issue": "[BUG]bug in ConvFCBBoxHead's init cfg.\nhttps://github.com/open-mmlab/mmdetection/blob/c88509cb9a73d6bd1edcba64eb924d3cf3cfe85d/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py#L103\r\n\r\nThis line will override initializers for fc_cls and fc_reg because they are also nn.Linear. \r\nOr is it what's intended? But I see the old way to initialize fc_cls and fc_reg is using Normal.\n", "before_files": [{"content": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch.nn as nn\nfrom mmcv.cnn import ConvModule\n\nfrom mmdet.models.builder import HEADS\nfrom mmdet.models.utils import build_linear_layer\nfrom .bbox_head import BBoxHead\n\n\n@HEADS.register_module()\nclass ConvFCBBoxHead(BBoxHead):\n    r\"\"\"More general bbox head, with shared conv and fc layers and two optional\n    separated branches.\n\n    .. code-block:: none\n\n                                    /-> cls convs -> cls fcs -> cls\n        shared convs -> shared fcs\n                                    \\-> reg convs -> reg fcs -> reg\n    \"\"\"  # noqa: W605\n\n    def __init__(self,\n                 num_shared_convs=0,\n                 num_shared_fcs=0,\n                 num_cls_convs=0,\n                 num_cls_fcs=0,\n                 num_reg_convs=0,\n                 num_reg_fcs=0,\n                 conv_out_channels=256,\n                 fc_out_channels=1024,\n                 conv_cfg=None,\n                 norm_cfg=None,\n                 init_cfg=None,\n                 *args,\n                 **kwargs):\n        super(ConvFCBBoxHead, self).__init__(\n            *args, init_cfg=init_cfg, **kwargs)\n        assert (num_shared_convs + num_shared_fcs + num_cls_convs +\n                num_cls_fcs + num_reg_convs + num_reg_fcs > 0)\n        if num_cls_convs > 0 or num_reg_convs > 0:\n            assert num_shared_fcs == 0\n        if not self.with_cls:\n            assert num_cls_convs == 0 and num_cls_fcs == 0\n        if not self.with_reg:\n            assert num_reg_convs == 0 and num_reg_fcs == 0\n        self.num_shared_convs = num_shared_convs\n        self.num_shared_fcs = num_shared_fcs\n        self.num_cls_convs = num_cls_convs\n        self.num_cls_fcs = num_cls_fcs\n        self.num_reg_convs = num_reg_convs\n        self.num_reg_fcs = num_reg_fcs\n        self.conv_out_channels = conv_out_channels\n        self.fc_out_channels = fc_out_channels\n        self.conv_cfg = conv_cfg\n        self.norm_cfg = norm_cfg\n\n        # add shared convs and fcs\n        self.shared_convs, self.shared_fcs, last_layer_dim = \\\n            self._add_conv_fc_branch(\n                self.num_shared_convs, self.num_shared_fcs, self.in_channels,\n                True)\n        self.shared_out_channels = last_layer_dim\n\n        # add cls specific branch\n        self.cls_convs, self.cls_fcs, self.cls_last_dim = \\\n            self._add_conv_fc_branch(\n                self.num_cls_convs, self.num_cls_fcs, self.shared_out_channels)\n\n        # add reg specific branch\n        self.reg_convs, self.reg_fcs, self.reg_last_dim = \\\n            self._add_conv_fc_branch(\n                self.num_reg_convs, self.num_reg_fcs, self.shared_out_channels)\n\n        if self.num_shared_fcs == 0 and not self.with_avg_pool:\n            if self.num_cls_fcs == 0:\n                self.cls_last_dim *= self.roi_feat_area\n            if self.num_reg_fcs == 0:\n                self.reg_last_dim *= self.roi_feat_area\n\n        self.relu = nn.ReLU(inplace=True)\n        # reconstruct fc_cls and fc_reg since input channels are changed\n        if self.with_cls:\n            if self.custom_cls_channels:\n                cls_channels = self.loss_cls.get_cls_channels(self.num_classes)\n            else:\n                cls_channels = self.num_classes + 1\n            self.fc_cls = build_linear_layer(\n                self.cls_predictor_cfg,\n                in_features=self.cls_last_dim,\n                out_features=cls_channels)\n        if self.with_reg:\n            out_dim_reg = (4 if self.reg_class_agnostic else 4 *\n                           self.num_classes)\n            self.fc_reg = build_linear_layer(\n                self.reg_predictor_cfg,\n                in_features=self.reg_last_dim,\n                out_features=out_dim_reg)\n\n        if init_cfg is None:\n            self.init_cfg += [\n                dict(\n                    type='Xavier',\n                    layer='Linear',\n                    override=[\n                        dict(name='shared_fcs'),\n                        dict(name='cls_fcs'),\n                        dict(name='reg_fcs')\n                    ])\n            ]\n\n    def _add_conv_fc_branch(self,\n                            num_branch_convs,\n                            num_branch_fcs,\n                            in_channels,\n                            is_shared=False):\n        \"\"\"Add shared or separable branch.\n\n        convs -> avg pool (optional) -> fcs\n        \"\"\"\n        last_layer_dim = in_channels\n        # add branch specific conv layers\n        branch_convs = nn.ModuleList()\n        if num_branch_convs > 0:\n            for i in range(num_branch_convs):\n                conv_in_channels = (\n                    last_layer_dim if i == 0 else self.conv_out_channels)\n                branch_convs.append(\n                    ConvModule(\n                        conv_in_channels,\n                        self.conv_out_channels,\n                        3,\n                        padding=1,\n                        conv_cfg=self.conv_cfg,\n                        norm_cfg=self.norm_cfg))\n            last_layer_dim = self.conv_out_channels\n        # add branch specific fc layers\n        branch_fcs = nn.ModuleList()\n        if num_branch_fcs > 0:\n            # for shared branch, only consider self.with_avg_pool\n            # for separated branches, also consider self.num_shared_fcs\n            if (is_shared\n                    or self.num_shared_fcs == 0) and not self.with_avg_pool:\n                last_layer_dim *= self.roi_feat_area\n            for i in range(num_branch_fcs):\n                fc_in_channels = (\n                    last_layer_dim if i == 0 else self.fc_out_channels)\n                branch_fcs.append(\n                    nn.Linear(fc_in_channels, self.fc_out_channels))\n            last_layer_dim = self.fc_out_channels\n        return branch_convs, branch_fcs, last_layer_dim\n\n    def forward(self, x):\n        # shared part\n        if self.num_shared_convs > 0:\n            for conv in self.shared_convs:\n                x = conv(x)\n\n        if self.num_shared_fcs > 0:\n            if self.with_avg_pool:\n                x = self.avg_pool(x)\n\n            x = x.flatten(1)\n\n            for fc in self.shared_fcs:\n                x = self.relu(fc(x))\n        # separate branches\n        x_cls = x\n        x_reg = x\n\n        for conv in self.cls_convs:\n            x_cls = conv(x_cls)\n        if x_cls.dim() > 2:\n            if self.with_avg_pool:\n                x_cls = self.avg_pool(x_cls)\n            x_cls = x_cls.flatten(1)\n        for fc in self.cls_fcs:\n            x_cls = self.relu(fc(x_cls))\n\n        for conv in self.reg_convs:\n            x_reg = conv(x_reg)\n        if x_reg.dim() > 2:\n            if self.with_avg_pool:\n                x_reg = self.avg_pool(x_reg)\n            x_reg = x_reg.flatten(1)\n        for fc in self.reg_fcs:\n            x_reg = self.relu(fc(x_reg))\n\n        cls_score = self.fc_cls(x_cls) if self.with_cls else None\n        bbox_pred = self.fc_reg(x_reg) if self.with_reg else None\n        return cls_score, bbox_pred\n\n\n@HEADS.register_module()\nclass Shared2FCBBoxHead(ConvFCBBoxHead):\n\n    def __init__(self, fc_out_channels=1024, *args, **kwargs):\n        super(Shared2FCBBoxHead, self).__init__(\n            num_shared_convs=0,\n            num_shared_fcs=2,\n            num_cls_convs=0,\n            num_cls_fcs=0,\n            num_reg_convs=0,\n            num_reg_fcs=0,\n            fc_out_channels=fc_out_channels,\n            *args,\n            **kwargs)\n\n\n@HEADS.register_module()\nclass Shared4Conv1FCBBoxHead(ConvFCBBoxHead):\n\n    def __init__(self, fc_out_channels=1024, *args, **kwargs):\n        super(Shared4Conv1FCBBoxHead, self).__init__(\n            num_shared_convs=4,\n            num_shared_fcs=1,\n            num_cls_convs=0,\n            num_cls_fcs=0,\n            num_reg_convs=0,\n            num_reg_fcs=0,\n            fc_out_channels=fc_out_channels,\n            *args,\n            **kwargs)\n", "path": "mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py"}], "after_files": [{"content": "# Copyright (c) OpenMMLab. All rights reserved.\nimport torch.nn as nn\nfrom mmcv.cnn import ConvModule\n\nfrom mmdet.models.builder import HEADS\nfrom mmdet.models.utils import build_linear_layer\nfrom .bbox_head import BBoxHead\n\n\n@HEADS.register_module()\nclass ConvFCBBoxHead(BBoxHead):\n    r\"\"\"More general bbox head, with shared conv and fc layers and two optional\n    separated branches.\n\n    .. code-block:: none\n\n                                    /-> cls convs -> cls fcs -> cls\n        shared convs -> shared fcs\n                                    \\-> reg convs -> reg fcs -> reg\n    \"\"\"  # noqa: W605\n\n    def __init__(self,\n                 num_shared_convs=0,\n                 num_shared_fcs=0,\n                 num_cls_convs=0,\n                 num_cls_fcs=0,\n                 num_reg_convs=0,\n                 num_reg_fcs=0,\n                 conv_out_channels=256,\n                 fc_out_channels=1024,\n                 conv_cfg=None,\n                 norm_cfg=None,\n                 init_cfg=None,\n                 *args,\n                 **kwargs):\n        super(ConvFCBBoxHead, self).__init__(\n            *args, init_cfg=init_cfg, **kwargs)\n        assert (num_shared_convs + num_shared_fcs + num_cls_convs +\n                num_cls_fcs + num_reg_convs + num_reg_fcs > 0)\n        if num_cls_convs > 0 or num_reg_convs > 0:\n            assert num_shared_fcs == 0\n        if not self.with_cls:\n            assert num_cls_convs == 0 and num_cls_fcs == 0\n        if not self.with_reg:\n            assert num_reg_convs == 0 and num_reg_fcs == 0\n        self.num_shared_convs = num_shared_convs\n        self.num_shared_fcs = num_shared_fcs\n        self.num_cls_convs = num_cls_convs\n        self.num_cls_fcs = num_cls_fcs\n        self.num_reg_convs = num_reg_convs\n        self.num_reg_fcs = num_reg_fcs\n        self.conv_out_channels = conv_out_channels\n        self.fc_out_channels = fc_out_channels\n        self.conv_cfg = conv_cfg\n        self.norm_cfg = norm_cfg\n\n        # add shared convs and fcs\n        self.shared_convs, self.shared_fcs, last_layer_dim = \\\n            self._add_conv_fc_branch(\n                self.num_shared_convs, self.num_shared_fcs, self.in_channels,\n                True)\n        self.shared_out_channels = last_layer_dim\n\n        # add cls specific branch\n        self.cls_convs, self.cls_fcs, self.cls_last_dim = \\\n            self._add_conv_fc_branch(\n                self.num_cls_convs, self.num_cls_fcs, self.shared_out_channels)\n\n        # add reg specific branch\n        self.reg_convs, self.reg_fcs, self.reg_last_dim = \\\n            self._add_conv_fc_branch(\n                self.num_reg_convs, self.num_reg_fcs, self.shared_out_channels)\n\n        if self.num_shared_fcs == 0 and not self.with_avg_pool:\n            if self.num_cls_fcs == 0:\n                self.cls_last_dim *= self.roi_feat_area\n            if self.num_reg_fcs == 0:\n                self.reg_last_dim *= self.roi_feat_area\n\n        self.relu = nn.ReLU(inplace=True)\n        # reconstruct fc_cls and fc_reg since input channels are changed\n        if self.with_cls:\n            if self.custom_cls_channels:\n                cls_channels = self.loss_cls.get_cls_channels(self.num_classes)\n            else:\n                cls_channels = self.num_classes + 1\n            self.fc_cls = build_linear_layer(\n                self.cls_predictor_cfg,\n                in_features=self.cls_last_dim,\n                out_features=cls_channels)\n        if self.with_reg:\n            out_dim_reg = (4 if self.reg_class_agnostic else 4 *\n                           self.num_classes)\n            self.fc_reg = build_linear_layer(\n                self.reg_predictor_cfg,\n                in_features=self.reg_last_dim,\n                out_features=out_dim_reg)\n\n        if init_cfg is None:\n            # when init_cfg is None,\n            # It has been set to\n            # [[dict(type='Normal', std=0.01, override=dict(name='fc_cls'))],\n            #  [dict(type='Normal', std=0.001, override=dict(name='fc_reg'))]\n            # after `super(ConvFCBBoxHead, self).__init__()`\n            # we only need to append additional configuration\n            # for `shared_fcs`, `cls_fcs` and `reg_fcs`\n            self.init_cfg += [\n                dict(\n                    type='Xavier',\n                    override=[\n                        dict(name='shared_fcs'),\n                        dict(name='cls_fcs'),\n                        dict(name='reg_fcs')\n                    ])\n            ]\n\n    def _add_conv_fc_branch(self,\n                            num_branch_convs,\n                            num_branch_fcs,\n                            in_channels,\n                            is_shared=False):\n        \"\"\"Add shared or separable branch.\n\n        convs -> avg pool (optional) -> fcs\n        \"\"\"\n        last_layer_dim = in_channels\n        # add branch specific conv layers\n        branch_convs = nn.ModuleList()\n        if num_branch_convs > 0:\n            for i in range(num_branch_convs):\n                conv_in_channels = (\n                    last_layer_dim if i == 0 else self.conv_out_channels)\n                branch_convs.append(\n                    ConvModule(\n                        conv_in_channels,\n                        self.conv_out_channels,\n                        3,\n                        padding=1,\n                        conv_cfg=self.conv_cfg,\n                        norm_cfg=self.norm_cfg))\n            last_layer_dim = self.conv_out_channels\n        # add branch specific fc layers\n        branch_fcs = nn.ModuleList()\n        if num_branch_fcs > 0:\n            # for shared branch, only consider self.with_avg_pool\n            # for separated branches, also consider self.num_shared_fcs\n            if (is_shared\n                    or self.num_shared_fcs == 0) and not self.with_avg_pool:\n                last_layer_dim *= self.roi_feat_area\n            for i in range(num_branch_fcs):\n                fc_in_channels = (\n                    last_layer_dim if i == 0 else self.fc_out_channels)\n                branch_fcs.append(\n                    nn.Linear(fc_in_channels, self.fc_out_channels))\n            last_layer_dim = self.fc_out_channels\n        return branch_convs, branch_fcs, last_layer_dim\n\n    def forward(self, x):\n        # shared part\n        if self.num_shared_convs > 0:\n            for conv in self.shared_convs:\n                x = conv(x)\n\n        if self.num_shared_fcs > 0:\n            if self.with_avg_pool:\n                x = self.avg_pool(x)\n\n            x = x.flatten(1)\n\n            for fc in self.shared_fcs:\n                x = self.relu(fc(x))\n        # separate branches\n        x_cls = x\n        x_reg = x\n\n        for conv in self.cls_convs:\n            x_cls = conv(x_cls)\n        if x_cls.dim() > 2:\n            if self.with_avg_pool:\n                x_cls = self.avg_pool(x_cls)\n            x_cls = x_cls.flatten(1)\n        for fc in self.cls_fcs:\n            x_cls = self.relu(fc(x_cls))\n\n        for conv in self.reg_convs:\n            x_reg = conv(x_reg)\n        if x_reg.dim() > 2:\n            if self.with_avg_pool:\n                x_reg = self.avg_pool(x_reg)\n            x_reg = x_reg.flatten(1)\n        for fc in self.reg_fcs:\n            x_reg = self.relu(fc(x_reg))\n\n        cls_score = self.fc_cls(x_cls) if self.with_cls else None\n        bbox_pred = self.fc_reg(x_reg) if self.with_reg else None\n        return cls_score, bbox_pred\n\n\n@HEADS.register_module()\nclass Shared2FCBBoxHead(ConvFCBBoxHead):\n\n    def __init__(self, fc_out_channels=1024, *args, **kwargs):\n        super(Shared2FCBBoxHead, self).__init__(\n            num_shared_convs=0,\n            num_shared_fcs=2,\n            num_cls_convs=0,\n            num_cls_fcs=0,\n            num_reg_convs=0,\n            num_reg_fcs=0,\n            fc_out_channels=fc_out_channels,\n            *args,\n            **kwargs)\n\n\n@HEADS.register_module()\nclass Shared4Conv1FCBBoxHead(ConvFCBBoxHead):\n\n    def __init__(self, fc_out_channels=1024, *args, **kwargs):\n        super(Shared4Conv1FCBBoxHead, self).__init__(\n            num_shared_convs=4,\n            num_shared_fcs=1,\n            num_cls_convs=0,\n            num_cls_fcs=0,\n            num_reg_convs=0,\n            num_reg_fcs=0,\n            fc_out_channels=fc_out_channels,\n            *args,\n            **kwargs)\n", "path": "mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py"}]}