ultralytics 8.1.44 add IS_RASPBERRYPI and constants refactor (#9827)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
parent
3f34a7c3af
commit
7d891a4aa4
43 changed files with 146 additions and 141 deletions
|
|
@ -3,7 +3,7 @@
|
|||
import requests
|
||||
|
||||
from ultralytics.hub.utils import HUB_API_ROOT, HUB_WEB_ROOT, PREFIX, request_with_credentials
|
||||
from ultralytics.utils import LOGGER, SETTINGS, emojis, is_colab
|
||||
from ultralytics.utils import IS_COLAB, LOGGER, SETTINGS, emojis
|
||||
|
||||
API_KEY_URL = f"{HUB_WEB_ROOT}/settings?tab=api+keys"
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ class Auth:
|
|||
# Attempt to authenticate with the provided API key
|
||||
success = self.authenticate()
|
||||
# If the API key is not provided and the environment is a Google Colab notebook
|
||||
elif is_colab():
|
||||
elif IS_COLAB:
|
||||
# Attempt to authenticate using browser cookies
|
||||
success = self.auth_with_cookies()
|
||||
else:
|
||||
|
|
@ -109,7 +109,7 @@ class Auth:
|
|||
Returns:
|
||||
(bool): True if authentication is successful, False otherwise.
|
||||
"""
|
||||
if not is_colab():
|
||||
if not IS_COLAB:
|
||||
return False # Currently only works with Colab
|
||||
try:
|
||||
authn = request_with_credentials(f"{HUB_API_ROOT}/v1/auth/auto")
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ from pathlib import Path
|
|||
|
||||
import requests
|
||||
|
||||
from ultralytics.hub.utils import HUB_WEB_ROOT, HELP_MSG, PREFIX, TQDM
|
||||
from ultralytics.utils import LOGGER, SETTINGS, __version__, checks, emojis, is_colab
|
||||
from ultralytics.hub.utils import HELP_MSG, HUB_WEB_ROOT, PREFIX, TQDM
|
||||
from ultralytics.utils import IS_COLAB, LOGGER, SETTINGS, __version__, checks, emojis
|
||||
from ultralytics.utils.errors import HUBModelError
|
||||
|
||||
AGENT_NAME = f"python-{__version__}-colab" if is_colab() else f"python-{__version__}-local"
|
||||
AGENT_NAME = f"python-{__version__}-colab" if IS_COLAB else f"python-{__version__}-local"
|
||||
|
||||
|
||||
class HUBTrainingSession:
|
||||
|
|
|
|||
|
|
@ -12,6 +12,9 @@ import requests
|
|||
from ultralytics.utils import (
|
||||
ARGV,
|
||||
ENVIRONMENT,
|
||||
IS_COLAB,
|
||||
IS_GIT_DIR,
|
||||
IS_PIP_PACKAGE,
|
||||
LOGGER,
|
||||
ONLINE,
|
||||
RANK,
|
||||
|
|
@ -22,9 +25,6 @@ from ultralytics.utils import (
|
|||
__version__,
|
||||
colorstr,
|
||||
get_git_origin_url,
|
||||
is_colab,
|
||||
is_git_dir,
|
||||
is_pip_package,
|
||||
)
|
||||
from ultralytics.utils.downloads import GITHUB_ASSETS_NAMES
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ def request_with_credentials(url: str) -> any:
|
|||
Raises:
|
||||
OSError: If the function is not run in a Google Colab environment.
|
||||
"""
|
||||
if not is_colab():
|
||||
if not IS_COLAB:
|
||||
raise OSError("request_with_credentials() must run in a Colab environment")
|
||||
from google.colab import output # noqa
|
||||
from IPython import display # noqa
|
||||
|
|
@ -189,7 +189,7 @@ class Events:
|
|||
self.t = 0.0 # rate limit timer (seconds)
|
||||
self.metadata = {
|
||||
"cli": Path(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": ".".join(platform.python_version_tuple()[:2]), # i.e. 3.10
|
||||
"version": __version__,
|
||||
"env": ENVIRONMENT,
|
||||
|
|
@ -201,7 +201,7 @@ class Events:
|
|||
and RANK in {-1, 0}
|
||||
and not TESTS_RUNNING
|
||||
and ONLINE
|
||||
and (is_pip_package() or get_git_origin_url() == "https://github.com/ultralytics/ultralytics.git")
|
||||
and (IS_PIP_PACKAGE or get_git_origin_url() == "https://github.com/ultralytics/ultralytics.git")
|
||||
)
|
||||
|
||||
def __call__(self, cfg):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue