From f8816f58b7f4bf018ec0fdf546430295e5719205 Mon Sep 17 00:00:00 2001 From: Ayush Chaurasia Date: Wed, 24 Aug 2022 15:45:37 +0530 Subject: [PATCH] Infer Loggers project name (#9117) * smart project name inference * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update __init__.py Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher --- utils/loggers/__init__.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/utils/loggers/__init__.py b/utils/loggers/__init__.py index 006125edbcd9..59d4b566836a 100644 --- a/utils/loggers/__init__.py +++ b/utils/loggers/__init__.py @@ -252,7 +252,7 @@ def __init__(self, opt, console_logger, include=('tb', 'wandb')): self.tb = SummaryWriter(str(self.save_dir)) if wandb and 'wandb' in self.include: - self.wandb = wandb.init(project="YOLOv5-Classifier" if opt.project == "runs/train" else opt.project, + self.wandb = wandb.init(project=web_project_name(str(opt.project)), name=None if opt.name == "exp" else opt.name, config=opt) else: @@ -303,3 +303,11 @@ def log_tensorboard_graph(tb, model, imgsz=(640, 640)): tb.add_graph(torch.jit.trace(de_parallel(model), im, strict=False), []) except Exception as e: print(f'WARNING: TensorBoard graph visualization failure {e}') + + +def web_project_name(project): + # Convert local project name to web project name + if not project.startswith('runs/train'): + return project + suffix = '-Classify' if project.endswith('-cls') else '-Segment' if project.endswith('-seg') else '' + return f'YOLOv5{suffix}'