Skip to main content

Documentation Index

Fetch the complete documentation index at: https://wb-21fd5541-style-guide-models-integrations-20260527-015516.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

This page shows you how to use W&B with OpenMMLab’s MMEngine to track and visualize training runs. It’s for users who train deep learning models with MMEngine or OpenMMLab computer vision libraries and want to log metrics, configs, and visualizations to W&B. MMEngine by OpenMMLab is a foundational library for training deep learning models based on PyTorch. MMEngine implements a training architecture for the OpenMMLab algorithm library, providing a unified execution foundation for over 30 algorithm libraries within OpenMMLab. Its core components include the training engine, evaluation engine, and module management. W&B is directly integrated into MMEngine through a dedicated WandbVisBackend that you can use to:
  • Log training and evaluation metrics.
  • Log and manage experiment configs.
  • Log additional records such as graphs, images, and scalars.

Get started

Install openmim and wandb.
pip install -q -U openmim wandb
Next, install mmengine and mmcv using mim.
mim install -q mmengine mmcv

Use the WandbVisBackend with MMEngine runner

This section demonstrates a typical workflow using WandbVisBackend with mmengine.runner.Runner. The visualizer wraps the W&B backend so the MMEngine runner can route logs to W&B during training.
  1. Define a visualizer from a visualization config. The visualizer is what the runner uses to dispatch logs to the configured backend.
    from mmengine.visualization import Visualizer
    
    # define the visualization configs
    visualization_cfg = dict(
        name="wandb_visualizer",
        vis_backends=[
            dict(
                type='WandbVisBackend',
                init_kwargs=dict(project="mmengine"),
            )
        ],
        save_dir="runs/wandb"
    )
    
    # get the visualizer from the visualization configs
    visualizer = Visualizer.get_instance(**visualization_cfg)
    
    You pass a dictionary of arguments for W&B run initialization input parameters to init_kwargs.
  2. Initialize a runner with the visualizer, and call runner.train() to start training. The runner uses the visualizer to stream metrics and configs to W&B.
    from mmengine.runner import Runner
    
    # build the mmengine Runner which is a training helper for PyTorch
    runner = Runner(
        model,
        work_dir='runs/gan/',
        train_dataloader=train_dataloader,
        train_cfg=train_cfg,
        optim_wrapper=opt_wrapper_dict,
        visualizer=visualizer, # pass the visualizer
    )
    
    # start training
    runner.train()
    

Use the WandbVisBackend with OpenMMLab computer vision libraries

You can also use the WandbVisBackend to track experiments with OpenMMLab computer vision libraries such as MMDetection. The following example overrides the vis_backends entry from a base config so that the existing visualizer logs to W&B.
# inherit base configs from the default runtime configs
_base_ = ["../_base_/default_runtime.py"]

# Assign the `WandbVisBackend` config dictionary to the
# `vis_backends` of the `visualizer` from the base configs
_base_.visualizer.vis_backends = [
    dict(
        type='WandbVisBackend',
        init_kwargs={
            'project': 'mmdet',
            'entity': 'geekyrakshit'
        },
    ),
]