`ultralytics 8.0.85` docs and events updates (#2189)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
single_channel
Glenn Jocher 2 years ago committed by GitHub
parent 4af9ca7382
commit 283e334bd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,42 @@
User-agent: *
Disallow: /tutorials/pruning-sparsity/
Disallow: /tutorials/nvidia-jetson/
Disallow: /tutorials/training-tips-best-results/
Disallow: /tutorials/hyperparameter-evolution/
Disallow: /callbacks/
Disallow: /config/
Disallow: /tutorials/transfer-learning-froze-layers/
Disallow: /environments/Docker-Quickstart/
Disallow: /tutorials/model-ensembling/
Disallow: /tutorials/test-time-augmentation/
Disallow: /quick-start/
Disallow: /FAQ/augmentation/
Disallow: /environments/AWS-Quickstart/
Disallow: /tutorials/pytorch-hub/
Disallow: /tutorials/torchscript-onnx-coreml-export/
Disallow: /tasks/tracking/
Disallow: /cfg/
Disallow: /tasks/detection/
Disallow: /tutorials/train-custom-datasets/
Disallow: /cli/
Disallow: /tasks/classification/
Disallow: /tutorials/multi-gpu-training/
Disallow: /engine/
Disallow: /tasks/segmentation/
Disallow: /predict/
Disallow: /python/
Disallow: /python
Disallow: /environments/GCP-Quickstart/
Disallow: /cli
Disallow: /tutorials/comet-logging/
Disallow: /cfg
Disallow: /tutorials/architecture-summary/
Disallow: /tutorials/clearml-logging/
Disallow: /sdk/
Disallow: /tutorials/roboflow/
Disallow: /tutorials/training-tips-best-results
Disallow: /package-framework/mock_detector/
Disallow: /package-framework/
Disallow: /tutorials/weights-and-biasis-logging/
Disallow: /tutorials/pruning-sparsity
Disallow: /tutorials/train-custom-datasets

@ -88,6 +88,9 @@ extra:
extra_css: extra_css:
- stylesheets/style.css - stylesheets/style.css
extra_files:
- robots.txt
markdown_extensions: markdown_extensions:
# Div text decorators # Div text decorators
- admonition - admonition
@ -123,22 +126,23 @@ plugins:
# Primary navigation # Primary navigation
nav: nav:
- Home: index.md - Home:
- Quickstart: quickstart.md - index.md
- Modes: - Quickstart: quickstart.md
- modes/index.md - Modes:
- Train: modes/train.md - modes/index.md
- Val: modes/val.md - Train: modes/train.md
- Predict: modes/predict.md - Val: modes/val.md
- Export: modes/export.md - Predict: modes/predict.md
- Track: modes/track.md - Export: modes/export.md
- Benchmark: modes/benchmark.md - Track: modes/track.md
- Tasks: - Benchmark: modes/benchmark.md
- tasks/index.md - Tasks:
- Detect: tasks/detect.md - tasks/index.md
- Segment: tasks/segment.md - Detect: tasks/detect.md
- Classify: tasks/classify.md - Segment: tasks/segment.md
- Pose: tasks/pose.md - Classify: tasks/classify.md
- Pose: tasks/pose.md
- Usage: - Usage:
- CLI: usage/cli.md - CLI: usage/cli.md
- Python: usage/python.md - Python: usage/python.md

@ -1,6 +1,6 @@
# Ultralytics YOLO 🚀, AGPL-3.0 license # Ultralytics YOLO 🚀, AGPL-3.0 license
__version__ = '8.0.84' __version__ = '8.0.85'
from ultralytics.hub import start from ultralytics.hub import start
from ultralytics.yolo.engine.model import YOLO from ultralytics.yolo.engine.model import YOLO

@ -6,7 +6,6 @@ import sys
import threading import threading
import time import time
from pathlib import Path from pathlib import Path
from random import random
import requests import requests
from tqdm import tqdm from tqdm import tqdm
@ -114,7 +113,7 @@ def smart_request(method, url, retry=3, timeout=30, thread=True, code=-1, verbos
if (time.time() - t0) > timeout: if (time.time() - t0) > timeout:
break break
r = requests_with_progress(func_method, func_url, **func_kwargs) # i.e. get(url, data, json, files) r = requests_with_progress(func_method, func_url, **func_kwargs) # i.e. get(url, data, json, files)
if r.status_code == 200: if r.status_code < 300: # return codes in the 2xx range are generally considered "good" or "successful"
break break
try: try:
m = r.json().get('message', 'No JSON message.') m = r.json().get('message', 'No JSON message.')
@ -142,66 +141,72 @@ def smart_request(method, url, retry=3, timeout=30, thread=True, code=-1, verbos
return func(*args, **kwargs) return func(*args, **kwargs)
class Traces: class Events:
"""
A class for collecting anonymous event analytics. Event analytics are enabled when sync=True in settings and
disabled when sync=False. Run 'yolo settings' to see and update settings YAML file.
Attributes:
url (str): The GA4 Measurement Protocol URL.
rate_limit (float): The rate limit in seconds for sending events.
metadata (dict): A dictionary containing metadata about the environment.
enabled (bool): A flag to enable or disable Events based on certain conditions.
"""
url = 'https://www.google-analytics.com/mp/collect?measurement_id=G-X8NCJYTQXM&api_secret=QLQrATrNSwGRFRLE-cbHJw'
def __init__(self): def __init__(self):
""" """
Initialize Traces for error tracking and reporting if tests are not currently running. Initializes the Events object with default values for events, rate_limit, and metadata.
Sets the rate limit, timer, and metadata attributes, and determines whether Traces are enabled.
""" """
self.rate_limit = 60.0 # rate limit (seconds) self.events = [] # events list
self.rate_limit = 10.0 # rate limit (seconds)
self.t = 0.0 # rate limit timer (seconds) self.t = 0.0 # rate limit timer (seconds)
self.metadata = { self.metadata = {
'sys_argv_name': Path(sys.argv[0]).name, 'cli': Path(sys.argv[0]).name == 'yolo',
'install': 'git' if is_git_dir() else 'pip' if is_pip_package() else 'other', 'install': 'git' if is_git_dir() else 'pip' if is_pip_package() else 'other',
'python': platform.python_version(), 'python': platform.python_version(),
'release': __version__, 'version': __version__,
'environment': ENVIRONMENT} 'env': ENVIRONMENT}
self.enabled = \ self.enabled = \
SETTINGS['sync'] and \ SETTINGS['sync'] and \
RANK in (-1, 0) and \ RANK in (-1, 0) and \
not TESTS_RUNNING and \ not TESTS_RUNNING and \
ONLINE and \ ONLINE and \
(is_pip_package() or get_git_origin_url() == 'https://github.com/ultralytics/ultralytics.git') (is_pip_package() or get_git_origin_url() == 'https://github.com/ultralytics/ultralytics.git')
self._reset_usage()
def __call__(self, cfg, all_keys=False, traces_sample_rate=1.0): def __call__(self, cfg):
""" """
Sync traces data if enabled in the global settings. Attempts to add a new event to the events list and send events if the rate limit is reached.
Args: Args:
cfg (IterableSimpleNamespace): Configuration for the task and mode. cfg: The configuration object containing mode and task information.
all_keys (bool): Sync all items, not just non-default values.
traces_sample_rate (float): Fraction of traces captured from 0.0 to 1.0.
""" """
if not self.enabled:
# Increment usage # Events disabled, do nothing
self.usage['modes'][cfg.mode] = self.usage['modes'].get(cfg.mode, 0) + 1
self.usage['tasks'][cfg.task] = self.usage['tasks'].get(cfg.task, 0) + 1
t = time.time() # current time
if not self.enabled or random() > traces_sample_rate:
# Traces disabled or not randomly selected, do nothing
return
elif (t - self.t) < self.rate_limit:
# Time is under rate limiter, do nothing
return return
else:
# Time is over rate limiter, send trace now
trace = {'uuid': SETTINGS['uuid'], 'usage': self.usage.copy(), 'metadata': self.metadata}
# Send a request to the HUB API to sync analytics # Attempt to add to events
smart_request('post', f'{HUB_API_ROOT}/v1/usage/anonymous', json=trace, code=3, retry=0, verbose=False) if len(self.events) < 25: # Events list limited to 25 events (drop any events past this)
params = {**self.metadata, **{'task': cfg.task}}
if cfg.mode == 'export':
params['format'] = cfg.format
self.events.append({'name': cfg.mode, 'params': params})
# Check rate limit
t = time.time()
if (t - self.t) < self.rate_limit:
# Time is under rate limiter, wait to send
return
# Reset usage and rate limit timer # Time is over rate limiter, send now
self._reset_usage() data = {'client_id': SETTINGS['uuid'], 'events': self.events} # SHA-256 anonymized UUID hash and events list
self.t = t smart_request('post', self.url, json=data, retry=0, code=3) # equivalent to requests.post(self.url, json=data)
def _reset_usage(self): # Reset events and rate limit timer
"""Reset the usage dictionary by initializing keys for each task and mode with a value of 0.""" self.events = []
from ultralytics.yolo.cfg import MODES, TASKS self.t = t
self.usage = {'tasks': {k: 0 for k in TASKS}, 'modes': {k: 0 for k in MODES}}
# Run below code on hub/utils init ------------------------------------------------------------------------------------- # Run below code on hub/utils init -------------------------------------------------------------------------------------
traces = Traces() events = Events()

@ -670,7 +670,7 @@ def get_settings(file=SETTINGS_YAML, version='0.0.3'):
'datasets_dir': str(datasets_root / 'datasets'), # default datasets directory. 'datasets_dir': str(datasets_root / 'datasets'), # default datasets directory.
'weights_dir': str(root / 'weights'), # default weights directory. 'weights_dir': str(root / 'weights'), # default weights directory.
'runs_dir': str(root / 'runs'), # default runs directory. 'runs_dir': str(root / 'runs'), # default runs directory.
'uuid': hashlib.sha256(str(uuid.getnode()).encode()).hexdigest(), # anonymized uuid hash 'uuid': hashlib.sha256(str(uuid.getnode()).encode()).hexdigest(), # SHA-256 anonymized UUID hash
'sync': True, # sync analytics to help with YOLO development 'sync': True, # sync analytics to help with YOLO development
'api_key': '', # Ultralytics HUB API key (https://hub.ultralytics.com/) 'api_key': '', # Ultralytics HUB API key (https://hub.ultralytics.com/)
'settings_version': version} # Ultralytics settings version 'settings_version': version} # Ultralytics settings version

@ -196,16 +196,16 @@ def add_integration_callbacks(instance):
instance (Trainer, Predictor, Validator, Exporter): An object with a 'callbacks' attribute that is a dictionary instance (Trainer, Predictor, Validator, Exporter): An object with a 'callbacks' attribute that is a dictionary
of callback lists. of callback lists.
""" """
from .clearml import callbacks as clearml_callbacks from .clearml import callbacks as clearml_cb
from .comet import callbacks as comet_callbacks from .comet import callbacks as comet_cb
from .hub import callbacks as hub_callbacks from .hub import callbacks as hub_cb
from .mlflow import callbacks as mf_callbacks from .mlflow import callbacks as mlflow_cb
from .neptune import callbacks as neptune_callbacks from .neptune import callbacks as neptune_cb
from .raytune import callbacks as tune_callbacks from .raytune import callbacks as tune_cb
from .tensorboard import callbacks as tb_callbacks from .tensorboard import callbacks as tensorboard_cb
from .wb import callbacks as wb_callbacks from .wb import callbacks as wb_cb
for x in clearml_callbacks, comet_callbacks, hub_callbacks, tb_callbacks, mf_callbacks, tune_callbacks, wb_callbacks, neptune_callbacks: for x in clearml_cb, comet_cb, hub_cb, mlflow_cb, neptune_cb, tune_cb, tensorboard_cb, wb_cb:
for k, v in x.items(): for k, v in x.items():
if v not in instance.callbacks[k]: # prevent duplicate callbacks addition if v not in instance.callbacks[k]: # prevent duplicate callbacks addition
instance.callbacks[k].append(v) # callback[name].append(func) instance.callbacks[k].append(v) # callback[name].append(func)

@ -3,7 +3,7 @@
import json import json
from time import time from time import time
from ultralytics.hub.utils import PREFIX, traces from ultralytics.hub.utils import PREFIX, events
from ultralytics.yolo.utils import LOGGER from ultralytics.yolo.utils import LOGGER
from ultralytics.yolo.utils.torch_utils import get_flops, get_num_params from ultralytics.yolo.utils.torch_utils import get_flops, get_num_params
@ -61,23 +61,23 @@ def on_train_end(trainer):
def on_train_start(trainer): def on_train_start(trainer):
"""Run traces on train start.""" """Run events on train start."""
traces(trainer.args, traces_sample_rate=1.0) events(trainer.args)
def on_val_start(validator): def on_val_start(validator):
"""Runs traces on validation start.""" """Runs events on validation start."""
traces(validator.args, traces_sample_rate=1.0) events(validator.args)
def on_predict_start(predictor): def on_predict_start(predictor):
"""Run traces on predict start.""" """Run events on predict start."""
traces(predictor.args, traces_sample_rate=1.0) events(predictor.args)
def on_export_start(exporter): def on_export_start(exporter):
"""Run traces on export start.""" """Run events on export start."""
traces(exporter.args, traces_sample_rate=1.0) events(exporter.args)
callbacks = { callbacks = {

@ -128,10 +128,11 @@ def check_latest_pypi_version(package_name='ultralytics'):
Returns: Returns:
(str): The latest version of the package. (str): The latest version of the package.
""" """
requests.packages.urllib3.disable_warnings() # Disable the InsecureRequestWarning with contextlib.suppress(Exception):
response = requests.get(f'https://pypi.org/pypi/{package_name}/json', verify=False) requests.packages.urllib3.disable_warnings() # Disable the InsecureRequestWarning
if response.status_code == 200: response = requests.get(f'https://pypi.org/pypi/{package_name}/json', timeout=3)
return response.json()['info']['version'] if response.status_code == 200:
return response.json()['info']['version']
return None return None

Loading…
Cancel
Save