Update get_loggers() (#4854)

* Update `set_logging()`

* Update export.py

* pre-commit fixes

* Update LoadImages

* Update LoadStreams

* Update print_args

* Single LOGGER definition

* yolo.py fix

Co-authored-by: pre-commit <pre-commit@example.com>
This commit is contained in:
Glenn Jocherandpre-commit authored and GitHub committed 2021-11-01 18:22:13 +01:00
1 parent 8c326a1edf
commit 7b1f7aec46
8 files changed
+84 -91

No files matched your search

+11 -7
View File
@@ -42,6 +42,16 @@ FILE = Path(__file__).resolve()
ROOT = FILE.parents[1] # YOLOv5 root directory
def set_logging(name=None, verbose=True):
# Sets level and returns logger
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.WARN)
return logging.getLogger(name)
LOGGER = set_logging(__name__) # define globally (used in train.py, val.py, detect.py, etc.)
class Profile(contextlib.ContextDecorator):
# Usage: @Profile() decorator or 'with Profile():' context manager
def __enter__(self):
@@ -87,15 +97,9 @@ def methods(instance):
return [f for f in dir(instance) if callable(getattr(instance, f)) and not f.startswith("__")]
def set_logging(rank=-1, verbose=True):
logging.basicConfig(
format="%(message)s",
level=logging.INFO if (verbose and rank in [-1, 0]) else logging.WARN)
def print_args(name, opt):
# Print argparser arguments
print(colorstr(f'{name}: ') + ', '.join(f'{k}={v}' for k, v in vars(opt).items()))
LOGGER.info(colorstr(f'{name}: ') + ', '.join(f'{k}={v}' for k, v in vars(opt).items()))
def init_seeds(seed=0):