From 87d48cde2d48ecb62fb202f585b00a87a47b2cba Mon Sep 17 00:00:00 2001 From: ZUPaulLin <2451902923@qq.com> Date: Sat, 16 Mar 2024 08:07:25 +0000 Subject: [PATCH] =?UTF-8?q?update=20official/cv/YOLOv5/src/util.py.=20?= =?UTF-8?q?=E6=9C=89=E9=9A=90=E8=97=8F=E6=96=87=E4=BB=B6=E5=A4=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: ZUPaulLin <2451902923@qq.com> --- official/cv/YOLOv5/src/util.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/official/cv/YOLOv5/src/util.py b/official/cv/YOLOv5/src/util.py index 5bc8fd781..275c13203 100644 --- a/official/cv/YOLOv5/src/util.py +++ b/official/cv/YOLOv5/src/util.py @@ -194,18 +194,19 @@ class COCOEvaluator: self.logger.info(f"File list: {file_path}") for path in file_path: - ann_list = [] - try: - with open(path, 'r') as f: - ann_list = json.load(f) - except json.decoder.JSONDecodeError: - pass # json file is empty - else: - ann_ids = set(ann['image_id'] for ann in ann_list) - diff_ids = ann_ids - dt_ids_set - ann_list = [ann for ann in ann_list if ann['image_id'] in diff_ids] - dt_ids_set = dt_ids_set | diff_ids - dt_list.extend(ann_list) + if not path.startswith("."): + ann_list = [] + try: + with open(path, 'r') as f: + ann_list = json.load(f) + except json.decoder.JSONDecodeError: + pass # json file is empty + else: + ann_ids = set(ann['image_id'] for ann in ann_list) + diff_ids = ann_ids - dt_ids_set + ann_list = [ann for ann in ann_list if ann['image_id'] in diff_ids] + dt_ids_set = dt_ids_set | diff_ids + dt_list.extend(ann_list) return dt_list def get_coco_from_dt_list(self, dt_list) -> COCO: -- Gitee