We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Beta update assert error in dynamic rcnn
When the beta updates, new beta will be the median of the beta_history. It might be 0.0 but the beta used in loss function should be greater than 0.
The assert error occurred.
[https://github.com/open-mmlab/mmdetection/blob/5d07dda8719b0c67c11ad015410bc111e9f90200/mmdet/models/roi_heads/dynamic_roi_head.py#L144](url)
The code to fix it could be as follows:
`if np.abs(np.median(self.beta_history)) < 1e-15:
            new_beta = self.bbox_head.loss_bbox.beta
  else:
            new_beta = min(self.train_cfg.dynamic_rcnn.initial_beta,
                       np.median(self.beta_history))`
I am willing to create a PR to fix it as well.
Beta update assert error in dynamic rcnn
When the beta updates, new beta will be the median of the beta_history. It might be 0.0 but the beta used in loss function should be greater than 0.
The assert error occurred.
[https://github.com/open-mmlab/mmdetection/blob/5d07dda8719b0c67c11ad015410bc111e9f90200/mmdet/models/roi_heads/dynamic_roi_head.py#L144](url)
The code to fix it could be as follows:
`if np.abs(np.median(self.beta_history)) < 1e-15:
            new_beta = self.bbox_head.loss_bbox.beta
  else:
            new_beta = min(self.train_cfg.dynamic_rcnn.initial_beta,
                       np.median(self.beta_history))`
I am willing to create a PR to fix it as well.

--- 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/dynamic_roi_head.py`
Content:
```
1 import numpy as np
2 import torch
3 
4 from mmdet.core import bbox2roi
5 from mmdet.models.losses import SmoothL1Loss
6 from ..builder import HEADS
7 from .standard_roi_head import StandardRoIHead
8 
9 
10 @HEADS.register_module()
11 class DynamicRoIHead(StandardRoIHead):
12     """RoI head for `Dynamic R-CNN <https://arxiv.org/abs/2004.06002>`_."""
13 
14     def __init__(self, **kwargs):
15         super(DynamicRoIHead, self).__init__(**kwargs)
16         assert isinstance(self.bbox_head.loss_bbox, SmoothL1Loss)
17         # the IoU history of the past `update_iter_interval` iterations
18         self.iou_history = []
19         # the beta history of the past `update_iter_interval` iterations
20         self.beta_history = []
21 
22     def forward_train(self,
23                       x,
24                       img_metas,
25                       proposal_list,
26                       gt_bboxes,
27                       gt_labels,
28                       gt_bboxes_ignore=None,
29                       gt_masks=None):
30         """Forward function for training.
31 
32         Args:
33             x (list[Tensor]): list of multi-level img features.
34 
35             img_metas (list[dict]): list of image info dict where each dict
36                 has: 'img_shape', 'scale_factor', 'flip', and may also contain
37                 'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'.
38                 For details on the values of these keys see
39                 `mmdet/datasets/pipelines/formatting.py:Collect`.
40 
41             proposals (list[Tensors]): list of region proposals.
42 
43             gt_bboxes (list[Tensor]): each item are the truth boxes for each
44                 image in [tl_x, tl_y, br_x, br_y] format.
45 
46             gt_labels (list[Tensor]): class indices corresponding to each box
47 
48             gt_bboxes_ignore (None | list[Tensor]): specify which bounding
49                 boxes can be ignored when computing the loss.
50 
51             gt_masks (None | Tensor) : true segmentation masks for each box
52                 used if the architecture supports a segmentation task.
53 
54         Returns:
55             dict[str, Tensor]: a dictionary of loss components
56         """
57         # assign gts and sample proposals
58         if self.with_bbox or self.with_mask:
59             num_imgs = len(img_metas)
60             if gt_bboxes_ignore is None:
61                 gt_bboxes_ignore = [None for _ in range(num_imgs)]
62             sampling_results = []
63             cur_iou = []
64             for i in range(num_imgs):
65                 assign_result = self.bbox_assigner.assign(
66                     proposal_list[i], gt_bboxes[i], gt_bboxes_ignore[i],
67                     gt_labels[i])
68                 sampling_result = self.bbox_sampler.sample(
69                     assign_result,
70                     proposal_list[i],
71                     gt_bboxes[i],
72                     gt_labels[i],
73                     feats=[lvl_feat[i][None] for lvl_feat in x])
74                 # record the `iou_topk`-th largest IoU in an image
75                 iou_topk = min(self.train_cfg.dynamic_rcnn.iou_topk,
76                                len(assign_result.max_overlaps))
77                 ious, _ = torch.topk(assign_result.max_overlaps, iou_topk)
78                 cur_iou.append(ious[-1].item())
79                 sampling_results.append(sampling_result)
80             # average the current IoUs over images
81             cur_iou = np.mean(cur_iou)
82             self.iou_history.append(cur_iou)
83 
84         losses = dict()
85         # bbox head forward and loss
86         if self.with_bbox:
87             bbox_results = self._bbox_forward_train(x, sampling_results,
88                                                     gt_bboxes, gt_labels,
89                                                     img_metas)
90             losses.update(bbox_results['loss_bbox'])
91 
92         # mask head forward and loss
93         if self.with_mask:
94             mask_results = self._mask_forward_train(x, sampling_results,
95                                                     bbox_results['bbox_feats'],
96                                                     gt_masks, img_metas)
97             losses.update(mask_results['loss_mask'])
98 
99         # update IoU threshold and SmoothL1 beta
100         update_iter_interval = self.train_cfg.dynamic_rcnn.update_iter_interval
101         if len(self.iou_history) % update_iter_interval == 0:
102             new_iou_thr, new_beta = self.update_hyperparameters()
103 
104         return losses
105 
106     def _bbox_forward_train(self, x, sampling_results, gt_bboxes, gt_labels,
107                             img_metas):
108         num_imgs = len(img_metas)
109         rois = bbox2roi([res.bboxes for res in sampling_results])
110         bbox_results = self._bbox_forward(x, rois)
111 
112         bbox_targets = self.bbox_head.get_targets(sampling_results, gt_bboxes,
113                                                   gt_labels, self.train_cfg)
114         # record the `beta_topk`-th smallest target
115         # `bbox_targets[2]` and `bbox_targets[3]` stand for bbox_targets
116         # and bbox_weights, respectively
117         pos_inds = bbox_targets[3][:, 0].nonzero().squeeze(1)
118         num_pos = len(pos_inds)
119         cur_target = bbox_targets[2][pos_inds, :2].abs().mean(dim=1)
120         beta_topk = min(self.train_cfg.dynamic_rcnn.beta_topk * num_imgs,
121                         num_pos)
122         cur_target = torch.kthvalue(cur_target, beta_topk)[0].item()
123         self.beta_history.append(cur_target)
124         loss_bbox = self.bbox_head.loss(bbox_results['cls_score'],
125                                         bbox_results['bbox_pred'], rois,
126                                         *bbox_targets)
127 
128         bbox_results.update(loss_bbox=loss_bbox)
129         return bbox_results
130 
131     def update_hyperparameters(self):
132         """Update hyperparameters like IoU thresholds for assigner and beta for
133         SmoothL1 loss based on the training statistics.
134 
135         Returns:
136             tuple[float]: the updated ``iou_thr`` and ``beta``.
137         """
138         new_iou_thr = max(self.train_cfg.dynamic_rcnn.initial_iou,
139                           np.mean(self.iou_history))
140         self.iou_history = []
141         self.bbox_assigner.pos_iou_thr = new_iou_thr
142         self.bbox_assigner.neg_iou_thr = new_iou_thr
143         self.bbox_assigner.min_pos_iou = new_iou_thr
144         new_beta = min(self.train_cfg.dynamic_rcnn.initial_beta,
145                        np.median(self.beta_history))
146         self.beta_history = []
147         self.bbox_head.loss_bbox.beta = new_beta
148         return new_iou_thr, new_beta
149
```
--- 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/dynamic_roi_head.py b/mmdet/models/roi_heads/dynamic_roi_head.py
--- a/mmdet/models/roi_heads/dynamic_roi_head.py
+++ b/mmdet/models/roi_heads/dynamic_roi_head.py
@@ -6,6 +6,8 @@
 from ..builder import HEADS
 from .standard_roi_head import StandardRoIHead
 
+EPS = 1e-15
+
 
 @HEADS.register_module()
 class DynamicRoIHead(StandardRoIHead):
@@ -141,8 +143,12 @@
         self.bbox_assigner.pos_iou_thr = new_iou_thr
         self.bbox_assigner.neg_iou_thr = new_iou_thr
         self.bbox_assigner.min_pos_iou = new_iou_thr
-        new_beta = min(self.train_cfg.dynamic_rcnn.initial_beta,
-                       np.median(self.beta_history))
+        if (np.median(self.beta_history) < EPS):
+            # avoid 0 or too small value for new_beta
+            new_beta = self.bbox_head.loss_bbox.beta
+        else:
+            new_beta = min(self.train_cfg.dynamic_rcnn.initial_beta,
+                           np.median(self.beta_history))
         self.beta_history = []
         self.bbox_head.loss_bbox.beta = new_beta
         return new_iou_thr, new_beta

{"golden_diff": "diff --git a/mmdet/models/roi_heads/dynamic_roi_head.py b/mmdet/models/roi_heads/dynamic_roi_head.py\n--- a/mmdet/models/roi_heads/dynamic_roi_head.py\n+++ b/mmdet/models/roi_heads/dynamic_roi_head.py\n@@ -6,6 +6,8 @@\n from ..builder import HEADS\n from .standard_roi_head import StandardRoIHead\n \n+EPS = 1e-15\n+\n \n @HEADS.register_module()\n class DynamicRoIHead(StandardRoIHead):\n@@ -141,8 +143,12 @@\n         self.bbox_assigner.pos_iou_thr = new_iou_thr\n         self.bbox_assigner.neg_iou_thr = new_iou_thr\n         self.bbox_assigner.min_pos_iou = new_iou_thr\n-        new_beta = min(self.train_cfg.dynamic_rcnn.initial_beta,\n-                       np.median(self.beta_history))\n+        if (np.median(self.beta_history) < EPS):\n+            # avoid 0 or too small value for new_beta\n+            new_beta = self.bbox_head.loss_bbox.beta\n+        else:\n+            new_beta = min(self.train_cfg.dynamic_rcnn.initial_beta,\n+                           np.median(self.beta_history))\n         self.beta_history = []\n         self.bbox_head.loss_bbox.beta = new_beta\n         return new_iou_thr, new_beta\n", "issue": "Beta update assert error in dynamic rcnn\nWhen the beta updates, new beta will be the median of the beta_history. It might be 0.0 but the beta used in loss function should be greater than 0.\r\nThe assert error occurred.\r\n[https://github.com/open-mmlab/mmdetection/blob/5d07dda8719b0c67c11ad015410bc111e9f90200/mmdet/models/roi_heads/dynamic_roi_head.py#L144](url)\r\nThe code to fix it could be as follows:\r\n`if np.abs(np.median(self.beta_history)) < 1e-15:\r\n            new_beta = self.bbox_head.loss_bbox.beta\r\n  else:\r\n            new_beta = min(self.train_cfg.dynamic_rcnn.initial_beta,\r\n                       np.median(self.beta_history))`\r\nI am willing to create a PR to fix it as well.\nBeta update assert error in dynamic rcnn\nWhen the beta updates, new beta will be the median of the beta_history. It might be 0.0 but the beta used in loss function should be greater than 0.\r\nThe assert error occurred.\r\n[https://github.com/open-mmlab/mmdetection/blob/5d07dda8719b0c67c11ad015410bc111e9f90200/mmdet/models/roi_heads/dynamic_roi_head.py#L144](url)\r\nThe code to fix it could be as follows:\r\n`if np.abs(np.median(self.beta_history)) < 1e-15:\r\n            new_beta = self.bbox_head.loss_bbox.beta\r\n  else:\r\n            new_beta = min(self.train_cfg.dynamic_rcnn.initial_beta,\r\n                       np.median(self.beta_history))`\r\nI am willing to create a PR to fix it as well.\n", "before_files": [{"content": "import numpy as np\nimport torch\n\nfrom mmdet.core import bbox2roi\nfrom mmdet.models.losses import SmoothL1Loss\nfrom ..builder import HEADS\nfrom .standard_roi_head import StandardRoIHead\n\n\n@HEADS.register_module()\nclass DynamicRoIHead(StandardRoIHead):\n    \"\"\"RoI head for `Dynamic R-CNN <https://arxiv.org/abs/2004.06002>`_.\"\"\"\n\n    def __init__(self, **kwargs):\n        super(DynamicRoIHead, self).__init__(**kwargs)\n        assert isinstance(self.bbox_head.loss_bbox, SmoothL1Loss)\n        # the IoU history of the past `update_iter_interval` iterations\n        self.iou_history = []\n        # the beta history of the past `update_iter_interval` iterations\n        self.beta_history = []\n\n    def forward_train(self,\n                      x,\n                      img_metas,\n                      proposal_list,\n                      gt_bboxes,\n                      gt_labels,\n                      gt_bboxes_ignore=None,\n                      gt_masks=None):\n        \"\"\"Forward function for training.\n\n        Args:\n            x (list[Tensor]): list of multi-level img features.\n\n            img_metas (list[dict]): list of image info dict where each dict\n                has: 'img_shape', 'scale_factor', 'flip', and may also contain\n                'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'.\n                For details on the values of these keys see\n                `mmdet/datasets/pipelines/formatting.py:Collect`.\n\n            proposals (list[Tensors]): list of region proposals.\n\n            gt_bboxes (list[Tensor]): each item are the truth boxes for each\n                image in [tl_x, tl_y, br_x, br_y] format.\n\n            gt_labels (list[Tensor]): class indices corresponding to each box\n\n            gt_bboxes_ignore (None | list[Tensor]): specify which bounding\n                boxes can be ignored when computing the loss.\n\n            gt_masks (None | Tensor) : true segmentation masks for each box\n                used if the architecture supports a segmentation task.\n\n        Returns:\n            dict[str, Tensor]: a dictionary of loss components\n        \"\"\"\n        # assign gts and sample proposals\n        if self.with_bbox or self.with_mask:\n            num_imgs = len(img_metas)\n            if gt_bboxes_ignore is None:\n                gt_bboxes_ignore = [None for _ in range(num_imgs)]\n            sampling_results = []\n            cur_iou = []\n            for i in range(num_imgs):\n                assign_result = self.bbox_assigner.assign(\n                    proposal_list[i], gt_bboxes[i], gt_bboxes_ignore[i],\n                    gt_labels[i])\n                sampling_result = self.bbox_sampler.sample(\n                    assign_result,\n                    proposal_list[i],\n                    gt_bboxes[i],\n                    gt_labels[i],\n                    feats=[lvl_feat[i][None] for lvl_feat in x])\n                # record the `iou_topk`-th largest IoU in an image\n                iou_topk = min(self.train_cfg.dynamic_rcnn.iou_topk,\n                               len(assign_result.max_overlaps))\n                ious, _ = torch.topk(assign_result.max_overlaps, iou_topk)\n                cur_iou.append(ious[-1].item())\n                sampling_results.append(sampling_result)\n            # average the current IoUs over images\n            cur_iou = np.mean(cur_iou)\n            self.iou_history.append(cur_iou)\n\n        losses = dict()\n        # bbox head forward and loss\n        if self.with_bbox:\n            bbox_results = self._bbox_forward_train(x, sampling_results,\n                                                    gt_bboxes, gt_labels,\n                                                    img_metas)\n            losses.update(bbox_results['loss_bbox'])\n\n        # mask head forward and loss\n        if self.with_mask:\n            mask_results = self._mask_forward_train(x, sampling_results,\n                                                    bbox_results['bbox_feats'],\n                                                    gt_masks, img_metas)\n            losses.update(mask_results['loss_mask'])\n\n        # update IoU threshold and SmoothL1 beta\n        update_iter_interval = self.train_cfg.dynamic_rcnn.update_iter_interval\n        if len(self.iou_history) % update_iter_interval == 0:\n            new_iou_thr, new_beta = self.update_hyperparameters()\n\n        return losses\n\n    def _bbox_forward_train(self, x, sampling_results, gt_bboxes, gt_labels,\n                            img_metas):\n        num_imgs = len(img_metas)\n        rois = bbox2roi([res.bboxes for res in sampling_results])\n        bbox_results = self._bbox_forward(x, rois)\n\n        bbox_targets = self.bbox_head.get_targets(sampling_results, gt_bboxes,\n                                                  gt_labels, self.train_cfg)\n        # record the `beta_topk`-th smallest target\n        # `bbox_targets[2]` and `bbox_targets[3]` stand for bbox_targets\n        # and bbox_weights, respectively\n        pos_inds = bbox_targets[3][:, 0].nonzero().squeeze(1)\n        num_pos = len(pos_inds)\n        cur_target = bbox_targets[2][pos_inds, :2].abs().mean(dim=1)\n        beta_topk = min(self.train_cfg.dynamic_rcnn.beta_topk * num_imgs,\n                        num_pos)\n        cur_target = torch.kthvalue(cur_target, beta_topk)[0].item()\n        self.beta_history.append(cur_target)\n        loss_bbox = self.bbox_head.loss(bbox_results['cls_score'],\n                                        bbox_results['bbox_pred'], rois,\n                                        *bbox_targets)\n\n        bbox_results.update(loss_bbox=loss_bbox)\n        return bbox_results\n\n    def update_hyperparameters(self):\n        \"\"\"Update hyperparameters like IoU thresholds for assigner and beta for\n        SmoothL1 loss based on the training statistics.\n\n        Returns:\n            tuple[float]: the updated ``iou_thr`` and ``beta``.\n        \"\"\"\n        new_iou_thr = max(self.train_cfg.dynamic_rcnn.initial_iou,\n                          np.mean(self.iou_history))\n        self.iou_history = []\n        self.bbox_assigner.pos_iou_thr = new_iou_thr\n        self.bbox_assigner.neg_iou_thr = new_iou_thr\n        self.bbox_assigner.min_pos_iou = new_iou_thr\n        new_beta = min(self.train_cfg.dynamic_rcnn.initial_beta,\n                       np.median(self.beta_history))\n        self.beta_history = []\n        self.bbox_head.loss_bbox.beta = new_beta\n        return new_iou_thr, new_beta\n", "path": "mmdet/models/roi_heads/dynamic_roi_head.py"}], "after_files": [{"content": "import numpy as np\nimport torch\n\nfrom mmdet.core import bbox2roi\nfrom mmdet.models.losses import SmoothL1Loss\nfrom ..builder import HEADS\nfrom .standard_roi_head import StandardRoIHead\n\nEPS = 1e-15\n\n\n@HEADS.register_module()\nclass DynamicRoIHead(StandardRoIHead):\n    \"\"\"RoI head for `Dynamic R-CNN <https://arxiv.org/abs/2004.06002>`_.\"\"\"\n\n    def __init__(self, **kwargs):\n        super(DynamicRoIHead, self).__init__(**kwargs)\n        assert isinstance(self.bbox_head.loss_bbox, SmoothL1Loss)\n        # the IoU history of the past `update_iter_interval` iterations\n        self.iou_history = []\n        # the beta history of the past `update_iter_interval` iterations\n        self.beta_history = []\n\n    def forward_train(self,\n                      x,\n                      img_metas,\n                      proposal_list,\n                      gt_bboxes,\n                      gt_labels,\n                      gt_bboxes_ignore=None,\n                      gt_masks=None):\n        \"\"\"Forward function for training.\n\n        Args:\n            x (list[Tensor]): list of multi-level img features.\n\n            img_metas (list[dict]): list of image info dict where each dict\n                has: 'img_shape', 'scale_factor', 'flip', and may also contain\n                'filename', 'ori_shape', 'pad_shape', and 'img_norm_cfg'.\n                For details on the values of these keys see\n                `mmdet/datasets/pipelines/formatting.py:Collect`.\n\n            proposals (list[Tensors]): list of region proposals.\n\n            gt_bboxes (list[Tensor]): each item are the truth boxes for each\n                image in [tl_x, tl_y, br_x, br_y] format.\n\n            gt_labels (list[Tensor]): class indices corresponding to each box\n\n            gt_bboxes_ignore (None | list[Tensor]): specify which bounding\n                boxes can be ignored when computing the loss.\n\n            gt_masks (None | Tensor) : true segmentation masks for each box\n                used if the architecture supports a segmentation task.\n\n        Returns:\n            dict[str, Tensor]: a dictionary of loss components\n        \"\"\"\n        # assign gts and sample proposals\n        if self.with_bbox or self.with_mask:\n            num_imgs = len(img_metas)\n            if gt_bboxes_ignore is None:\n                gt_bboxes_ignore = [None for _ in range(num_imgs)]\n            sampling_results = []\n            cur_iou = []\n            for i in range(num_imgs):\n                assign_result = self.bbox_assigner.assign(\n                    proposal_list[i], gt_bboxes[i], gt_bboxes_ignore[i],\n                    gt_labels[i])\n                sampling_result = self.bbox_sampler.sample(\n                    assign_result,\n                    proposal_list[i],\n                    gt_bboxes[i],\n                    gt_labels[i],\n                    feats=[lvl_feat[i][None] for lvl_feat in x])\n                # record the `iou_topk`-th largest IoU in an image\n                iou_topk = min(self.train_cfg.dynamic_rcnn.iou_topk,\n                               len(assign_result.max_overlaps))\n                ious, _ = torch.topk(assign_result.max_overlaps, iou_topk)\n                cur_iou.append(ious[-1].item())\n                sampling_results.append(sampling_result)\n            # average the current IoUs over images\n            cur_iou = np.mean(cur_iou)\n            self.iou_history.append(cur_iou)\n\n        losses = dict()\n        # bbox head forward and loss\n        if self.with_bbox:\n            bbox_results = self._bbox_forward_train(x, sampling_results,\n                                                    gt_bboxes, gt_labels,\n                                                    img_metas)\n            losses.update(bbox_results['loss_bbox'])\n\n        # mask head forward and loss\n        if self.with_mask:\n            mask_results = self._mask_forward_train(x, sampling_results,\n                                                    bbox_results['bbox_feats'],\n                                                    gt_masks, img_metas)\n            losses.update(mask_results['loss_mask'])\n\n        # update IoU threshold and SmoothL1 beta\n        update_iter_interval = self.train_cfg.dynamic_rcnn.update_iter_interval\n        if len(self.iou_history) % update_iter_interval == 0:\n            new_iou_thr, new_beta = self.update_hyperparameters()\n\n        return losses\n\n    def _bbox_forward_train(self, x, sampling_results, gt_bboxes, gt_labels,\n                            img_metas):\n        num_imgs = len(img_metas)\n        rois = bbox2roi([res.bboxes for res in sampling_results])\n        bbox_results = self._bbox_forward(x, rois)\n\n        bbox_targets = self.bbox_head.get_targets(sampling_results, gt_bboxes,\n                                                  gt_labels, self.train_cfg)\n        # record the `beta_topk`-th smallest target\n        # `bbox_targets[2]` and `bbox_targets[3]` stand for bbox_targets\n        # and bbox_weights, respectively\n        pos_inds = bbox_targets[3][:, 0].nonzero().squeeze(1)\n        num_pos = len(pos_inds)\n        cur_target = bbox_targets[2][pos_inds, :2].abs().mean(dim=1)\n        beta_topk = min(self.train_cfg.dynamic_rcnn.beta_topk * num_imgs,\n                        num_pos)\n        cur_target = torch.kthvalue(cur_target, beta_topk)[0].item()\n        self.beta_history.append(cur_target)\n        loss_bbox = self.bbox_head.loss(bbox_results['cls_score'],\n                                        bbox_results['bbox_pred'], rois,\n                                        *bbox_targets)\n\n        bbox_results.update(loss_bbox=loss_bbox)\n        return bbox_results\n\n    def update_hyperparameters(self):\n        \"\"\"Update hyperparameters like IoU thresholds for assigner and beta for\n        SmoothL1 loss based on the training statistics.\n\n        Returns:\n            tuple[float]: the updated ``iou_thr`` and ``beta``.\n        \"\"\"\n        new_iou_thr = max(self.train_cfg.dynamic_rcnn.initial_iou,\n                          np.mean(self.iou_history))\n        self.iou_history = []\n        self.bbox_assigner.pos_iou_thr = new_iou_thr\n        self.bbox_assigner.neg_iou_thr = new_iou_thr\n        self.bbox_assigner.min_pos_iou = new_iou_thr\n        if (np.median(self.beta_history) < EPS):\n            # avoid 0 or too small value for new_beta\n            new_beta = self.bbox_head.loss_bbox.beta\n        else:\n            new_beta = min(self.train_cfg.dynamic_rcnn.initial_beta,\n                           np.median(self.beta_history))\n        self.beta_history = []\n        self.bbox_head.loss_bbox.beta = new_beta\n        return new_iou_thr, new_beta\n", "path": "mmdet/models/roi_heads/dynamic_roi_head.py"}]}