diff --git a/segment/train.py b/segment/train.py index 3f32d21..883c8b0 100644 --- a/segment/train.py +++ b/segment/train.py @@ -19,6 +19,7 @@ import argparse import math import os import random +import subprocess import sys import time from copy import deepcopy @@ -597,7 +598,8 @@ def main(opt, callbacks=Callbacks()): # ei = [isinstance(x, (int, float)) for x in hyp.values()] # evolvable indices evolve_yaml, evolve_csv = save_dir / 'hyp_evolve.yaml', save_dir / 'evolve.csv' if opt.bucket: - os.system(f'gsutil cp gs://{opt.bucket}/evolve.csv {evolve_csv}') # download evolve.csv if exists + subprocess.run( + f'gsutil cp gs://{opt.bucket}/evolve.csv {evolve_csv}'.split()) # download evolve.csv if exists for _ in range(opt.evolve): # generations to evolve if evolve_csv.exists(): # if evolve.csv exists: select best hyps and mutate diff --git a/segment/val.py b/segment/val.py index 248d2be..8168b54 100644 --- a/segment/val.py +++ b/segment/val.py @@ -23,6 +23,7 @@ Usage - formats: import argparse import json import os +import subprocess import sys from multiprocessing.pool import ThreadPool from pathlib import Path @@ -461,7 +462,7 @@ def main(opt): r, _, t = run(**vars(opt), plots=False) y.append(r + t) # results and times np.savetxt(f, y, fmt='%10.4g') # save - os.system('zip -r study.zip study_*.txt') + subprocess.run('zip -r study.zip study_*.txt'.split()) plot_val_study(x=x) # plot else: raise NotImplementedError(f'--task {opt.task} not in ("train", "val", "test", "speed", "study")') diff --git a/train.py b/train.py index 5d75f22..db65f2c 100644 --- a/train.py +++ b/train.py @@ -19,6 +19,7 @@ import argparse import math import os import random +import subprocess import sys import time from copy import deepcopy @@ -571,7 +572,8 @@ def main(opt, callbacks=Callbacks()): # ei = [isinstance(x, (int, float)) for x in hyp.values()] # evolvable indices evolve_yaml, evolve_csv = save_dir / 'hyp_evolve.yaml', save_dir / 'evolve.csv' if opt.bucket: - os.system(f'gsutil cp gs://{opt.bucket}/evolve.csv {evolve_csv}') # download evolve.csv if exists + subprocess.run( + f'gsutil cp gs://{opt.bucket}/evolve.csv {evolve_csv}'.split()) # download evolve.csv if exists for _ in range(opt.evolve): # generations to evolve if evolve_csv.exists(): # if evolve.csv exists: select best hyps and mutate diff --git a/utils/downloads.py b/utils/downloads.py index 72ea873..a3ff927 100644 --- a/utils/downloads.py +++ b/utils/downloads.py @@ -50,7 +50,8 @@ def safe_download(file, url, url2=None, min_bytes=1E0, error_msg=''): if file.exists(): file.unlink() # remove partial downloads LOGGER.info(f'ERROR: {e}\nRe-attempting {url2 or url} to {file}...') - os.system(f"curl -# -L '{url2 or url}' -o '{file}' --retry 3 -C -") # curl download, retry and resume on fail + subprocess.run( + f"curl -# -L '{url2 or url}' -o '{file}' --retry 3 -C -".split()) # curl download, retry and resume on fail finally: if not file.exists() or file.stat().st_size < min_bytes: # check if file.exists(): diff --git a/utils/general.py b/utils/general.py index 4d5e94b..4e5c714 100644 --- a/utils/general.py +++ b/utils/general.py @@ -631,8 +631,7 @@ def download(url, dir='.', unzip=True, delete=True, curl=False, threads=1, retry for i in range(retry + 1): if curl: s = 'sS' if threads > 1 else '' # silent - r = os.system( - f'curl -# -{s}L "{url}" -o "{f}" --retry 9 -C -') # curl download with retry, continue + r = subprocess.run(f'curl -# -{s}L "{url}" -o "{f}" --retry 9 -C -'.split()) success = r == 0 else: torch.hub.download_url_to_file(url, f, progress=threads == 1) # torch download diff --git a/val.py b/val.py index 599aa1a..62fa2c9 100644 --- a/val.py +++ b/val.py @@ -22,6 +22,7 @@ Usage - formats: import argparse import json import os +import subprocess import sys from pathlib import Path @@ -397,7 +398,7 @@ def main(opt): r, _, t = run(**vars(opt), plots=False) y.append(r + t) # results and times np.savetxt(f, y, fmt='%10.4g') # save - os.system('zip -r study.zip study_*.txt') + subprocess.run('zip -r study.zip study_*.txt'.split()) plot_val_study(x=x) # plot else: raise NotImplementedError(f'--task {opt.task} not in ("train", "val", "test", "speed", "study")')