We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Write image name to pickle file
Hi MMOCR team,
Thank you for this awesome framework. I have a task to get coordinate of bounding box from Textsnake model, so I use --out argument in test.py to export to a pickle file. But when I load this pickle, I just got ‘boundary_result’ and don't know this ‘boundary_result’ belongs to which image. How can I get the image to write to the pickle file? Thank you.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mmocr/models/textdet/dense_heads/head_mixin.py`
Content:
```
1 # Copyright (c) OpenMMLab. All rights reserved.
2 import numpy as np
3 
4 from mmocr.models.builder import HEADS
5 from mmocr.models.textdet.postprocess import decode
6 from mmocr.utils import check_argument
7 
8 
9 @HEADS.register_module()
10 class HeadMixin:
11     """The head minxin for dbnet and pannet heads."""
12 
13     def resize_boundary(self, boundaries, scale_factor):
14         """Rescale boundaries via scale_factor.
15 
16         Args:
17             boundaries (list[list[float]]): The boundary list. Each boundary
18             with size 2k+1 with k>=4.
19             scale_factor(ndarray): The scale factor of size (4,).
20 
21         Returns:
22             boundaries (list[list[float]]): The scaled boundaries.
23         """
24         assert check_argument.is_2dlist(boundaries)
25         assert isinstance(scale_factor, np.ndarray)
26         assert scale_factor.shape[0] == 4
27 
28         for b in boundaries:
29             sz = len(b)
30             check_argument.valid_boundary(b, True)
31             b[:sz -
32               1] = (np.array(b[:sz - 1]) *
33                     (np.tile(scale_factor[:2], int(
34                         (sz - 1) / 2)).reshape(1, sz - 1))).flatten().tolist()
35         return boundaries
36 
37     def get_boundary(self, score_maps, img_metas, rescale):
38         """Compute text boundaries via post processing.
39 
40         Args:
41             score_maps (Tensor): The text score map.
42             img_metas (dict): The image meta info.
43             rescale (bool): Rescale boundaries to the original image resolution
44                 if true, and keep the score_maps resolution if false.
45 
46         Returns:
47             results (dict): The result dict.
48         """
49 
50         assert check_argument.is_type_list(img_metas, dict)
51         assert isinstance(rescale, bool)
52 
53         score_maps = score_maps.squeeze()
54         boundaries = decode(
55             decoding_type=self.decoding_type,
56             preds=score_maps,
57             text_repr_type=self.text_repr_type)
58         if rescale:
59             boundaries = self.resize_boundary(
60                 boundaries,
61                 1.0 / self.downsample_ratio / img_metas[0]['scale_factor'])
62         results = dict(boundary_result=boundaries)
63         return results
64 
65     def loss(self, pred_maps, **kwargs):
66         """Compute the loss for text detection.
67 
68         Args:
69             pred_maps (tensor): The input score maps of NxCxHxW.
70 
71         Returns:
72             losses (dict): The dict for losses.
73         """
74         losses = self.loss_module(pred_maps, self.downsample_ratio, **kwargs)
75         return losses
76
```
--- 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/mmocr/models/textdet/dense_heads/head_mixin.py b/mmocr/models/textdet/dense_heads/head_mixin.py
--- a/mmocr/models/textdet/dense_heads/head_mixin.py
+++ b/mmocr/models/textdet/dense_heads/head_mixin.py
@@ -59,7 +59,9 @@
             boundaries = self.resize_boundary(
                 boundaries,
                 1.0 / self.downsample_ratio / img_metas[0]['scale_factor'])
-        results = dict(boundary_result=boundaries)
+        results = dict(
+            boundary_result=boundaries, filename=img_metas[0]['filename'])
+
         return results
 
     def loss(self, pred_maps, **kwargs):

{"golden_diff": "diff --git a/mmocr/models/textdet/dense_heads/head_mixin.py b/mmocr/models/textdet/dense_heads/head_mixin.py\n--- a/mmocr/models/textdet/dense_heads/head_mixin.py\n+++ b/mmocr/models/textdet/dense_heads/head_mixin.py\n@@ -59,7 +59,9 @@\n             boundaries = self.resize_boundary(\n                 boundaries,\n                 1.0 / self.downsample_ratio / img_metas[0]['scale_factor'])\n-        results = dict(boundary_result=boundaries)\n+        results = dict(\n+            boundary_result=boundaries, filename=img_metas[0]['filename'])\n+\n         return results\n \n     def loss(self, pred_maps, **kwargs):\n", "issue": "Write image name to pickle file\nHi MMOCR team,\nThank you for this awesome framework. I have a task to get coordinate of bounding box from Textsnake model, so I use --out argument in test.py to export to a pickle file. But when I load this pickle, I just got \u2018boundary_result\u2019 and don't know this \u2018boundary_result\u2019 belongs to which image. How can I get the image to write to the pickle file? Thank you.\n", "before_files": [{"content": "# Copyright (c) OpenMMLab. All rights reserved.\nimport numpy as np\n\nfrom mmocr.models.builder import HEADS\nfrom mmocr.models.textdet.postprocess import decode\nfrom mmocr.utils import check_argument\n\n\n@HEADS.register_module()\nclass HeadMixin:\n    \"\"\"The head minxin for dbnet and pannet heads.\"\"\"\n\n    def resize_boundary(self, boundaries, scale_factor):\n        \"\"\"Rescale boundaries via scale_factor.\n\n        Args:\n            boundaries (list[list[float]]): The boundary list. Each boundary\n            with size 2k+1 with k>=4.\n            scale_factor(ndarray): The scale factor of size (4,).\n\n        Returns:\n            boundaries (list[list[float]]): The scaled boundaries.\n        \"\"\"\n        assert check_argument.is_2dlist(boundaries)\n        assert isinstance(scale_factor, np.ndarray)\n        assert scale_factor.shape[0] == 4\n\n        for b in boundaries:\n            sz = len(b)\n            check_argument.valid_boundary(b, True)\n            b[:sz -\n              1] = (np.array(b[:sz - 1]) *\n                    (np.tile(scale_factor[:2], int(\n                        (sz - 1) / 2)).reshape(1, sz - 1))).flatten().tolist()\n        return boundaries\n\n    def get_boundary(self, score_maps, img_metas, rescale):\n        \"\"\"Compute text boundaries via post processing.\n\n        Args:\n            score_maps (Tensor): The text score map.\n            img_metas (dict): The image meta info.\n            rescale (bool): Rescale boundaries to the original image resolution\n                if true, and keep the score_maps resolution if false.\n\n        Returns:\n            results (dict): The result dict.\n        \"\"\"\n\n        assert check_argument.is_type_list(img_metas, dict)\n        assert isinstance(rescale, bool)\n\n        score_maps = score_maps.squeeze()\n        boundaries = decode(\n            decoding_type=self.decoding_type,\n            preds=score_maps,\n            text_repr_type=self.text_repr_type)\n        if rescale:\n            boundaries = self.resize_boundary(\n                boundaries,\n                1.0 / self.downsample_ratio / img_metas[0]['scale_factor'])\n        results = dict(boundary_result=boundaries)\n        return results\n\n    def loss(self, pred_maps, **kwargs):\n        \"\"\"Compute the loss for text detection.\n\n        Args:\n            pred_maps (tensor): The input score maps of NxCxHxW.\n\n        Returns:\n            losses (dict): The dict for losses.\n        \"\"\"\n        losses = self.loss_module(pred_maps, self.downsample_ratio, **kwargs)\n        return losses\n", "path": "mmocr/models/textdet/dense_heads/head_mixin.py"}], "after_files": [{"content": "# Copyright (c) OpenMMLab. All rights reserved.\nimport numpy as np\n\nfrom mmocr.models.builder import HEADS\nfrom mmocr.models.textdet.postprocess import decode\nfrom mmocr.utils import check_argument\n\n\n@HEADS.register_module()\nclass HeadMixin:\n    \"\"\"The head minxin for dbnet and pannet heads.\"\"\"\n\n    def resize_boundary(self, boundaries, scale_factor):\n        \"\"\"Rescale boundaries via scale_factor.\n\n        Args:\n            boundaries (list[list[float]]): The boundary list. Each boundary\n            with size 2k+1 with k>=4.\n            scale_factor(ndarray): The scale factor of size (4,).\n\n        Returns:\n            boundaries (list[list[float]]): The scaled boundaries.\n        \"\"\"\n        assert check_argument.is_2dlist(boundaries)\n        assert isinstance(scale_factor, np.ndarray)\n        assert scale_factor.shape[0] == 4\n\n        for b in boundaries:\n            sz = len(b)\n            check_argument.valid_boundary(b, True)\n            b[:sz -\n              1] = (np.array(b[:sz - 1]) *\n                    (np.tile(scale_factor[:2], int(\n                        (sz - 1) / 2)).reshape(1, sz - 1))).flatten().tolist()\n        return boundaries\n\n    def get_boundary(self, score_maps, img_metas, rescale):\n        \"\"\"Compute text boundaries via post processing.\n\n        Args:\n            score_maps (Tensor): The text score map.\n            img_metas (dict): The image meta info.\n            rescale (bool): Rescale boundaries to the original image resolution\n                if true, and keep the score_maps resolution if false.\n\n        Returns:\n            results (dict): The result dict.\n        \"\"\"\n\n        assert check_argument.is_type_list(img_metas, dict)\n        assert isinstance(rescale, bool)\n\n        score_maps = score_maps.squeeze()\n        boundaries = decode(\n            decoding_type=self.decoding_type,\n            preds=score_maps,\n            text_repr_type=self.text_repr_type)\n        if rescale:\n            boundaries = self.resize_boundary(\n                boundaries,\n                1.0 / self.downsample_ratio / img_metas[0]['scale_factor'])\n        results = dict(\n            boundary_result=boundaries, filename=img_metas[0]['filename'])\n\n        return results\n\n    def loss(self, pred_maps, **kwargs):\n        \"\"\"Compute the loss for text detection.\n\n        Args:\n            pred_maps (tensor): The input score maps of NxCxHxW.\n\n        Returns:\n            losses (dict): The dict for losses.\n        \"\"\"\n        losses = self.loss_module(pred_maps, self.downsample_ratio, **kwargs)\n        return losses\n", "path": "mmocr/models/textdet/dense_heads/head_mixin.py"}]}