Add ultralytics pip package (#11529)
* Add ultralytics pip package * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add requirements.txt locations * Update requirements.txt Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> --------- Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
54e95159c7
commit
5deff1471d
5 files changed
+5
-55
No files matched your search
+1
-1
@@ -300,7 +300,7 @@ def main(opt):
|
|||||||
if RANK in {-1, 0}:
|
if RANK in {-1, 0}:
|
||||||
print_args(vars(opt))
|
print_args(vars(opt))
|
||||||
check_git_status()
|
check_git_status()
|
||||||
check_requirements()
|
check_requirements(ROOT / 'requirements.txt')
|
||||||
|
|
||||||
# DDP mode
|
# DDP mode
|
||||||
device = select_device(opt.device, batch_size=opt.batch_size)
|
device = select_device(opt.device, batch_size=opt.batch_size)
|
||||||
|
|||||||
+1
-1
@@ -15,6 +15,7 @@ thop>=0.1.1 # FLOPs computation
|
|||||||
torch>=1.7.0 # see https://pytorch.org/get-started/locally (recommended)
|
torch>=1.7.0 # see https://pytorch.org/get-started/locally (recommended)
|
||||||
torchvision>=0.8.1
|
torchvision>=0.8.1
|
||||||
tqdm>=4.64.0
|
tqdm>=4.64.0
|
||||||
|
ultralytics>=8.0.100
|
||||||
# protobuf<=3.20.1 # https://github.com/ultralytics/yolov5/issues/8012
|
# protobuf<=3.20.1 # https://github.com/ultralytics/yolov5/issues/8012
|
||||||
|
|
||||||
# Logging ---------------------------------------------------------------------
|
# Logging ---------------------------------------------------------------------
|
||||||
@@ -46,4 +47,3 @@ setuptools>=65.5.1 # Snyk vulnerability fix
|
|||||||
# mss # screenshots
|
# mss # screenshots
|
||||||
# albumentations>=1.0.3
|
# albumentations>=1.0.3
|
||||||
# pycocotools>=2.0.6 # COCO mAP
|
# pycocotools>=2.0.6 # COCO mAP
|
||||||
# ultralytics # HUB https://hub.ultralytics.com
|
|
||||||
+1
-1
@@ -511,7 +511,7 @@ def main(opt, callbacks=Callbacks()):
|
|||||||
if RANK in {-1, 0}:
|
if RANK in {-1, 0}:
|
||||||
print_args(vars(opt))
|
print_args(vars(opt))
|
||||||
check_git_status()
|
check_git_status()
|
||||||
check_requirements()
|
check_requirements(ROOT / 'requirements.txt')
|
||||||
|
|
||||||
# Resume
|
# Resume
|
||||||
if opt.resume and not opt.evolve: # resume from specified or most recent last.pt
|
if opt.resume and not opt.evolve: # resume from specified or most recent last.pt
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ def main(opt, callbacks=Callbacks()):
|
|||||||
if RANK in {-1, 0}:
|
if RANK in {-1, 0}:
|
||||||
print_args(vars(opt))
|
print_args(vars(opt))
|
||||||
check_git_status()
|
check_git_status()
|
||||||
check_requirements()
|
check_requirements(ROOT / 'requirements.txt')
|
||||||
|
|
||||||
# Resume (from specified or most recent last.pt)
|
# Resume (from specified or most recent last.pt)
|
||||||
if opt.resume and not check_comet_resume(opt) and not opt.evolve:
|
if opt.resume and not check_comet_resume(opt) and not opt.evolve:
|
||||||
|
|||||||
+1
-51
@@ -35,6 +35,7 @@ import pkg_resources as pkg
|
|||||||
import torch
|
import torch
|
||||||
import torchvision
|
import torchvision
|
||||||
import yaml
|
import yaml
|
||||||
|
from ultralytics.yolo.utils.checks import check_requirements
|
||||||
|
|
||||||
from utils import TryExcept, emojis
|
from utils import TryExcept, emojis
|
||||||
from utils.downloads import curl_download, gsutil_getsize
|
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
|
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):
|
def check_img_size(imgsz, s=32, floor=0):
|
||||||
# Verify image size is a multiple of stride s in each dimension
|
# Verify image size is a multiple of stride s in each dimension
|
||||||
if isinstance(imgsz, int): # integer i.e. img_size=640
|
if isinstance(imgsz, int): # integer i.e. img_size=640
|
||||||
|
|||||||
Reference in new issue
Block a user