Predictor support (#65)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Laughing-q <1185102784@qq.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
479992093c
commit
e6737f1207
22 changed files with 916 additions and 48 deletions
|
|
@ -6,6 +6,8 @@ import sys
|
|||
import threading
|
||||
from pathlib import Path
|
||||
|
||||
import IPython
|
||||
|
||||
# Constants
|
||||
FILE = Path(__file__).resolve()
|
||||
ROOT = FILE.parents[2] # YOLO
|
||||
|
|
@ -29,6 +31,23 @@ def is_kaggle():
|
|||
return os.environ.get('PWD') == '/kaggle/working' and os.environ.get('KAGGLE_URL_BASE') == 'https://www.kaggle.com'
|
||||
|
||||
|
||||
def is_notebook():
|
||||
# Is environment a Jupyter notebook? Verified on Colab, Jupyterlab, Kaggle, Paperspace
|
||||
ipython_type = str(type(IPython.get_ipython()))
|
||||
return 'colab' in ipython_type or 'zmqshell' in ipython_type
|
||||
|
||||
|
||||
def is_docker() -> bool:
|
||||
"""Check if the process runs inside a docker container."""
|
||||
if Path("/.dockerenv").exists():
|
||||
return True
|
||||
try: # check if docker is in control groups
|
||||
with open("/proc/self/cgroup") as file:
|
||||
return any("docker" in line for line in file)
|
||||
except OSError:
|
||||
return False
|
||||
|
||||
|
||||
def is_writeable(dir, test=False):
|
||||
# Return True if directory has write permissions, test opening a file with write permissions if test=True
|
||||
if not test:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue