We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
当返回的roidbs为空时，卡在if isinstance(item, collections.Sequence) and len(item) == 0
    def _load_batch(self):
        batch = []
        bs = 0
        while bs != self._batch_size:
            if self._pos >= self.size():
                break
            pos = self.indexes[self._pos]
            sample = copy.deepcopy(self._roidbs[pos])
            sample["curr_iter"] = self._curr_iter
            self._pos += 1

            if self._drop_empty and self._fields and 'gt_bbox' in sample:
                if _has_empty(sample['gt_bbox']):

经自己测试 如果record有数据 但是roidbs里面bbox数据为[]，会一直循环 跳不出去 望加个判断修复下

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `ppdet/data/source/coco.py`
Content:
```
1 # Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 import os
16 import numpy as np
17 
18 from .dataset import DataSet
19 from ppdet.core.workspace import register, serializable
20 
21 import logging
22 logger = logging.getLogger(__name__)
23 
24 
25 @register
26 @serializable
27 class COCODataSet(DataSet):
28     """
29     Load COCO records with annotations in json file 'anno_path'
30 
31     Args:
32         dataset_dir (str): root directory for dataset.
33         image_dir (str): directory for images.
34         anno_path (str): json file path.
35         sample_num (int): number of samples to load, -1 means all.
36         with_background (bool): whether load background as a class.
37             if True, total class number will be 81. default True.
38     """
39 
40     def __init__(self,
41                  image_dir=None,
42                  anno_path=None,
43                  dataset_dir=None,
44                  sample_num=-1,
45                  with_background=True,
46                  load_semantic=False):
47         super(COCODataSet, self).__init__(
48             image_dir=image_dir,
49             anno_path=anno_path,
50             dataset_dir=dataset_dir,
51             sample_num=sample_num,
52             with_background=with_background)
53         self.anno_path = anno_path
54         self.sample_num = sample_num
55         self.with_background = with_background
56         # `roidbs` is list of dict whose structure is:
57         # {
58         #     'im_file': im_fname, # image file name
59         #     'im_id': img_id, # image id
60         #     'h': im_h, # height of image
61         #     'w': im_w, # width
62         #     'is_crowd': is_crowd,
63         #     'gt_score': gt_score,
64         #     'gt_class': gt_class,
65         #     'gt_bbox': gt_bbox,
66         #     'gt_poly': gt_poly,
67         # }
68         self.roidbs = None
69         # a dict used to map category name to class id
70         self.cname2cid = None
71         self.load_image_only = False
72         self.load_semantic = load_semantic
73 
74     def load_roidb_and_cname2cid(self):
75         anno_path = os.path.join(self.dataset_dir, self.anno_path)
76         image_dir = os.path.join(self.dataset_dir, self.image_dir)
77 
78         assert anno_path.endswith('.json'), \
79             'invalid coco annotation file: ' + anno_path
80         from pycocotools.coco import COCO
81         coco = COCO(anno_path)
82         img_ids = coco.getImgIds()
83         cat_ids = coco.getCatIds()
84         records = []
85         ct = 0
86 
87         # when with_background = True, mapping category to classid, like:
88         #   background:0, first_class:1, second_class:2, ...
89         catid2clsid = dict({
90             catid: i + int(self.with_background)
91             for i, catid in enumerate(cat_ids)
92         })
93         cname2cid = dict({
94             coco.loadCats(catid)[0]['name']: clsid
95             for catid, clsid in catid2clsid.items()
96         })
97 
98         if 'annotations' not in coco.dataset:
99             self.load_image_only = True
100             logger.warn('Annotation file: {} does not contains ground truth '
101                         'and load image information only.'.format(anno_path))
102 
103         for img_id in img_ids:
104             img_anno = coco.loadImgs(img_id)[0]
105             im_fname = img_anno['file_name']
106             im_w = float(img_anno['width'])
107             im_h = float(img_anno['height'])
108 
109             im_path = os.path.join(image_dir,
110                                    im_fname) if image_dir else im_fname
111             if not os.path.exists(im_path):
112                 logger.warn('Illegal image file: {}, and it will be '
113                             'ignored'.format(im_path))
114                 continue
115 
116             if im_w < 0 or im_h < 0:
117                 logger.warn('Illegal width: {} or height: {} in annotation, '
118                             'and im_id: {} will be ignored'.format(im_w, im_h,
119                                                                    img_id))
120                 continue
121 
122             coco_rec = {
123                 'im_file': im_path,
124                 'im_id': np.array([img_id]),
125                 'h': im_h,
126                 'w': im_w,
127             }
128 
129             if not self.load_image_only:
130                 ins_anno_ids = coco.getAnnIds(imgIds=img_id, iscrowd=False)
131                 instances = coco.loadAnns(ins_anno_ids)
132 
133                 bboxes = []
134                 for inst in instances:
135                     x, y, box_w, box_h = inst['bbox']
136                     x1 = max(0, x)
137                     y1 = max(0, y)
138                     x2 = min(im_w - 1, x1 + max(0, box_w - 1))
139                     y2 = min(im_h - 1, y1 + max(0, box_h - 1))
140                     if x2 >= x1 and y2 >= y1:
141                         inst['clean_bbox'] = [x1, y1, x2, y2]
142                         bboxes.append(inst)
143                     else:
144                         logger.warn(
145                             'Found an invalid bbox in annotations: im_id: {}, '
146                             'x1: {}, y1: {}, x2: {}, y2: {}.'.format(
147                                 img_id, x1, y1, x2, y2))
148                 num_bbox = len(bboxes)
149 
150                 gt_bbox = np.zeros((num_bbox, 4), dtype=np.float32)
151                 gt_class = np.zeros((num_bbox, 1), dtype=np.int32)
152                 gt_score = np.ones((num_bbox, 1), dtype=np.float32)
153                 is_crowd = np.zeros((num_bbox, 1), dtype=np.int32)
154                 difficult = np.zeros((num_bbox, 1), dtype=np.int32)
155                 gt_poly = [None] * num_bbox
156 
157                 for i, box in enumerate(bboxes):
158                     catid = box['category_id']
159                     gt_class[i][0] = catid2clsid[catid]
160                     gt_bbox[i, :] = box['clean_bbox']
161                     is_crowd[i][0] = box['iscrowd']
162                     if 'segmentation' in box:
163                         gt_poly[i] = box['segmentation']
164 
165                 coco_rec.update({
166                     'is_crowd': is_crowd,
167                     'gt_class': gt_class,
168                     'gt_bbox': gt_bbox,
169                     'gt_score': gt_score,
170                     'gt_poly': gt_poly,
171                 })
172 
173                 if self.load_semantic:
174                     seg_path = os.path.join(self.dataset_dir, 'stuffthingmaps',
175                                             'train2017', im_fname[:-3] + 'png')
176                     coco_rec.update({'semantic': seg_path})
177 
178             logger.debug('Load file: {}, im_id: {}, h: {}, w: {}.'.format(
179                 im_path, img_id, im_h, im_w))
180             records.append(coco_rec)
181             ct += 1
182             if self.sample_num > 0 and ct >= self.sample_num:
183                 break
184         assert len(records) > 0, 'not found any coco record in %s' % (anno_path)
185         logger.debug('{} samples in file {}'.format(ct, anno_path))
186         self.roidbs, self.cname2cid = records, cname2cid
187
```
--- 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/ppdet/data/source/coco.py b/ppdet/data/source/coco.py
--- a/ppdet/data/source/coco.py
+++ b/ppdet/data/source/coco.py
@@ -146,6 +146,8 @@
                             'x1: {}, y1: {}, x2: {}, y2: {}.'.format(
                                 img_id, x1, y1, x2, y2))
                 num_bbox = len(bboxes)
+                if num_bbox <= 0:
+                    continue
 
                 gt_bbox = np.zeros((num_bbox, 4), dtype=np.float32)
                 gt_class = np.zeros((num_bbox, 1), dtype=np.int32)
@@ -154,6 +156,7 @@
                 difficult = np.zeros((num_bbox, 1), dtype=np.int32)
                 gt_poly = [None] * num_bbox
 
+                has_segmentation = False
                 for i, box in enumerate(bboxes):
                     catid = box['category_id']
                     gt_class[i][0] = catid2clsid[catid]
@@ -161,6 +164,10 @@
                     is_crowd[i][0] = box['iscrowd']
                     if 'segmentation' in box:
                         gt_poly[i] = box['segmentation']
+                        has_segmentation = True
+
+                if has_segmentation and not any(gt_poly):
+                    continue
 
                 coco_rec.update({
                     'is_crowd': is_crowd,

{"golden_diff": "diff --git a/ppdet/data/source/coco.py b/ppdet/data/source/coco.py\n--- a/ppdet/data/source/coco.py\n+++ b/ppdet/data/source/coco.py\n@@ -146,6 +146,8 @@\n                             'x1: {}, y1: {}, x2: {}, y2: {}.'.format(\n                                 img_id, x1, y1, x2, y2))\n                 num_bbox = len(bboxes)\n+                if num_bbox <= 0:\n+                    continue\n \n                 gt_bbox = np.zeros((num_bbox, 4), dtype=np.float32)\n                 gt_class = np.zeros((num_bbox, 1), dtype=np.int32)\n@@ -154,6 +156,7 @@\n                 difficult = np.zeros((num_bbox, 1), dtype=np.int32)\n                 gt_poly = [None] * num_bbox\n \n+                has_segmentation = False\n                 for i, box in enumerate(bboxes):\n                     catid = box['category_id']\n                     gt_class[i][0] = catid2clsid[catid]\n@@ -161,6 +164,10 @@\n                     is_crowd[i][0] = box['iscrowd']\n                     if 'segmentation' in box:\n                         gt_poly[i] = box['segmentation']\n+                        has_segmentation = True\n+\n+                if has_segmentation and not any(gt_poly):\n+                    continue\n \n                 coco_rec.update({\n                     'is_crowd': is_crowd,\n", "issue": "\u5f53\u8fd4\u56de\u7684roidbs\u4e3a\u7a7a\u65f6\uff0c\u5361\u5728if isinstance(item, collections.Sequence) and len(item) == 0\n    def _load_batch(self):\r\n        batch = []\r\n        bs = 0\r\n        while bs != self._batch_size:\r\n            if self._pos >= self.size():\r\n                break\r\n            pos = self.indexes[self._pos]\r\n            sample = copy.deepcopy(self._roidbs[pos])\r\n            sample[\"curr_iter\"] = self._curr_iter\r\n            self._pos += 1\r\n\r\n            if self._drop_empty and self._fields and 'gt_bbox' in sample:\r\n                if _has_empty(sample['gt_bbox']):\r\n\r\n\u7ecf\u81ea\u5df1\u6d4b\u8bd5 \u5982\u679crecord\u6709\u6570\u636e \u4f46\u662froidbs\u91cc\u9762bbox\u6570\u636e\u4e3a[]\uff0c\u4f1a\u4e00\u76f4\u5faa\u73af \u8df3\u4e0d\u51fa\u53bb \u671b\u52a0\u4e2a\u5224\u65ad\u4fee\u590d\u4e0b\n", "before_files": [{"content": "# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport os\nimport numpy as np\n\nfrom .dataset import DataSet\nfrom ppdet.core.workspace import register, serializable\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\n@register\n@serializable\nclass COCODataSet(DataSet):\n    \"\"\"\n    Load COCO records with annotations in json file 'anno_path'\n\n    Args:\n        dataset_dir (str): root directory for dataset.\n        image_dir (str): directory for images.\n        anno_path (str): json file path.\n        sample_num (int): number of samples to load, -1 means all.\n        with_background (bool): whether load background as a class.\n            if True, total class number will be 81. default True.\n    \"\"\"\n\n    def __init__(self,\n                 image_dir=None,\n                 anno_path=None,\n                 dataset_dir=None,\n                 sample_num=-1,\n                 with_background=True,\n                 load_semantic=False):\n        super(COCODataSet, self).__init__(\n            image_dir=image_dir,\n            anno_path=anno_path,\n            dataset_dir=dataset_dir,\n            sample_num=sample_num,\n            with_background=with_background)\n        self.anno_path = anno_path\n        self.sample_num = sample_num\n        self.with_background = with_background\n        # `roidbs` is list of dict whose structure is:\n        # {\n        #     'im_file': im_fname, # image file name\n        #     'im_id': img_id, # image id\n        #     'h': im_h, # height of image\n        #     'w': im_w, # width\n        #     'is_crowd': is_crowd,\n        #     'gt_score': gt_score,\n        #     'gt_class': gt_class,\n        #     'gt_bbox': gt_bbox,\n        #     'gt_poly': gt_poly,\n        # }\n        self.roidbs = None\n        # a dict used to map category name to class id\n        self.cname2cid = None\n        self.load_image_only = False\n        self.load_semantic = load_semantic\n\n    def load_roidb_and_cname2cid(self):\n        anno_path = os.path.join(self.dataset_dir, self.anno_path)\n        image_dir = os.path.join(self.dataset_dir, self.image_dir)\n\n        assert anno_path.endswith('.json'), \\\n            'invalid coco annotation file: ' + anno_path\n        from pycocotools.coco import COCO\n        coco = COCO(anno_path)\n        img_ids = coco.getImgIds()\n        cat_ids = coco.getCatIds()\n        records = []\n        ct = 0\n\n        # when with_background = True, mapping category to classid, like:\n        #   background:0, first_class:1, second_class:2, ...\n        catid2clsid = dict({\n            catid: i + int(self.with_background)\n            for i, catid in enumerate(cat_ids)\n        })\n        cname2cid = dict({\n            coco.loadCats(catid)[0]['name']: clsid\n            for catid, clsid in catid2clsid.items()\n        })\n\n        if 'annotations' not in coco.dataset:\n            self.load_image_only = True\n            logger.warn('Annotation file: {} does not contains ground truth '\n                        'and load image information only.'.format(anno_path))\n\n        for img_id in img_ids:\n            img_anno = coco.loadImgs(img_id)[0]\n            im_fname = img_anno['file_name']\n            im_w = float(img_anno['width'])\n            im_h = float(img_anno['height'])\n\n            im_path = os.path.join(image_dir,\n                                   im_fname) if image_dir else im_fname\n            if not os.path.exists(im_path):\n                logger.warn('Illegal image file: {}, and it will be '\n                            'ignored'.format(im_path))\n                continue\n\n            if im_w < 0 or im_h < 0:\n                logger.warn('Illegal width: {} or height: {} in annotation, '\n                            'and im_id: {} will be ignored'.format(im_w, im_h,\n                                                                   img_id))\n                continue\n\n            coco_rec = {\n                'im_file': im_path,\n                'im_id': np.array([img_id]),\n                'h': im_h,\n                'w': im_w,\n            }\n\n            if not self.load_image_only:\n                ins_anno_ids = coco.getAnnIds(imgIds=img_id, iscrowd=False)\n                instances = coco.loadAnns(ins_anno_ids)\n\n                bboxes = []\n                for inst in instances:\n                    x, y, box_w, box_h = inst['bbox']\n                    x1 = max(0, x)\n                    y1 = max(0, y)\n                    x2 = min(im_w - 1, x1 + max(0, box_w - 1))\n                    y2 = min(im_h - 1, y1 + max(0, box_h - 1))\n                    if x2 >= x1 and y2 >= y1:\n                        inst['clean_bbox'] = [x1, y1, x2, y2]\n                        bboxes.append(inst)\n                    else:\n                        logger.warn(\n                            'Found an invalid bbox in annotations: im_id: {}, '\n                            'x1: {}, y1: {}, x2: {}, y2: {}.'.format(\n                                img_id, x1, y1, x2, y2))\n                num_bbox = len(bboxes)\n\n                gt_bbox = np.zeros((num_bbox, 4), dtype=np.float32)\n                gt_class = np.zeros((num_bbox, 1), dtype=np.int32)\n                gt_score = np.ones((num_bbox, 1), dtype=np.float32)\n                is_crowd = np.zeros((num_bbox, 1), dtype=np.int32)\n                difficult = np.zeros((num_bbox, 1), dtype=np.int32)\n                gt_poly = [None] * num_bbox\n\n                for i, box in enumerate(bboxes):\n                    catid = box['category_id']\n                    gt_class[i][0] = catid2clsid[catid]\n                    gt_bbox[i, :] = box['clean_bbox']\n                    is_crowd[i][0] = box['iscrowd']\n                    if 'segmentation' in box:\n                        gt_poly[i] = box['segmentation']\n\n                coco_rec.update({\n                    'is_crowd': is_crowd,\n                    'gt_class': gt_class,\n                    'gt_bbox': gt_bbox,\n                    'gt_score': gt_score,\n                    'gt_poly': gt_poly,\n                })\n\n                if self.load_semantic:\n                    seg_path = os.path.join(self.dataset_dir, 'stuffthingmaps',\n                                            'train2017', im_fname[:-3] + 'png')\n                    coco_rec.update({'semantic': seg_path})\n\n            logger.debug('Load file: {}, im_id: {}, h: {}, w: {}.'.format(\n                im_path, img_id, im_h, im_w))\n            records.append(coco_rec)\n            ct += 1\n            if self.sample_num > 0 and ct >= self.sample_num:\n                break\n        assert len(records) > 0, 'not found any coco record in %s' % (anno_path)\n        logger.debug('{} samples in file {}'.format(ct, anno_path))\n        self.roidbs, self.cname2cid = records, cname2cid\n", "path": "ppdet/data/source/coco.py"}], "after_files": [{"content": "# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport os\nimport numpy as np\n\nfrom .dataset import DataSet\nfrom ppdet.core.workspace import register, serializable\n\nimport logging\nlogger = logging.getLogger(__name__)\n\n\n@register\n@serializable\nclass COCODataSet(DataSet):\n    \"\"\"\n    Load COCO records with annotations in json file 'anno_path'\n\n    Args:\n        dataset_dir (str): root directory for dataset.\n        image_dir (str): directory for images.\n        anno_path (str): json file path.\n        sample_num (int): number of samples to load, -1 means all.\n        with_background (bool): whether load background as a class.\n            if True, total class number will be 81. default True.\n    \"\"\"\n\n    def __init__(self,\n                 image_dir=None,\n                 anno_path=None,\n                 dataset_dir=None,\n                 sample_num=-1,\n                 with_background=True,\n                 load_semantic=False):\n        super(COCODataSet, self).__init__(\n            image_dir=image_dir,\n            anno_path=anno_path,\n            dataset_dir=dataset_dir,\n            sample_num=sample_num,\n            with_background=with_background)\n        self.anno_path = anno_path\n        self.sample_num = sample_num\n        self.with_background = with_background\n        # `roidbs` is list of dict whose structure is:\n        # {\n        #     'im_file': im_fname, # image file name\n        #     'im_id': img_id, # image id\n        #     'h': im_h, # height of image\n        #     'w': im_w, # width\n        #     'is_crowd': is_crowd,\n        #     'gt_score': gt_score,\n        #     'gt_class': gt_class,\n        #     'gt_bbox': gt_bbox,\n        #     'gt_poly': gt_poly,\n        # }\n        self.roidbs = None\n        # a dict used to map category name to class id\n        self.cname2cid = None\n        self.load_image_only = False\n        self.load_semantic = load_semantic\n\n    def load_roidb_and_cname2cid(self):\n        anno_path = os.path.join(self.dataset_dir, self.anno_path)\n        image_dir = os.path.join(self.dataset_dir, self.image_dir)\n\n        assert anno_path.endswith('.json'), \\\n            'invalid coco annotation file: ' + anno_path\n        from pycocotools.coco import COCO\n        coco = COCO(anno_path)\n        img_ids = coco.getImgIds()\n        cat_ids = coco.getCatIds()\n        records = []\n        ct = 0\n\n        # when with_background = True, mapping category to classid, like:\n        #   background:0, first_class:1, second_class:2, ...\n        catid2clsid = dict({\n            catid: i + int(self.with_background)\n            for i, catid in enumerate(cat_ids)\n        })\n        cname2cid = dict({\n            coco.loadCats(catid)[0]['name']: clsid\n            for catid, clsid in catid2clsid.items()\n        })\n\n        if 'annotations' not in coco.dataset:\n            self.load_image_only = True\n            logger.warn('Annotation file: {} does not contains ground truth '\n                        'and load image information only.'.format(anno_path))\n\n        for img_id in img_ids:\n            img_anno = coco.loadImgs(img_id)[0]\n            im_fname = img_anno['file_name']\n            im_w = float(img_anno['width'])\n            im_h = float(img_anno['height'])\n\n            im_path = os.path.join(image_dir,\n                                   im_fname) if image_dir else im_fname\n            if not os.path.exists(im_path):\n                logger.warn('Illegal image file: {}, and it will be '\n                            'ignored'.format(im_path))\n                continue\n\n            if im_w < 0 or im_h < 0:\n                logger.warn('Illegal width: {} or height: {} in annotation, '\n                            'and im_id: {} will be ignored'.format(im_w, im_h,\n                                                                   img_id))\n                continue\n\n            coco_rec = {\n                'im_file': im_path,\n                'im_id': np.array([img_id]),\n                'h': im_h,\n                'w': im_w,\n            }\n\n            if not self.load_image_only:\n                ins_anno_ids = coco.getAnnIds(imgIds=img_id, iscrowd=False)\n                instances = coco.loadAnns(ins_anno_ids)\n\n                bboxes = []\n                for inst in instances:\n                    x, y, box_w, box_h = inst['bbox']\n                    x1 = max(0, x)\n                    y1 = max(0, y)\n                    x2 = min(im_w - 1, x1 + max(0, box_w - 1))\n                    y2 = min(im_h - 1, y1 + max(0, box_h - 1))\n                    if x2 >= x1 and y2 >= y1:\n                        inst['clean_bbox'] = [x1, y1, x2, y2]\n                        bboxes.append(inst)\n                    else:\n                        logger.warn(\n                            'Found an invalid bbox in annotations: im_id: {}, '\n                            'x1: {}, y1: {}, x2: {}, y2: {}.'.format(\n                                img_id, x1, y1, x2, y2))\n                num_bbox = len(bboxes)\n                if num_bbox <= 0:\n                    continue\n\n                gt_bbox = np.zeros((num_bbox, 4), dtype=np.float32)\n                gt_class = np.zeros((num_bbox, 1), dtype=np.int32)\n                gt_score = np.ones((num_bbox, 1), dtype=np.float32)\n                is_crowd = np.zeros((num_bbox, 1), dtype=np.int32)\n                difficult = np.zeros((num_bbox, 1), dtype=np.int32)\n                gt_poly = [None] * num_bbox\n\n                has_segmentation = False\n                for i, box in enumerate(bboxes):\n                    catid = box['category_id']\n                    gt_class[i][0] = catid2clsid[catid]\n                    gt_bbox[i, :] = box['clean_bbox']\n                    is_crowd[i][0] = box['iscrowd']\n                    if 'segmentation' in box:\n                        gt_poly[i] = box['segmentation']\n                        has_segmentation = True\n\n                if has_segmentation and not any(gt_poly):\n                    continue\n\n                coco_rec.update({\n                    'is_crowd': is_crowd,\n                    'gt_class': gt_class,\n                    'gt_bbox': gt_bbox,\n                    'gt_score': gt_score,\n                    'gt_poly': gt_poly,\n                })\n\n                if self.load_semantic:\n                    seg_path = os.path.join(self.dataset_dir, 'stuffthingmaps',\n                                            'train2017', im_fname[:-3] + 'png')\n                    coco_rec.update({'semantic': seg_path})\n\n            logger.debug('Load file: {}, im_id: {}, h: {}, w: {}.'.format(\n                im_path, img_id, im_h, im_w))\n            records.append(coco_rec)\n            ct += 1\n            if self.sample_num > 0 and ct >= self.sample_num:\n                break\n        assert len(records) > 0, 'not found any coco record in %s' % (anno_path)\n        logger.debug('{} samples in file {}'.format(ct, anno_path))\n        self.roidbs, self.cname2cid = records, cname2cid\n", "path": "ppdet/data/source/coco.py"}]}