Use shell=True to run hyperparameter tuning (#18284)

Signed-off-by: Mohammed Yasin <32206511+Y-T-G@users.noreply.github.com>
Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Mohammed Yasin 2024-12-18 02:27:44 +08:00 committed by GitHub
parent 207c1c8319
commit 5c2ecb7669
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -191,7 +191,7 @@ class Tuner:
try: try:
# Train YOLO model with mutated hyperparameters (run in subprocess to avoid dataloader hang) # Train YOLO model with mutated hyperparameters (run in subprocess to avoid dataloader hang)
cmd = ["yolo", "train", *(f"{k}={v}" for k, v in train_args.items())] cmd = ["yolo", "train", *(f"{k}={v}" for k, v in train_args.items())]
return_code = subprocess.run(cmd, check=True).returncode return_code = subprocess.run(" ".join(cmd), check=True, shell=True).returncode
ckpt_file = weights_dir / ("best.pt" if (weights_dir / "best.pt").exists() else "last.pt") ckpt_file = weights_dir / ("best.pt" if (weights_dir / "best.pt").exists() else "last.pt")
metrics = torch.load(ckpt_file)["train_metrics"] metrics = torch.load(ckpt_file)["train_metrics"]
assert return_code == 0, "training failed" assert return_code == 0, "training failed"