2.9 KiB
title |
---|
MMEngine |
:::tip If you are not already using ClearML, see Getting Started for setup instructions. :::
MMEngine is a library for training deep learning models based on PyTorch. MMEngine supports ClearML through a builtin logger: It automatically logs experiment environment information, such as required packages and uncommitted changes, and supports reporting scalars, parameters, and debug samples.
Integrate ClearML with the following steps:
-
Instantiate a
ClearMLVisBackend
object. This creates a ClearML Task that logs the experiment’s environment information.from mmengine.visualization import ClearMLVisBackend vis_backend = ClearMLVisBackend( artifact_suffix=('.py', 'pth'), init_kwargs=dict( project_name='examples', task_name='OpenMMLab cifar10', output_uri=True ) )
You can specify the following parameters:
init_kwargs
– A dictionary that contains the arguments to pass to ClearML'sTask.init()
.artifact_suffix
– At the end of training, artifacts with these suffixes will be uploaded to the task'soutput_uri
. Defaults to (.py
,pth
).
-
Log experiment parameters using
ClearMLVisBackend.add_config()
. Under theconfig
parameter, input a dictionary of parameter key-value pairs.cfg = Config(dict(a=1, b=dict(b1=[0, 1]))) vis_backend.add_config(config=cfg)
The parameters will be displayed in the ClearML WebApp, under the experiment’s Hyperparameters
-
Log your experiment’s scalars using either
ClearMLVisBackend.add_scalar()
for single values orClearMLVisBackend.add_scalars()
for multiple values:vis_backend.add_scalar(name='mAP', value=0.6, step=1) vis_backend.add_scalars(scalar_dict={'loss': 0.1,'acc':0.8}, step=1)
The scalars are displayed in the experiment's Scalars tab.
-
Report images to your experiment using
ClearMLVisBackend.add_image()
. Under theimage
parameter, input the image to be reported as annp.ndarray
in RGB format:img = np.random.randint(0, 256, size=(10, 10, 3)) vis_backend.add_image(name='img.png', image=img, step=1)
The images will be displayed in the experiment's Debug Samples
-
Once you've finished training, make sure to run
ClearMLVisBackend.close()
so that ClearML can mark the task as completed. This will also scan the directory for relevant artifacts with the suffixes input when instantiatingClearMLVisBackend
and log the artifacts to your experiment.vis_backend.close()