Fix overrides training cfg bug (#10002)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
Co-authored-by: Ultralytics AI Assistant <135830346+UltralyticsAssistant@users.noreply.github.com>
Co-authored-by: Laughing-q <1185102784@qq.com>
This commit is contained in:
Mo Li 2024-04-14 22:24:25 +08:00 committed by GitHub
parent a506a55062
commit 3bbbdcfef8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -641,7 +641,12 @@ class Model(nn.Module):
checks.check_pip_update_available() checks.check_pip_update_available()
overrides = yaml_load(checks.check_yaml(kwargs["cfg"])) if kwargs.get("cfg") else self.overrides overrides = yaml_load(checks.check_yaml(kwargs["cfg"])) if kwargs.get("cfg") else self.overrides
custom = {"data": DEFAULT_CFG_DICT["data"] or TASK2DATA[self.task]} # method defaults custom = {
# NOTE: handle the case when 'cfg' includes 'data'.
"data": overrides.get("data") or DEFAULT_CFG_DICT["data"] or TASK2DATA[self.task],
"model": self.overrides["model"],
"task": self.task,
} # method defaults
args = {**overrides, **custom, **kwargs, "mode": "train"} # highest priority args on the right args = {**overrides, **custom, **kwargs, "mode": "train"} # highest priority args on the right
if args.get("resume"): if args.get("resume"):
args["resume"] = self.ckpt_path args["resume"] = self.ckpt_path