Update val.py

Fixed a bug in yolov10's verification of the MAP of the COCO test2017
This commit is contained in:
zhiqiang yang 2024-07-18 10:39:57 +08:00 committed by GitHub
parent aad320dd80
commit 84b18f968c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -65,7 +65,7 @@ class DetectionValidator(BaseValidator):
def init_metrics(self, model): def init_metrics(self, model):
"""Initialize evaluation metrics for YOLO.""" """Initialize evaluation metrics for YOLO."""
val = self.data.get(self.args.split, "") # validation path val = self.data.get(self.args.split, "") # validation path
self.is_coco = isinstance(val, str) and "coco" in val and val.endswith(f"{os.sep}val2017.txt") # is COCO self.is_coco = isinstance(val, str) and "coco" in val and (val.endswith(f"{os.sep}val2017.txt") or val.endswith(f"{os.sep}test-dev2017.txt")) # is COCO
self.class_map = converter.coco80_to_coco91_class() if self.is_coco else list(range(1000)) self.class_map = converter.coco80_to_coco91_class() if self.is_coco else list(range(1000))
self.args.save_json |= self.is_coco # run on final val if training COCO self.args.save_json |= self.is_coco # run on final val if training COCO
self.names = model.names self.names = model.names