diff --git a/utils/general.py b/utils/general.py index de7871c..c451914 100644 --- a/utils/general.py +++ b/utils/general.py @@ -27,6 +27,7 @@ from typing import Optional from zipfile import ZipFile import cv2 +import IPython import numpy as np import pandas as pd import pkg_resources as pkg @@ -137,6 +138,11 @@ def user_config_dir(dir='Ultralytics', env_var='YOLOV5_CONFIG_DIR'): path.mkdir(exist_ok=True) # make if required return path +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 + CONFIG_DIR = user_config_dir() # Ultralytics settings dir