ultralytics 8.0.20
CLI yolo
simplifications, DDP and ONNX fixes (#608)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Sid Prabhakaran <s2siddhu@gmail.com>
This commit is contained in:
@ -1,14 +1,19 @@
|
||||
# Ultralytics YOLO 🚀, GPL-3.0 license
|
||||
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
from pathlib import Path
|
||||
from random import random
|
||||
|
||||
import requests
|
||||
|
||||
from ultralytics.yolo.utils import DEFAULT_CFG_DICT, LOGGER, RANK, SETTINGS, TryExcept, colorstr, emojis
|
||||
from ultralytics.yolo.utils import (DEFAULT_CFG_DICT, LOGGER, RANK, SETTINGS, TryExcept, colorstr, emojis,
|
||||
get_git_origin_url, is_colab, is_docker, is_git_dir, is_github_actions_ci,
|
||||
is_jupyter, is_kaggle, is_pip_package, is_pytest_running)
|
||||
|
||||
PREFIX = colorstr('Ultralytics: ')
|
||||
HELP_MSG = 'If this issue persists please visit https://github.com/ultralytics/hub/issues for assistance.'
|
||||
@ -131,21 +136,57 @@ def smart_request(*args, retry=3, timeout=30, thread=True, code=-1, method="post
|
||||
return func(*args, **kwargs)
|
||||
|
||||
|
||||
@TryExcept(verbose=False)
|
||||
def traces(cfg, all_keys=False, traces_sample_rate=0.0):
|
||||
"""
|
||||
Sync traces data if enabled in the global settings
|
||||
class Traces:
|
||||
|
||||
Args:
|
||||
cfg (IterableSimpleNamespace): Configuration for the task and mode.
|
||||
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 SETTINGS['sync'] and RANK in {-1, 0} and (random() < traces_sample_rate):
|
||||
cfg = vars(cfg) # convert type from IterableSimpleNamespace to dict
|
||||
if not all_keys:
|
||||
cfg = {k: v for k, v in cfg.items() if v != DEFAULT_CFG_DICT.get(k, None)} # retain non-default values
|
||||
cfg['uuid'] = SETTINGS['uuid'] # add the device UUID to the configuration data
|
||||
def __init__(self):
|
||||
"""
|
||||
Initialize Traces for error tracking and reporting if tests are not currently running.
|
||||
"""
|
||||
from ultralytics import __version__
|
||||
env = 'Colab' if is_colab() else 'Kaggle' if is_kaggle() else 'Jupyter' if is_jupyter() else \
|
||||
'Docker' if is_docker() else platform.system()
|
||||
self.rate_limit = 3.0 # rate limit (seconds)
|
||||
self.t = time.time() # rate limit timer (seconds)
|
||||
self.metadata = {
|
||||
"sys_argv_name": Path(sys.argv[0]).name,
|
||||
"install": 'git' if is_git_dir() else 'pip' if is_pip_package() else 'other',
|
||||
"python": platform.python_version(),
|
||||
"release": __version__,
|
||||
"environment": env}
|
||||
self.enabled = SETTINGS['sync'] and \
|
||||
RANK in {-1, 0} and \
|
||||
not is_pytest_running() and \
|
||||
not is_github_actions_ci() and \
|
||||
(is_pip_package() or get_git_origin_url() == "https://github.com/ultralytics/ultralytics.git")
|
||||
|
||||
# Send a request to the HUB API to sync analytics
|
||||
smart_request(f'{HUB_API_ROOT}/v1/usage/anonymous', json=cfg, headers=None, code=3, retry=0, verbose=False)
|
||||
@TryExcept(verbose=False)
|
||||
def __call__(self, cfg, all_keys=False, traces_sample_rate=1.0):
|
||||
"""
|
||||
Sync traces data if enabled in the global settings
|
||||
|
||||
Args:
|
||||
cfg (IterableSimpleNamespace): Configuration for the task and mode.
|
||||
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
|
||||
"""
|
||||
t = time.time() # current time
|
||||
if self.enabled and random() < traces_sample_rate and (t - self.t) > self.rate_limit:
|
||||
self.t = t # reset rate limit timer
|
||||
cfg = vars(cfg) # convert type from IterableSimpleNamespace to dict
|
||||
if not all_keys: # filter cfg
|
||||
include_keys = {'task', 'mode'} # always include
|
||||
cfg = {k: v for k, v in cfg.items() if v != DEFAULT_CFG_DICT.get(k, None) or k in include_keys}
|
||||
trace = {'uuid': SETTINGS['uuid'], 'cfg': cfg, 'metadata': self.metadata}
|
||||
|
||||
# Send a request to the HUB API to sync analytics
|
||||
smart_request(f'{HUB_API_ROOT}/v1/usage/anonymous',
|
||||
json=trace,
|
||||
headers=None,
|
||||
code=3,
|
||||
retry=0,
|
||||
verbose=False)
|
||||
|
||||
|
||||
# Run below code on hub/utils init -------------------------------------------------------------------------------------
|
||||
|
||||
traces = Traces()
|
||||
|
Reference in New Issue
Block a user