WandbVisBackend¶
- class mmengine.visualization.WandbVisBackend(save_dir, init_kwargs=None, define_metric_cfg=None, commit=True, log_code_name=None, watch_kwargs=None)[source]¶
Wandb visualization backend class.
Examples
>>> from mmengine.visualization import WandbVisBackend >>> import numpy as np >>> wandb_vis_backend = WandbVisBackend() >>> img=np.random.randint(0, 256, size=(10, 10, 3)) >>> wandb_vis_backend.add_image('img', img) >>> wandb_vis_backend.add_scaler('mAP', 0.6) >>> wandb_vis_backend.add_scalars({'loss': [1, 2, 3],'acc': 0.8}) >>> cfg = Config(dict(a=1, b=dict(b1=[0, 1]))) >>> wandb_vis_backend.add_config(cfg)
- Parameters
save_dir (str, optional) – The root directory to save the files produced by the visualizer.
init_kwargs (dict, optional) – wandb initialization input parameters. See wandb.init for details. Defaults to None.
define_metric_cfg (dict, optional) – A dict of metrics and summary for wandb.define_metric. The key is metric and the value is summary. When
define_metric_cfg={'coco/bbox_mAP': 'max'}
, The maximum value ofcoco/bbox_mAP
is logged on wandb UI. See wandb define_metric for details. Default: Nonecommit (Optional[bool]) – (bool, optional) Save the metrics dict to the wandb server and increment the step. If false wandb.log just updates the current metrics dict with the row argument and metrics won’t be saved until wandb.log is called with commit=True. Defaults to True.
log_code_name (Optional[str]) – (str, optional) The name of code artifact. By default, the artifact will be named source-$PROJECT_ID-$ENTRYPOINT_RELPATH. See wandb log_code for details. Defaults to None. New in version 0.3.0.
watch_kwargs (optional, dict) – Agurments for
wandb.watch
. New in version 0.4.0.
- add_config(config, **kwargs)[source]¶
Record the config to wandb.
- Parameters
config (Config) – The Config object
- Return type
None
- add_graph(model, data_batch, **kwargs)[source]¶
Record the model graph.
- Parameters
model (torch.nn.Module) – Model to draw.
data_batch (Sequence[dict]) – Batch of data from dataloader.
- Return type
None
- add_scalar(name, value, step=0, **kwargs)[source]¶
Record the scalar data to wandb.
- Parameters
name (str) – The scalar identifier.
value (int, float, torch.Tensor, np.ndarray) – Value to save.
step (int) – Useless parameter. Wandb does not need this parameter. Defaults to 0.
- Return type
None
- add_scalars(scalar_dict, step=0, file_path=None, **kwargs)[source]¶
Record the scalar’s data to wandb.
- property experiment¶
Return wandb object.
The experiment attribute can get the wandb backend, If you want to write other data, such as writing a table, you can directly get the wandb backend through experiment.