diff --git a/detect.py b/detect.py index 92fcd064d53d..9b9e7c74644b 100644 --- a/detect.py +++ b/detect.py @@ -286,7 +286,7 @@ def parse_opt(): def main(opt): - check_requirements(requirements=ROOT / 'requirements.txt', exclude=('tensorboard', 'thop')) + check_requirements(exclude=('tensorboard', 'thop')) run(**vars(opt)) diff --git a/hubconf.py b/hubconf.py index 9c5fa63809d1..3a89cf9763da 100644 --- a/hubconf.py +++ b/hubconf.py @@ -34,7 +34,7 @@ def _create(name, pretrained=True, channels=3, classes=80, autoshape=True, verbo from utils.torch_utils import select_device file = Path(__file__).resolve() - check_requirements(requirements=file.parent / 'requirements.txt', exclude=('tensorboard', 'thop', 'opencv-python')) + check_requirements(exclude=('tensorboard', 'thop', 'opencv-python')) set_logging(verbose=verbose) save_dir = Path('') if str(name).endswith('.pt') else file.parent diff --git a/train.py b/train.py index 89c0c507b8bf..6f98a64124d7 100644 --- a/train.py +++ b/train.py @@ -476,7 +476,7 @@ def main(opt, callbacks=Callbacks()): if RANK in [-1, 0]: print_args(FILE.stem, opt) check_git_status() - check_requirements(requirements=ROOT / 'requirements.txt', exclude=['thop']) + check_requirements(exclude=['thop']) # Resume if opt.resume and not check_wandb_resume(opt) and not opt.evolve: # resume an interrupted run diff --git a/utils/autoanchor.py b/utils/autoanchor.py index 66a2712dfd5d..1706fcb8e735 100644 --- a/utils/autoanchor.py +++ b/utils/autoanchor.py @@ -127,7 +127,7 @@ def print_results(k): print(f'{prefix}Running kmeans for {n} anchors on {len(wh)} points...') s = wh.std(0) # sigmas for whitening k, dist = kmeans(wh / s, n, iter=30) # points, mean distance - assert len(k) == n, print(f'{prefix}ERROR: scipy.cluster.vq.kmeans requested {n} points but returned only {len(k)}') + assert len(k) == n, f'{prefix}ERROR: scipy.cluster.vq.kmeans requested {n} points but returned only {len(k)}' k *= s wh = torch.tensor(wh, dtype=torch.float32) # filtered wh0 = torch.tensor(wh0, dtype=torch.float32) # unfiltered diff --git a/utils/general.py b/utils/general.py index d4d8e2064d08..dcaa3c71b3f5 100755 --- a/utils/general.py +++ b/utils/general.py @@ -37,6 +37,9 @@ cv2.setNumThreads(0) # prevent OpenCV from multithreading (incompatible with PyTorch DataLoader) os.environ['NUMEXPR_MAX_THREADS'] = str(min(os.cpu_count(), 8)) # NumExpr max threads +FILE = Path(__file__).resolve() +ROOT = FILE.parents[1] # YOLOv5 root directory + class Profile(contextlib.ContextDecorator): # Usage: @Profile() decorator or 'with Profile():' context manager @@ -222,7 +225,7 @@ def check_version(current='0.0.0', minimum='0.0.0', name='version ', pinned=Fals @try_except -def check_requirements(requirements='requirements.txt', exclude=(), install=True): +def check_requirements(requirements=ROOT / 'requirements.txt', exclude=(), install=True): # Check installed dependencies meet requirements (pass *.txt file or list of packages) prefix = colorstr('red', 'bold', 'requirements:') check_python() # check python version diff --git a/val.py b/val.py index 2dbf570f1e6e..f8c4f9e1cdd5 100644 --- a/val.py +++ b/val.py @@ -327,7 +327,7 @@ def parse_opt(): def main(opt): set_logging() - check_requirements(requirements=ROOT / 'requirements.txt', exclude=('tensorboard', 'thop')) + check_requirements(exclude=('tensorboard', 'thop')) if opt.task in ('train', 'val', 'test'): # run normally run(**vars(opt))