3.0 KiB
Visualization
Visualization can give an intuitive interpretation of the performance of the model.
How visualization is implemented
It is recommended to learn the basic concept of visualization in engine.md.
OpenMMLab 2.0 introduces the visualization object Visualizer
and several visualization backends VisBackend
. The diagram below shows the relationship between Visualizer
and VisBackend
,
What Visualization do in MMSelfsup
(1) Save training data using different storage backends
The backends in MMEngine includes LocalVisBackend
, TensorboardVisBackend
and WandbVisBackend
.
During training, after_train_iter() in the default hook LoggerHook
will be called, and use add_scalars
in different backends, as follows:
...
def after_train_iter(...):
...
runner.visualizer.add_scalars(
tag, step=runner.iter + 1, file_path=self.json_log_path)
...
(2) Browse dataset
The function add_datasample()
is impleted in SelfSupVisualizer
, and it is mainly used in browse_dataset.py for browsing dataset. More tutorial is in analysis_tools.md
Use different storage backends
If you want to use a different backend (Wandb, Tensorboard, or a custom backend with a remote window), just change the vis_backends
in the config, as follows:
Local
vis_backends = [dict(type='LocalVisBackend')]
Tensorboard
vis_backends = [dict(type='TensorboardVisBackend')]
visualizer = dict(
type='SelfSupVisualizer', vis_backends=vis_backends, name='visualizer')
Wandb
vis_backends = [dict(type='WandbVisBackend')]
visualizer = dict(
type='SelfSupVisualizer', vis_backends=vis_backends, name='visualizer')
Note that when multiple visualization backends exist for vis_backends
, only WandbVisBackend
is valid.
Customize Visualization
The customization of the visualization is similar to other components. If you want to customize Visualizer
, VisBackend
or VisualizationHook
, you can refer to Visualization Doc in MMEngine.