Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor train.py and val.py loggers #4137

Merged
merged 27 commits into from
Jul 24, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update message
  • Loading branch information
glenn-jocher committed Jul 24, 2021
commit 9c4317acb5c9ddd67712d418a2bf14cc407fd2b7
12 changes: 10 additions & 2 deletions utils/loggers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import torch
from torch.utils.tensorboard import SummaryWriter

from utils.general import colorstr
from utils.torch_utils import de_parallel
from utils.general import colorstr, emojis
from utils.loggers.wandb.wandb_utils import WandbLogger
from utils.torch_utils import de_parallel

LOGGERS = ('txt', 'tb', 'wandb') # text-file, TensorBoard, Weights & Biases

Expand Down Expand Up @@ -37,6 +37,14 @@ def __init__(self, save_dir=None, results_file=None, weights=None, opt=None, hyp
def start(self):
self.txt = True # always log to txt

# Message
try:
import wandb
except ImportError:
prefix = colorstr('Weights & Biases: ')
s = f"{prefix}run 'pip install wandb' to automatically track and visualize YOLOv5 πŸš€ runs (RECOMMENDED)"
print(emojis(s))

# TensorBoard
s = self.save_dir
if 'tb' in self.include and not self.opt.evolve:
Expand Down
6 changes: 2 additions & 4 deletions utils/loggers/wandb/wandb_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities and tools for tracking runs with Weights & Biases."""

import logging
import os
import sys
Expand All @@ -13,16 +14,13 @@

from utils.datasets import LoadImagesAndLabels
from utils.datasets import img2label_paths
from utils.general import colorstr, check_dataset, check_file, emojis
from utils.general import check_dataset, check_file

try:
import wandb

assert hasattr(wandb, '__version__') # verify package import not local dir
except (ImportError, AssertionError):
prefix = colorstr('Weights & Biases: ')
s = f"{prefix}run 'pip install wandb' to automatically track and visualize YOLOv5 πŸš€ training (RECOMMENDED)"
print(emojis(s))
wandb = None

RANK = int(os.getenv('RANK', -1))
Expand Down