diff --git a/official/cv/YOLOv5/src/util.py b/official/cv/YOLOv5/src/util.py index 5bc8fd781e59f6687c9d478163fd616c1e9d99b3..275c13203fc0ab1a676185e167b92b90255a04c3 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: