LocalVisBackend¶
- class mmengine.visualization.LocalVisBackend(save_dir, img_save_dir='vis_image', config_save_file='config.py', scalar_save_file='scalars.json')[源代码]¶
Local visualization backend class.
It can write image, config, scalars, etc. to the local hard disk. You can get the drawing backend through the experiment property for custom drawing.
示例
>>> from mmengine.visualization import LocalVisBackend >>> import numpy as np >>> local_vis_backend = LocalVisBackend(save_dir='temp_dir') >>> img = np.random.randint(0, 256, size=(10, 10, 3)) >>> local_vis_backend.add_image('img', img) >>> local_vis_backend.add_scalar('mAP', 0.6) >>> local_vis_backend.add_scalars({'loss': [1, 2, 3], 'acc': 0.8}) >>> cfg = Config(dict(a=1, b=dict(b1=[0, 1]))) >>> local_vis_backend.add_config(cfg)
- 参数:
save_dir (str, optional) – The root directory to save the files produced by the visualizer. If it is none, it means no data is stored.
img_save_dir (str) – The directory to save images. Defaults to ‘vis_image’.
config_save_file (str) – The file name to save config. Defaults to ‘config.py’.
scalar_save_file (str) – The file name to save scalar values. Defaults to ‘scalars.json’.
- add_config(config, **kwargs)[源代码]¶
Record the config to disk.
- 参数:
config (Config) – The Config object
- 返回类型:
None
- add_scalar(name, value, step=0, **kwargs)[源代码]¶
Record the scalar data to disk.
- 参数:
name (str) – The scalar identifier.
value (int, float, torch.Tensor, np.ndarray) – Value to save.
step (int) – Global step value to record. Defaults to 0.
- 返回类型:
None
- add_scalars(scalar_dict, step=0, file_path=None, **kwargs)[源代码]¶
Record the scalars to disk.
The scalar dict will be written to the default and specified files if
file_path
is specified.- 参数:
scalar_dict (dict) – Key-value pair storing the tag and corresponding values. The value must be dumped into json format.
step (int) – Global step value to record. Defaults to 0.
file_path (str, optional) – The scalar’s data will be saved to the
file_path
file at the same time if thefile_path
parameter is specified. Defaults to None.
- 返回类型:
None
- property experiment: LocalVisBackend¶
Return the experiment object associated with this visualization backend.