diff --git a/classify/train.py b/classify/train.py index 8b8327f173ef..ecbea1d8c0de 100644 --- a/classify/train.py +++ b/classify/train.py @@ -300,7 +300,7 @@ def main(opt): if RANK in {-1, 0}: print_args(vars(opt)) check_git_status() - check_requirements() + check_requirements(ROOT / 'requirements.txt') # DDP mode device = select_device(opt.device, batch_size=opt.batch_size) diff --git a/requirements.txt b/requirements.txt index 65924c9feec4..ae0a21f003e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,6 +15,7 @@ thop>=0.1.1 # FLOPs computation torch>=1.7.0 # see https://pytorch.org/get-started/locally (recommended) torchvision>=0.8.1 tqdm>=4.64.0 +ultralytics>=8.0.100 # protobuf<=3.20.1 # https://github.com/ultralytics/yolov5/issues/8012 # Logging --------------------------------------------------------------------- @@ -46,4 +47,3 @@ setuptools>=65.5.1 # Snyk vulnerability fix # mss # screenshots # albumentations>=1.0.3 # pycocotools>=2.0.6 # COCO mAP -# ultralytics # HUB https://hub.ultralytics.com diff --git a/segment/train.py b/segment/train.py index 073fc742005b..5f1fa4a1e453 100644 --- a/segment/train.py +++ b/segment/train.py @@ -511,7 +511,7 @@ def main(opt, callbacks=Callbacks()): if RANK in {-1, 0}: print_args(vars(opt)) check_git_status() - check_requirements() + check_requirements(ROOT / 'requirements.txt') # Resume if opt.resume and not opt.evolve: # resume from specified or most recent last.pt diff --git a/train.py b/train.py index 216da6399028..48eeb09468fe 100644 --- a/train.py +++ b/train.py @@ -485,7 +485,7 @@ def main(opt, callbacks=Callbacks()): if RANK in {-1, 0}: print_args(vars(opt)) check_git_status() - check_requirements() + check_requirements(ROOT / 'requirements.txt') # Resume (from specified or most recent last.pt) if opt.resume and not check_comet_resume(opt) and not opt.evolve: diff --git a/utils/general.py b/utils/general.py index 42c6d8c8aab5..e95b07486619 100644 --- a/utils/general.py +++ b/utils/general.py @@ -35,6 +35,7 @@ import torch import torchvision import yaml +from ultralytics.yolo.utils.checks import check_requirements from utils import TryExcept, emojis from utils.downloads import curl_download, gsutil_getsize @@ -387,57 +388,6 @@ def check_version(current='0.0.0', minimum='0.0.0', name='version ', pinned=Fals return result -@TryExcept() -def check_requirements(requirements=ROOT / 'requirements.txt', exclude=(), install=True, cmds=''): - """ - Check if installed dependencies meet YOLOv5 requirements and attempt to auto-update if needed. - - Args: - requirements (Union[Path, str, List[str]]): Path to a requirements.txt file, a single package requirement as a - string, or a list of package requirements as strings. - exclude (Tuple[str]): Tuple of package names to exclude from checking. - install (bool): If True, attempt to auto-update packages that don't meet requirements. - cmds (str): Additional commands to pass to the pip install command when auto-updating. - - Returns: - None - """ - prefix = colorstr('red', 'bold', 'requirements:') - check_python() # check python version - file = None - if isinstance(requirements, Path): # requirements.txt file - file = requirements.resolve() - assert file.exists(), f'{prefix} {file} not found, check failed.' - with file.open() as f: - requirements = [f'{x.name}{x.specifier}' for x in pkg.parse_requirements(f) if x.name not in exclude] - elif isinstance(requirements, str): - requirements = [requirements] - - s = '' # console string - n = 0 # number of packages updates - for r in requirements: - try: - pkg.require(r) - except (pkg.VersionConflict, pkg.DistributionNotFound): # exception if requirements not met - try: # attempt to import (slower but more accurate) - import importlib - importlib.import_module(next(pkg.parse_requirements(r)).name) - except ImportError: - s += f'"{r}" ' - n += 1 - - if s and install and AUTOINSTALL: # check environment variable - LOGGER.info(f"{prefix} YOLOv5 requirement{'s' * (n > 1)} {s}not found, attempting AutoUpdate...") - try: - assert check_online(), 'AutoUpdate skipped (offline)' - LOGGER.info(subprocess.check_output(f'pip install {s} {cmds}', shell=True).decode()) - s = f"{prefix} {n} package{'s' * (n > 1)} updated per {file or requirements}\n" \ - f"{prefix} ⚠️ {colorstr('bold', 'Restart runtime or rerun command for updates to take effect')}\n" - LOGGER.info(s) - except Exception as e: - LOGGER.warning(f'{prefix} ❌ {e}') - - def check_img_size(imgsz, s=32, floor=0): # Verify image size is a multiple of stride s in each dimension if isinstance(imgsz, int): # integer i.e. img_size=640