Shortcuts

LocalVisBackend

class mmengine.visualization.LocalVisBackend(save_dir, img_save_dir='vis_image', config_save_file='config.py', scalar_save_file='scalars.json')[source]

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.

Examples

>>> 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)
Parameters:
  • 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)[source]

Record the config to disk.

Parameters:

config (Config) – The Config object

Return type:

None

add_image(name, image, step=0, **kwargs)[source]

Record the image to disk.

Parameters:
  • name (str) – The image identifier.

  • image (np.ndarray) – The image to be saved. The format should be RGB. Defaults to None.

  • step (int) – Global step value to record. Defaults to 0.

Return type:

None

add_scalar(name, value, step=0, **kwargs)[source]

Record the scalar data to disk.

Parameters:
  • 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.

Return type:

None

add_scalars(scalar_dict, step=0, file_path=None, **kwargs)[source]

Record the scalars to disk.

The scalar dict will be written to the default and specified files if file_path is specified.

Parameters:
  • 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 the file_path parameter is specified. Defaults to None.

Return type:

None

property experiment: LocalVisBackend

Return the experiment object associated with this visualization backend.

Read the Docs v: latest
Versions
latest
stable
v0.10.3
v0.10.2
v0.10.1
v0.10.0
v0.9.1
v0.9.0
v0.8.5
v0.8.4
v0.8.3
v0.8.2
v0.8.1
v0.8.0
v0.7.4
v0.7.3
v0.7.2
v0.7.1
v0.7.0
v0.6.0
v0.5.0
v0.4.0
v0.3.0
v0.2.0
Downloads
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.