更改Yolov8时出现这个错误,我更改的是YOLOv8的检测头,最后排查发现是task.py中出现问题。
未添加检测头代码在这段代码中,更改后
def cfg2task(cfg):
"""Guess from YAML dictionary."""
m = cfg["head"][-1][-2].lower() # output module name
if m in {"classify", "classifier", "cls", "fc"}:
return "classify"
if m == "detect":
return "detect"
if m == "segment":
return "segment"
if m == "pose":
return "pose"
if m == "obb":
return "obb"
if m == "new_detect":
return "new_detect"
在最后添加代码即可解决问题。new_detect为新的检测头命名,根据自己的命名更改。