Skip to content

Commit

Permalink
[Feature] Dedicated WandbLogger for MMDetection (#7459)
Browse files Browse the repository at this point in the history
* [Fix] Adjust the order of get_classes and FileClient. (#7276)

* delete -sv (#7277)

Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>

* wandb-integration

* docstring

* lint

* log config+handle segmentation results

* remove val logging

* segmentation logging

* metadata logging improved + remove best metadata

* remove extra arg

* train.py conflict

* shuffle eval data+remove config

* wandb config file

* iter based logging + cleanup

* minor update

* minor update

* minor fix

* epoch and iter eval table

* save and log config

* Delete mask_rcnn_r50_fpn_1x_wandb_iter_coco.py

Co-authored-by: Wencheng Wu <41542251+274869388@users.noreply.github.com>
Co-authored-by: Yue Zhou <592267829@qq.com>
Co-authored-by: Wenwei Zhang <40779233+ZwwWayne@users.noreply.github.com>
  • Loading branch information
4 people authored May 27, 2022
1 parent f3a451a commit b637c99
Show file tree
Hide file tree
Showing 4 changed files with 604 additions and 1 deletion.
26 changes: 26 additions & 0 deletions configs/mask_rcnn/mask_rcnn_r50_fpn_1x_wandb_coco.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
_base_ = [
'../_base_/models/mask_rcnn_r50_fpn.py',
'../_base_/datasets/coco_instance.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]

# Set evaluation interval
evaluation = dict(interval=2)
# Set checkpoint interval
checkpoint_config = dict(interval=4)

# yapf:disable
log_config = dict(
interval=50,
hooks=[
dict(type='TextLoggerHook'),
dict(type='MMDetWandbHook',
init_kwargs={
'project': 'mmdetection',
'group': 'maskrcnn-r50-fpn-1x-coco'
},
interval=50,
log_checkpoint=True,
log_checkpoint_metadata=True,
num_eval_images=100)
])
10 changes: 10 additions & 0 deletions mmdet/core/evaluation/eval_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class EvalHook(BaseEvalHook):

def __init__(self, *args, dynamic_intervals=None, **kwargs):
super(EvalHook, self).__init__(*args, **kwargs)
self.latest_results = None

self.use_dynamic_intervals = dynamic_intervals is not None
if self.use_dynamic_intervals:
Expand Down Expand Up @@ -53,7 +54,11 @@ def _do_evaluate(self, runner):
return

from mmdet.apis import single_gpu_test

# Changed results to self.results so that MMDetWandbHook can access
# the evaluation results and log them to wandb.
results = single_gpu_test(runner.model, self.dataloader, show=False)
self.latest_results = results
runner.log_buffer.output['eval_iter_num'] = len(self.dataloader)
key_score = self.evaluate(runner, results)
# the key_score may be `None` so it needs to skip the action to save
Expand All @@ -69,6 +74,7 @@ class DistEvalHook(BaseDistEvalHook):

def __init__(self, *args, dynamic_intervals=None, **kwargs):
super(DistEvalHook, self).__init__(*args, **kwargs)
self.latest_results = None

self.use_dynamic_intervals = dynamic_intervals is not None
if self.use_dynamic_intervals:
Expand Down Expand Up @@ -114,11 +120,15 @@ def _do_evaluate(self, runner):
tmpdir = osp.join(runner.work_dir, '.eval_hook')

from mmdet.apis import multi_gpu_test

# Changed results to self.results so that MMDetWandbHook can access
# the evaluation results and log them to wandb.
results = multi_gpu_test(
runner.model,
self.dataloader,
tmpdir=tmpdir,
gpu_collect=self.gpu_collect)
self.latest_results = results
if runner.rank == 0:
print('\n')
runner.log_buffer.output['eval_iter_num'] = len(self.dataloader)
Expand Down
4 changes: 3 additions & 1 deletion mmdet/core/hook/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
from .set_epoch_info_hook import SetEpochInfoHook
from .sync_norm_hook import SyncNormHook
from .sync_random_size_hook import SyncRandomSizeHook
from .wandblogger_hook import MMDetWandbHook
from .yolox_lrupdater_hook import YOLOXLrUpdaterHook
from .yolox_mode_switch_hook import YOLOXModeSwitchHook

__all__ = [
'SyncRandomSizeHook', 'YOLOXModeSwitchHook', 'SyncNormHook',
'ExpMomentumEMAHook', 'LinearMomentumEMAHook', 'YOLOXLrUpdaterHook',
'CheckInvalidLossHook', 'SetEpochInfoHook', 'MemoryProfilerHook'
'CheckInvalidLossHook', 'SetEpochInfoHook', 'MemoryProfilerHook',
'MMDetWandbHook'
]
Loading

0 comments on commit b637c99

Please sign in to comment.