|
|
@@ -44,10 +44,21 @@ cv2.setNumThreads(0) # prevent OpenCV from multithreading (incompatible with Py |
|
|
|
os.environ['NUMEXPR_MAX_THREADS'] = str(NUM_THREADS) # NumExpr max threads |
|
|
|
|
|
|
|
|
|
|
|
def is_kaggle(): |
|
|
|
# Is environment a Kaggle Notebook? |
|
|
|
try: |
|
|
|
assert os.environ.get('PWD') == '/kaggle/working' |
|
|
|
assert os.environ.get('KAGGLE_URL_BASE') == 'https://www.kaggle.com' |
|
|
|
return True |
|
|
|
except AssertionError: |
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
def set_logging(name=None, verbose=True): |
|
|
|
# Sets level and returns logger |
|
|
|
for h in logging.root.handlers: |
|
|
|
logging.root.removeHandler(h) # remove all handlers associated with the root logger object |
|
|
|
if is_kaggle(): |
|
|
|
for h in logging.root.handlers: |
|
|
|
logging.root.removeHandler(h) # remove all handlers associated with the root logger object |
|
|
|
rank = int(os.getenv('RANK', -1)) # rank in world for Multi-GPU trainings |
|
|
|
logging.basicConfig(format="%(message)s", level=logging.INFO if (verbose and rank in (-1, 0)) else logging.WARNING) |
|
|
|
return logging.getLogger(name) |