Fix names bug when exporting YOLOv8-World to ONNX (#8941)

Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Jamjamjon 2024-03-15 02:46:56 +08:00 committed by GitHub
parent 5c1277113b
commit 58a05f8e70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -71,8 +71,9 @@ class YOLOWorld(Model):
"""
super().__init__(model=model, task="detect")
# Assign default COCO class names
self.model.names = yaml_load(ROOT / "cfg/datasets/coco8.yaml").get("names")
# Assign default COCO class names when there are no custom names
if not hasattr(self.model, "names"):
self.model.names = yaml_load(ROOT / "cfg/datasets/coco8.yaml").get("names")
@property
def task_map(self):