ultralytics 8.0.186 add Open Images V7 models (#5070)

This commit is contained in:
Glenn Jocher 2023-09-25 01:15:26 +02:00 committed by GitHub
parent a9033118cf
commit eb976f5ad2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 152 additions and 96 deletions

View file

@ -1,23 +1,17 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license
from ultralytics.utils import LOGGER, SETTINGS, TESTS_RUNNING
from ultralytics.utils import LOGGER, SETTINGS, TESTS_RUNNING, checks
try:
assert not TESTS_RUNNING # do not log pytest
assert SETTINGS['dvc'] is True # verify integration is enabled
import dvclive
assert hasattr(dvclive, '__version__') # verify package is not directory
assert checks.check_version('dvclive', '2.11.0', verbose=True)
import os
import re
from pathlib import Path
from ultralytics.utils.checks import check_version
if not check_version(dvclive.__version__, '2.11.0', name='dvclive', verbose=True):
dvclive = None
# DVCLive logger instance
live = None
_processed_plots = {}

View file

@ -135,23 +135,24 @@ def check_imgsz(imgsz, stride=32, min_dim=1, max_dim=2, floor=0):
def check_version(current: str = '0.0.0',
required: str = '0.0.0',
name: str = 'version ',
name: str = 'version',
hard: bool = False,
verbose: bool = False) -> bool:
"""
Check current version against the required version or range.
Args:
current (str): Current version.
current (str): Current version or package name to get version from.
required (str): Required version or range (in pip-style format).
name (str): Name to be used in warning message.
hard (bool): If True, raise an AssertionError if the requirement is not met.
verbose (bool): If True, print warning message if requirement is not met.
name (str, optional): Name to be used in warning message.
hard (bool, optional): If True, raise an AssertionError if the requirement is not met.
verbose (bool, optional): If True, print warning message if requirement is not met.
Returns:
(bool): True if requirement is met, False otherwise.
Example:
```python
# check if current version is exactly 22.04
check_version(current='22.04', required='==22.04')
@ -163,31 +164,40 @@ def check_version(current: str = '0.0.0',
# check if current version is between 20.04 (inclusive) and 22.04 (exclusive)
check_version(current='21.10', required='>20.04,<22.04')
```
"""
if not current: # if current is '' or None
LOGGER.warning(f'WARNING ⚠️ invalid check_version({current}, {required}) requested, please check values.')
return True
elif not current[0].isdigit(): # current is package name rather than version string, i.e. current='ultralytics'
try:
name = current # assigned package name to 'name' arg
current = version(current) # get version string from package name
except PackageNotFoundError:
if hard:
raise ModuleNotFoundError(emojis(f'WARNING ⚠️ {current} package is required but not installed'))
else:
return False
if not required: # if required is '' or None
return True
current = parse_version(current) # '1.2.3' -> (1, 2, 3)
constraints = re.findall(r'([<>!=]{1,2}\s*\d+\.\d+)', required) or [f'>={required}']
result = True
for constraint in constraints:
op, v = re.match(r'([<>!=]{1,2})\s*(\d+\.\d+)', constraint).groups()
c = parse_version(current) # '1.2.3' -> (1, 2, 3)
for r in required.strip(',').split(','):
op, v = re.match(r'([^0-9]*)([\d.]+)', r).groups() # split '>=22.04' -> ('>=', '22.04')
v = parse_version(v) # '1.2.3' -> (1, 2, 3)
if op == '==' and current != v:
if op == '==' and c != v:
result = False
elif op == '!=' and current == v:
elif op == '!=' and c == v:
result = False
elif op == '>=' and not (current >= v):
elif op in ('>=', '') and not (c >= v): # if no constraint passed assume '>=required'
result = False
elif op == '<=' and not (current <= v):
elif op == '<=' and not (c <= v):
result = False
elif op == '>' and not (current > v):
elif op == '>' and not (c > v):
result = False
elif op == '<' and not (current < v):
elif op == '<' and not (c < v):
result = False
if not result:
warning_message = f'WARNING ⚠️ {name}{op}{required} is required, but {name}=={current} is currently installed'