Welcome to MMCV’s documentation!¶
You can switch between Chinese and English documents in the lower-left corner of the layout.
Introduction¶
MMCV is a foundational library for computer vision research and provides the following functionalities.
It supports the following systems:
Linux
Windows
macOS
It supports many research projects as below:
MMClassification: OpenMMLab image classification toolbox and benchmark.
MMDetection: OpenMMLab detection toolbox and benchmark.
MMDetection3D: OpenMMLab’s next-generation platform for general 3D object detection.
MMRotate: OpenMMLab rotated object detection toolbox and benchmark.
MMYOLO: OpenMMLab YOLO series toolbox and benchmark.
MMSegmentation: OpenMMLab semantic segmentation toolbox and benchmark.
MMOCR: OpenMMLab text detection, recognition, and understanding toolbox.
MMPose: OpenMMLab pose estimation toolbox and benchmark.
MMHuman3D: OpenMMLab 3D human parametric model toolbox and benchmark.
MMSelfSup: OpenMMLab self-supervised learning toolbox and benchmark.
MMRazor: OpenMMLab model compression toolbox and benchmark.
MMFewShot: OpenMMLab fewshot learning toolbox and benchmark.
MMAction2: OpenMMLab’s next-generation action understanding toolbox and benchmark.
MMTracking: OpenMMLab video perception toolbox and benchmark.
MMFlow: OpenMMLab optical flow toolbox and benchmark.
MMEditing: OpenMMLab image and video editing toolbox.
MMGeneration: OpenMMLab image and video generative models toolbox.
MMDeploy: OpenMMLab model deployment framework.
Installation¶
There are two versions of MMCV:
mmcv: comprehensive, with full features and various CUDA ops out of box. It takes longer time to build.
mmcv-lite: lite, without CUDA ops but all other features, similar to mmcv<1.0.0. It is useful when you do not need those CUDA ops.
警告
Do not install both versions in the same environment, otherwise you may encounter errors like ModuleNotFound
. You need to uninstall one before installing the other. Installing the full version is highly recommended if CUDA is avaliable
.
Install mmcv¶
Before installing mmcv, make sure that PyTorch has been successfully installed following the PyTorch official installation guide. This can be verified using the following command
python -c 'import torch;print(torch.__version__)'
If version information is output, then PyTorch is installed.
Install with mim (recommended)¶
mim is the package management tool for the OpenMMLab projects, which makes it easy to install mmcv
pip install -U openmim
mim install mmcv
If you find that the above installation command does not use a pre-built package ending with .whl
but a source package ending with .tar.gz
, you may not have a pre-build package corresponding to the PyTorch or CUDA or mmcv version, in which case you can build mmcv from source.
Installation log using pre-built packages
Looking in links: https://download.openmmlab.com/mmcv/dist/cu102/torch1.8.0/index.html
Collecting mmcv
Downloading https://download.openmmlab.com/mmcv/dist/cu102/torch1.8.0/mmcv-2.0.0-cp38-cp38-manylinux1_x86_64.whl
Installation log using source packages
Looking in links: https://download.openmmlab.com/mmcv/dist/cu102/torch1.8.0/index.html
Collecting mmcv==2.0.0
Downloading mmcv-2.0.0.tar.gz
To install a specific version of mmcv, for example, mmcv version 2.0.0, you can use the following command
mim install mmcv==2.0.0
注解
If you would like to use opencv-python-headless
instead of opencv-python
,
e.g., in a minimum container environment or servers without GUI,
you can first install it before installing MMCV to skip the installation of opencv-python
.
Alternatively, if it takes too long to install a dependency library, you can specify the pypi source
mim install mmcv -i https://pypi.tuna.tsinghua.edu.cn/simple
You can run check_installation.py to check the installation of mmcv-full after running the installation commands.
Install with pip¶
Use the following command to check the version of CUDA and PyTorch
python -c 'import torch;print(torch.__version__);print(torch.version.cuda)'
Select the appropriate installation command depending on the type of system, CUDA version, PyTorch version, and MMCV version
If you do not find a corresponding version in the dropdown box above, you probably do not have a pre-built package corresponding to the PyTorch or CUDA or mmcv version, at which point you can build mmcv from source.
注解
mmcv is only compiled on PyTorch 1.x.0 because the compatibility usually holds between 1.x.0 and 1.x.1. If your PyTorch version is 1.x.1, you can install mmcv compiled with PyTorch 1.x.0 and it usually works well. For example, if your PyTorch version is 1.8.1, you can feel free to choose 1.8.x.
注解
If you would like to use opencv-python-headless
instead of opencv-python
,
e.g., in a minimum container environment or servers without GUI,
you can first install it before installing MMCV to skip the installation of opencv-python
.
Alternatively, if it takes too long to install a dependency library, you can specify the pypi source
mim install mmcv -i https://pypi.tuna.tsinghua.edu.cn/simple
You can run check_installation.py to check the installation of mmcv after running the installation commands.
Using mmcv with Docker¶
Build with local repository
git clone https://github.com/open-mmlab/mmcv.git && cd mmcv
docker build -t mmcv -f docker/release/Dockerfile .
Or build with remote repository
docker build -t mmcv https://github.com/open-mmlab/mmcv.git#main:docker/release
The Dockerfile installs latest released version of mmcv-full by default, but you can specify mmcv versions to install expected versions.
docker image build -t mmcv -f docker/release/Dockerfile --build-arg MMCV=2.0.0 .
If you also want to use other versions of PyTorch and CUDA, you can also pass them when building docker images.
An example to build an image with PyTorch 1.11 and CUDA 11.3.
docker build -t mmcv -f docker/release/Dockerfile \
--build-arg PYTORCH=1.11.0 \
--build-arg CUDA=11.3 \
--build-arg CUDNN=8 \
--build-arg MMCV=2.0.0 .
More available versions of PyTorch and CUDA can be found at dockerhub/pytorch.
Install mmcv-lite¶
If you need to use PyTorch-related modules, make sure PyTorch has been successfully installed in your environment by referring to the PyTorch official installation guide.
pip install mmcv-lite
Build MMCV from source¶
Build mmcv¶
Before installing mmcv, make sure that PyTorch has been successfully installed following the PyTorch official installation guide. This can be verified using the following command
python -c 'import torch;print(torch.__version__)'
If version information is output, then PyTorch is installed.
注解
If you would like to use opencv-python-headless
instead of opencv-python
,
e.g., in a minimum container environment or servers without GUI,
you can first install it before installing MMCV to skip the installation of opencv-python
.
Build on Linux¶
Clone the repo
git clone https://github.com/open-mmlab/mmcv.git cd mmcv
Install
ninja
andpsutil
to speed up the compilationpip install -r requirements/optional.txt
Check the nvcc version (requires 9.2+. Skip if no GPU available.)
nvcc --version
If the above command outputs the following message, it means that the nvcc setting is OK, otherwise you need to set CUDA_HOME.
nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2020 NVIDIA Corporation Built on Mon_Nov_30_19:08:53_PST_2020 Cuda compilation tools, release 11.2, V11.2.67 Build cuda_11.2.r11.2/compiler.29373293_0
注解
If you want to support ROCm, you can refer to AMD ROCm to install ROCm.
Check the gcc version (requires 5.4+)
gcc --version
Start building (takes 10+ min)
pip install -e . -v
Validate the installation
python .dev_scripts/check_installation.py
If no error is reported by the above command, the installation is successful. If there is an error reported, please check Frequently Asked Questions to see if there is already a solution.
If no solution is found, please feel free to open an issue.
Build on macOS¶
注解
If you are using a mac with apple silicon chip, install the PyTorch 1.13+, otherwise you will encounter the problem in issues#2218.
Clone the repo
git clone https://github.com/open-mmlab/mmcv.git cd mmcv
Install
ninja
andpsutil
to speed up the compilationpip install -r requirements/optional.txt
Start building
MMCV_WITH_OPS=1 pip install -e .
Validate the installation
python .dev_scripts/check_installation.py
If no error is reported by the above command, the installation is successful. If there is an error reported, please check Frequently Asked Questions to see if there is already a solution.
If no solution is found, please feel free to open an issue.
Build on Windows¶
Building MMCV on Windows is a bit more complicated than that on Linux. The following instructions show how to get this accomplished.
Prerequisite¶
The following software is required for building MMCV on windows. Install them first.
-
During installation, tick add git to Path.
-
A compiler for C++ and CUDA codes.
-
Official distributions of Python should work too.
-
Not required for building CPU version.
Customize the installation if necessary. As a recommendation, skip the driver installation if a newer version is already installed.
注解
You should know how to set up environment variables, especially Path
, on Windows. The following instruction relies heavily on this skill.
Common steps¶
Launch Anaconda prompt from Windows Start menu
Do not use raw
cmd.exe
s instruction is based on PowerShell syntax.Create a new conda environment
(base) PS C:\Users\xxx> conda create --name mmcv python=3.7 (base) PS C:\Users\xxx> conda activate mmcv # make sure to activate environment before any operation
Install PyTorch. Choose a version based on your need.
# CUDA version (mmcv) PS C:\Users\xxx> conda install pytorch torchvision cudatoolkit=10.2 -c pytorch # CPU version (mmcv) PS C:\Users\xxx> conda install install pytorch torchvision cpuonly -c pytorch
Clone the repo
(mmcv) PS C:\Users\xxx> git clone https://github.com/open-mmlab/mmcv.git (mmcv) PS C:\Users\xxx\mmcv> cd mmcv
Install
ninja
andpsutil
to speed up the compilation(mmcv) PS C:\Users\xxx\mmcv> pip install -r requirements/optional.txt
Set up MSVC compiler
Set Environment variable, add
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx86\x64
toPATH
, so thatcl.exe
will be available in prompt, as shown below.(mmcv) PS C:\Users\xxx\mmcv> cl Microsoft (R) C/C++ Optimizing Compiler Version 19.27.29111 for x64 Copyright (C) Microsoft Corporation. All rights reserved. usage: cl [ option... ] filename... [ / link linkoption... ]
For compatibility, we use the x86-hosted and x64-targeted compiler. note
Hostx86\x64
in the path.You may want to change the system language to English because pytorch will parse text output from
cl.exe
to check its version. However only utf-8 is recognized. Navigate to Control Panel -> Region -> Administrative -> Language for Non-Unicode programs and change it to English.
Build and install MMCV¶
mmcv can be built in two ways:
Full version (CPU ops)
Module
ops
will be compiled as a pytorch extension, but only x86 code will be compiled. The compiled ops can be executed on CPU only.Full version (CUDA ops)
Both x86 and CUDA codes of
ops
module will be compiled. The compiled version can be run on both CPU and CUDA-enabled GPU (if implemented).
CPU version¶
Build and install
(mmcv) PS C:\Users\xxx\mmcv> python setup.py build_ext
(mmcv) PS C:\Users\xxx\mmcv> python setup.py develop
GPU version¶
Make sure
CUDA_PATH
orCUDA_HOME
is already set inenvs
vials env:
, desired output is shown as below:(mmcv) PS C:\Users\xxx\mmcv> ls env: Name Value ---- ----- CUDA_PATH C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2 CUDA_PATH_V10_1 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1 CUDA_PATH_V10_2 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2
This should already be done by CUDA installer. If not, or you have multiple version of CUDA toolkit installed, set it with
(mmcv) PS C:\Users\xxx\mmcv> $env:CUDA_HOME = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2" # OR (mmcv) PS C:\Users\xxx\mmcv> $env:CUDA_HOME = $env:CUDA_PATH_V10_2 # if CUDA_PATH_V10_2 is in envs:
Set CUDA target arch
# Here you need to change to the target architecture corresponding to your GPU (mmcv) PS C:\Users\xxx\mmcv> $env:TORCH_CUDA_ARCH_LIST="7.5"
注解
Check your the compute capability of your GPU from here.
(mmcv) PS C:\Users\xxx\mmcv> &"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\extras\demo_suite\deviceQuery.exe" Device 0: "NVIDIA GeForce GTX 1660 SUPER" CUDA Driver Version / Runtime Version 11.7 / 11.1 CUDA Capability Major/Minor version number: 7.5
The 7.5 above indicates the target architecture. Note: You need to replace v10.2 with your CUDA version in the above command.
Build and install
# build python setup.py build_ext # if success, cl will be launched to compile ops # install python setup.py develop
注解
If you are compiling against PyTorch 1.6.0, you might meet some errors from PyTorch as described in this issue. Follow this pull request to modify the source code in your local PyTorch installation.
Validate installation¶
(mmcv) PS C:\Users\xxx\mmcv> python .dev_scripts/check_installation.py
If no error is reported by the above command, the installation is successful. If there is an error reported, please check Frequently Asked Questions to see if there is already a solution. If no solution is found, please feel free to open an issue.
Build mmcv-lite¶
If you need to use PyTorch-related modules, make sure PyTorch has been successfully installed in your environment by referring to the PyTorch official installation guide.
Clone the repo
git clone https://github.com/open-mmlab/mmcv.git cd mmcv
Start building
MMCV_WITH_OPS=0 pip install -e . -v
Validate installation
python -c 'import mmcv;print(mmcv.__version__)'
Build mmcv-full on Cambricon MLU Devices¶
Install torch_mlu¶
Option1: Install mmcv-full based on Cambricon docker image¶
Firstly, install and pull Cambricon docker image (please email service@cambricon.com for the latest release docker):
docker pull ${docker image}
Run and attach to the docker, Install mmcv-full on MLU device and make sure you’ve installed mmcv-full on MLU device successfully
Option2: Install mmcv-full from compiling Cambricon PyTorch source code¶
Please email service@cambricon.com or contact with Cambricon engineers for a suitable version of CATCH package. After you get the suitable version of CATCH package, please follow the steps in ${CATCH-path}/CONTRIBUTING.md to install Cambricon PyTorch.
Install mmcv-full on Cambricon MLU device¶
Clone the repo
git clone https://github.com/open-mmlab/mmcv.git
The mlu-ops library will be downloaded to the default directory (mmcv/mlu-ops) while building MMCV. You can also set MMCV_MLU_OPS_PATH
to an existing mlu-ops library before building as follows:
export MMCV_MLU_OPS_PATH=/xxx/xxx/mlu-ops
Install mmcv-full
cd mmcv
export MMCV_WITH_OPS=1
export FORCE_MLU=1
python setup.py install
Test Code¶
After finishing previous steps, you can run the following python code to make sure that you’ve installed mmcv-full on MLU device successfully
import torch
import torch_mlu
from mmcv.ops import sigmoid_focal_loss
x = torch.randn(3, 10).mlu()
x.requires_grad = True
y = torch.tensor([1, 5, 3]).mlu()
w = torch.ones(10).float().mlu()
output = sigmoid_focal_loss(x, y, 2.0, 0.25, w, 'none')
print(output)
API reference table¶
Due to the removal of the mmcv.fileio
, mmcv.runner
, mmcv.parallel
, mmcv.engine
, mmcv.device
modules, and all classes and most of the functions in the mmcv.utils
module during the upgrade from MMCV v1.x to MMCV v2.x, which were removed at PR #2179, PR #2216, PR #2217. Therefore, we provide the following API reference table to make it easier to quickly find the migrated interfaces.
mmcv.fileio
¶
MMCV | MMCV URL | MMEngine | MMEngine URL |
---|---|---|---|
mmcv.fileio.file_client.BaseStorageBackend | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/file_client.py | mmengine.fileio.backends.base.BaseStorageBackend | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/backends/base.py |
mmcv.fileio.file_client.CephBackend | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/file_client.py | ||
mmcv.fileio.file_client.PetrelBackend | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/file_client.py | mmengine.fileio.backends.petrel_backend.PetrelBackend | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/backends/petrel_backend.py |
mmcv.fileio.file_client.MemcachedBackend | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/file_client.py | mmengine.fileio.backends.memcached_backend.MemcachedBackend | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/backends/memcached_backend.py |
mmcv.fileio.file_client.LmdbBackend | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/file_client.py | mmengine.fileio.backends.lmdb_backend.LmdbBackend | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/backends/lmdb_backend.py |
mmcv.fileio.file_client.HardDiskBackend | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/file_client.py | mmengine.fileio.file_client.HardDiskBackend | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/file_client.py |
mmcv.fileio.file_client.HTTPBackend | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/file_client.py | mmengine.fileio.backends.http_backend.HTTPBackend | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/backends/http_backend.py |
mmcv.fileio.file_client.FileClient | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/file_client.py | mmengine.fileio.file_client.FileClient | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/file_client.py |
mmcv.fileio.io.load | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/io.py | mmengine.fileio.io.load | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/io.py |
mmcv.fileio.io.dump | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/io.py | mmengine.fileio.io.dump | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/io.py |
mmcv.fileio.io._register_handler | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/io.py | mmengine.fileio.handlers._register_handler | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/handlers/registry_utils.py |
mmcv.fileio.io.register_handler | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/io.py | mmengine.fileio.handlers.register_handler | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/handlers/registry_utils.py |
mmcv.fileio.parse.list_from_file | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/parse.py | mmengine.fileio.parse.list_from_file | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/parse.py |
mmcv.fileio.parse.dict_from_file | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/parse.py | mmengine.fileio.parse.dict_from_file | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/parse.py |
mmcv.fileio.handlers.base.BaseFileHandler | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/handlers/base.py | mmengine.fileio.handlers.base.BaseFileHandler | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/handlers/base.py |
mmcv.fileio.handlers.json_handler.set_default | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/handlers/json_handler.py | mmengine.fileio.handlers.json_handler.set_default | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/handlers/json_handler.py |
mmcv.fileio.handlers.json_handler.JsonHandler | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/handlers/json_handler.py | mmengine.fileio.handlers.json_handler.JsonHandler | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/handlers/json_handler.py |
mmcv.fileio.handlers.pickle_handler.PickleHandler | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/handlers/pickle_handler.py | mmengine.fileio.handlers.pickle_handler.PickleHandler | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/handlers/pickle_handler.py |
mmcv.fileio.handlers.yaml_handler.YamlHandler | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/fileio/handlers/yaml_handler.py | mmengine.fileio.handlers.yaml_handler.YamlHandler | https://github.com/open-mmlab/mmengine/blob/main/mmengine/fileio/handlers/yaml_handler.py |
mmcv.runner
¶
MMCV | MMCV URL | MMEngine | MMEngine URL |
---|---|---|---|
mmcv.runner.hooks.logger.base.LoggerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/logger/base.py | mmengine.hooks.logger_hook.LoggerHook | https://github.com/open-mmlab/mmengine/blob/main/mmengine/hooks/logger_hook.py |
mmcv.runner.hooks.logger.clearml.ClearMLLoggerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/logger/clearml.py | Similar: mmengine.visualization.vis_backend.ClearMLVisBackend | https://github.com/open-mmlab/mmengine/blob/main/mmengine/visualization/vis_backend.py |
mmcv.runner.hooks.logger.dvclive.DvcliveLoggerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/logger/dvclive.py | Similar: mmengine.visualization.vis_backend.DVCLiveVisBackend | https://github.com/open-mmlab/mmengine/blob/main/mmengine/visualization/vis_backend.py |
mmcv.runner.hooks.logger.mlflow.MlflowLoggerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/logger/mlflow.py | Similar: mmengine.visualization.vis_backend.MLflowVisBackend | https://github.com/open-mmlab/mmengine/blob/main/mmengine/visualization/vis_backend.py |
mmcv.runner.hooks.logger.neptune.NeptuneLoggerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/logger/neptune.py | Similar: mmengine.visualization.vis_backend.NeptuneVisBackend | https://github.com/open-mmlab/mmengine/blob/main/mmengine/visualization/vis_backend.py |
mmcv.runner.hooks.logger.pavi.PaviLoggerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/logger/pavi.py | ||
mmcv.runner.hooks.logger.segmind.SegmindLoggerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/logger/segmind.py | ||
mmcv.runner.hooks.logger.tensorboard.TensorboardLoggerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/logger/tensorboard.py | Similar: mmengine.visualization.vis_backend.TensorboardVisBackend | https://github.com/open-mmlab/mmengine/blob/main/mmengine/visualization/vis_backend.py |
mmcv.runner.hooks.logger.text.TextLoggerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/logger/text.py | ||
mmcv.runner.hooks.logger.wandb.WandbLoggerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/logger/wandb.py | Similar: mmengine.visualization.vis_backend.WandbVisBackend | https://github.com/open-mmlab/mmengine/blob/main/mmengine/visualization/vis_backend.py |
mmcv.runner.hooks.checkpoint.CheckpointHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/checkpoint.py | mmengine.hooks.checkpoint_hook.CheckpointHook | https://github.com/open-mmlab/mmengine/blob/main/mmengine/hooks/checkpoint_hook.py |
mmcv.runner.hooks.closure.ClosureHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/closure.py | ||
mmcv.runner.hooks.ema.EMAHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/ema.py | mmengine.hooks.ema_hook.EMAHook | https://github.com/open-mmlab/mmengine/blob/main/mmengine/hooks/ema_hook.py |
mmcv.runner.hooks.evaluation.EvalHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/evaluation.py | Some features have been moved to: mmengine.hooks.checkpoint_hook.CheckpointHook | https://github.com/open-mmlab/mmengine/blob/main/mmengine/hooks/checkpoint_hook.py |
mmcv.runner.hooks.evaluation.DistEvalHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/evaluation.py | Some features have been moved to: mmengine.hooks.checkpoint_hook.CheckpointHook | https://github.com/open-mmlab/mmengine/blob/main/mmengine/hooks/checkpoint_hook.py |
mmcv.runner.hooks.hook.HOOKS | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/hook.py | mmengine.registry.root.HOOKS | https://github.com/open-mmlab/mmengine/blob/main/mmengine/registry/root.py |
mmcv.runner.hooks.hook.Hook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/hook.py | mmengine.hooks.hook.Hook | https://github.com/open-mmlab/mmengine/blob/main/mmengine/hooks/hook.py |
mmcv.runner.hooks.iter_timer.IterTimerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/iter_timer.py | mmengine.hooks.iter_timer_hook.IterTimerHook | https://github.com/open-mmlab/mmengine/blob/main/mmengine/hooks/iter_timer_hook.py |
mmcv.runner.hooks.lr_updater.LrUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | mmengine.optim.scheduler.lr_scheduler.LRSchedulerMixin | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/lr_scheduler.py |
mmcv.runner.hooks.lr_updater.FixedLrUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | mmengine.optim.scheduler.lr_scheduler.ConstantLR | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/lr_scheduler.py |
mmcv.runner.hooks.lr_updater.StepLrUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | mmengine.optim.scheduler.lr_scheduler.StepLR | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/lr_scheduler.py |
mmcv.runner.hooks.lr_updater.ExpLrUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | mmengine.optim.scheduler.lr_scheduler.ExponentialLR | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/lr_scheduler.py |
mmcv.runner.hooks.lr_updater.PolyLrUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | mmengine.optim.scheduler.lr_scheduler.PolyLR | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/lr_scheduler.py |
mmcv.runner.hooks.lr_updater.InvLrUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | ||
mmcv.runner.hooks.lr_updater.CosineAnnealingUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | mmengine.optim.scheduler.lr_scheduler.CosineAnnealingLR | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/lr_scheduler.py |
mmcv.runner.hooks.lr_updater.FlatCosineAnnealingUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | ||
mmcv.runner.hooks.lr_updater.CosineRestartLrUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | mmengine.optim.scheduler.lr_scheduler.CosineRestartLR | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/lr_scheduler.py |
mmcv.runner.hooks.lr_updater.get_position_from_periods | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | mmengine.optim.scheduler.lr_scheduler.CosineRestartLR.get_position_from_periods | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/lr_scheduler.py |
mmcv.runner.hooks.lr_updater.CyclicLrUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | ||
mmcv.runner.hooks.lr_updater.OneCycleLrUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | mmengine.optim.scheduler.lr_scheduler.OneCycleLR | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/lr_scheduler.py |
mmcv.runner.hooks.lr_updater.LinearAnnealingLrUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | ||
mmcv.runner.hooks.lr_updater.annealing_cos | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | mmengine.optim.scheduler.lr_scheduler.OneCycleLR._annealing_cos | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/lr_scheduler.py |
mmcv.runner.hooks.lr_updater.annealing_linear | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | mmengine.optim.scheduler.lr_scheduler.OneCycleLR._annealing_linear | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/lr_scheduler.py |
mmcv.runner.hooks.lr_updater.format_param | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/lr_updater.py | mmengine.optim.scheduler.lr_scheduler.OneCycleLR._format_param | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/lr_scheduler.py |
mmcv.runner.hooks.memory.EmptyCacheHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/memory.py | mmengine.hoos.empty_cache_hook.EmptyCacheHook | https://github.com/open-mmlab/mmengine/blob/main/mmengine/hooks/empty_cache_hook.py |
mmcv.runner.hooks.momentum_updater.MomentumUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/momentum_updater.py | mmengine.optim.scheduler.momentum_scheduler.MomentumSchedulerMixin | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/momentum_scheduler.py |
mmcv.runner.hooks.momentum_updater.StepMomentumUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/momentum_updater.py | mmengine.optim.scheduler.momentum_scheduler.StepMomentum | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/momentum_scheduler.py |
mmcv.runner.hooks.momentum_updater.CosineAnnealingMomentumUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/momentum_updater.py | mmengine.optim.scheduler.momentum_scheduler.CosineAnnealingMomentum | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/scheduler/momentum_scheduler.py |
mmcv.runner.hooks.momentum_updater.LinearAnnealingMomentumUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/momentum_updater.py | ||
mmcv.runner.hooks.momentum_updater.CyclikcMomentumUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/momentum_updater.py | ||
mmcv.runner.hooks.momentum_updater.OneCycleMomentumUpdaterHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/momentum_updater.py | ||
mmcv.runner.hooks.optimizer.OptimizerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/optimizer.py | mmengine.optimizer.optimizer_wrapper.OptimWrapper | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/optimizer_wrapper.py |
mmcv.runner.hooks.optimizer.GradientCumulativeOptimizerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/optimizer.py | ||
mmcv.runner.hooks.optimizer.Fp16OptimizerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/optimizer.py | Moved to: mmengine.optimizer.amp_optimizer_wrapper.AmpOptimWrapper and mmengine.optimizer.apex_optimizer_wrapper.ApexOptimWrapper | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/amp_optimizer_wrapper.py https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/apex_optimizer_wrapper.py |
mmcv.runner.hooks.optimizer.GradientCumulativeFp16OptimizerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/optimizer.py | ||
mmcv.runner.hooks.optimizer.Fp16OptimizerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/optimizer.py | Moved to: mmengine.optimizer.amp_optimizer_wrapper.AmpOptimWrapper and mmengine.optimizer.apex_optimizer_wrapper.ApexOptimWrapper | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/amp_optimizer_wrapper.py https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/apex_optimizer_wrapper.py |
mmcv.runner.hooks.optimizer.GradientCumulativeFp16OptimizerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/optimizer.py | ||
mmcv.runner.hooks.profiler.ProfilerHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/profiler.py | mmengine.hooks.profiler_hook.ProfilerHook | https://github.com/open-mmlab/mmengine/blob/main/mmengine/hooks/profiler_hook.py |
mmcv.runner.hooks.sampler_seed.DistSamplerSeedHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/sampler_seed.py | mmengine.hooks.sampler_seed_hook.DistSamplerSeedHook | https://github.com/open-mmlab/mmengine/blob/main/mmengine/hooks/sampler_seed_hook.py |
mmcv.runner.hooks.sync_buffer.SyncbuffersHook | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/hooks/sync_buffer.py | mmengine.hooks.sync_buffer_hook.SyncBufferHook | https://github.com/open-mmlab/mmengine/blob/main/mmengine/hooks/sync_buffer_hook.py |
mmcv.runner.optimizer.builder.OPTIMIZERS | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/optimizer/builder.py | mmengine.registry.root.OPTIMIZERS | https://github.com/open-mmlab/mmengine/blob/main/mmengine/registry/root.py |
mmcv.runner.optimizer.builder.OPTIMIZER_BUILDERS | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/optimizer/builder.py | ||
mmcv.runner.optimizer.builder.register_torch_optimizers | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/optimizer/builder.py | mmengine.optim.optimizer.builder.register_torch_optimizers | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/builder.py |
mmcv.runner.optimizer.builder.TORCH_OPTIMIZERS | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/optimizer/builder.py | ||
mmcv.runner.optimizer.builder.build_optimizer_constructor | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/optimizer/builder.py | ||
mmcv.runner.optimizer.builder.build_optimizer | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/optimizer/builder.py | ||
mmcv.runner.optimizer.default_constructor.DefaultOptimizerConstructor | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/optimizer/default_constructor.py | ||
mmcv.runner.base_module.BaseModule | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/base_module.py | mmengine.model.base_module.BaseModule | https://github.com/open-mmlab/mmengine/blob/main/mmengine/model/base_module.py |
mmcv.runner.base_module.Sequential | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/base_module.py | mmengine.model.base_module.Sequential | https://github.com/open-mmlab/mmengine/blob/main/mmengine/model/base_module.py |
mmcv.runner.base_module.ModuleList | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/base_module.py | mmengine.model.base_module.ModuleList | https://github.com/open-mmlab/mmengine/blob/main/mmengine/model/base_module.py |
mmcv.runner.base_module.ModuleDict | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/base_module.py | mmengine.model.base_module.ModuleDict | https://github.com/open-mmlab/mmengine/blob/main/mmengine/model/base_module.py |
mmcv.runner.base_runner.BaseRunner | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/base_runner.py | mmengine.runner.runner.Runner | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/runner.py |
mmcv.runner.builder.RUNNERS | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/builder.py | mmengine.registry.root.RUNNERS | https://github.com/open-mmlab/mmengine/blob/main/mmengine/registry/root.py |
mmcv.runner.builder.RUNNER_BUILDERS | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/builder.py | mmengine.registry.root.RUNNER_CONSTRUCTORS | https://github.com/open-mmlab/mmengine/blob/main/mmengine/registry/root.py |
mmcv.runner.builder.build_runner_constructor | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/builder.py | ||
mmcv.runner.builder.build_runner | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/builder.py | ||
mmcv.runner.checkpoint.ENV_MMCV_HOME | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.ENV_MMENGINE_HOME | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.ENV_XDG_CACHE_HOME | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.ENV_XDG_CACHE_HOME | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.DEFAULT_CACHE_HOME | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.DEFAULT_CACHE_DIR | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint._get_mmcv_home | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint._get_mmengine_home | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.load_state_dict | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.load_state_dict | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.get_torchvision_models | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.get_torchvision_models | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.get_external_models | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.get_external_models | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.get_mmcls_models | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.get_mmcls_models | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.get_deprecated_model_names | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.get_deprecated_model_names | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint._process_mmcls_checkpoint | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint._process_mmcls_checkpoint | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.CheckpointLoader | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.CheckpointLoader | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.load_from_local | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.load_from_local | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.load_from_http | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.load_from_http | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.load_from_pavi | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.load_from_pavi | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.load_from_ceph | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.load_from_ceph | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.load_from_torchvision | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.load_from_torchvision | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.load_from_openmmlab | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.load_from_openmmlab | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.load_from_mmcls | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.load_from_mmcls | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint._load_checkpoint | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint._load_checkpoint | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint._load_checkpoint_with_prefix | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint._load_checkpoint_with_prefix | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.load_checkpoint | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.load_checkpoint | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.weights_to_cpu | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.weights_to_cpu | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint._save_to_state_dict | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint._save_to_state_dict | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.get_state_dict | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.get_state_dict | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.checkpoint.save_checkpoint | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/checkpoint.py | mmengine.runner.checkpoint.save_checkpoint | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/checkpoint.py |
mmcv.runner.default_coonstructor.DefaultRunnerConstructor | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/default_constructor.py | ||
mmcv.runner.dist_utils._find_free_port | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/dist_utils.py | ||
mmcv.runner.dist_utils._is_free_port | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/dist_utils.py | ||
mmcv.runner.dist_utils.init_dist | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/dist_utils.py | mmengine.dist.utils.init_dist | https://github.com/open-mmlab/mmengine/blob/main/mmengine/dist/utils.py |
mmcv.runner.dist_utils._init_dist_pytorch | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/dist_utils.py | mmengine.dist.utils._init_dist_pytorch | https://github.com/open-mmlab/mmengine/blob/main/mmengine/dist/utils.py |
mmcv.runner.dist_utils._init_dist_mpi | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/dist_utils.py | mmengine.dist.utils._init_dist_mpi | https://github.com/open-mmlab/mmengine/blob/main/mmengine/dist/utils.py |
mmcv.runner.dist_utils._init_dist_slurm | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/dist_utils.py | mmengine.dist.utils._init_dist_slurm | https://github.com/open-mmlab/mmengine/blob/main/mmengine/dist/utils.py |
mmcv.runner.dist_utils.get_dist_info | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/dist_utils.py | mmengine.dist.utils.get_dist_info | https://github.com/open-mmlab/mmengine/blob/main/mmengine/dist/utils.py |
mmcv.runner.dist_utils.master_only | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/dist_utils.py | mmengine.dist.utils.master_only | https://github.com/open-mmlab/mmengine/blob/main/mmengine/dist/utils.py |
mmcv.runner.dist_utils.allreduce_params | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/dist_utils.py | ||
mmcv.runner.dist_utils.allreduce_grads | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/dist_utils.py | ||
mmcv.runner.dist_utils._allreduce_coalesced | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/dist_utils.py | ||
mmcv.runner.epoch_based_runner.EpochBasedRunner | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/epoch_based_runner.py | mmengine.runner.loops.EpochBasedTrainLoop | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/loops.py |
mmcv.runner.epoch_based_runner.Runner | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/epoch_based_runner.py | ||
mmcv.runner.fp16_utils.cast_tensor_type | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/fp16_utils.py | Moved fp16-related to: mmengine.optimizer.amp_optimizer_wrapper.AmpOptimWrapper and mmengine.optimizer.apex_optimizer_wrapper.ApexOptimWrapper | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/amp_optimizer_wrapper.py https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/apex_optimizer_wrapper.py |
mmcv.runner.fp16_utils.auto_fp16 | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/fp16_utils.py | Moved fp16-related to: mmengine.optimizer.amp_optimizer_wrapper.AmpOptimWrapper and mmengine.optimizer.apex_optimizer_wrapper.ApexOptimWrapper | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/amp_optimizer_wrapper.py https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/apex_optimizer_wrapper.py |
mmcv.runner.fp16_utils.force_fp32 | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/fp16_utils.py | Moved fp16-related to: mmengine.optimizer.amp_optimizer_wrapper.AmpOptimWrapper and mmengine.optimizer.apex_optimizer_wrapper.ApexOptimWrapper | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/amp_optimizer_wrapper.py https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/apex_optimizer_wrapper.py |
mmcv.runner.fp16_utils.allreduce_grads | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/fp16_utils.py | Moved fp16-related to: mmengine.optimizer.amp_optimizer_wrapper.AmpOptimWrapper and mmengine.optimizer.apex_optimizer_wrapper.ApexOptimWrapper | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/amp_optimizer_wrapper.py https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/apex_optimizer_wrapper.py |
mmcv.runner.fp16_utils.wrap_fp16_model | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/fp16_utils.py | Moved fp16-related to: mmengine.optimizer.amp_optimizer_wrapper.AmpOptimWrapper and mmengine.optimizer.apex_optimizer_wrapper.ApexOptimWrapper | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/amp_optimizer_wrapper.py https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/apex_optimizer_wrapper.py |
mmcv.runner.fp16_utils.patch_norm_fp32 | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/fp16_utils.py | Moved fp16-related to: mmengine.optimizer.amp_optimizer_wrapper.AmpOptimWrapper and mmengine.optimizer.apex_optimizer_wrapper.ApexOptimWrapper | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/amp_optimizer_wrapper.py https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/apex_optimizer_wrapper.py |
mmcv.runner.fp16_utils.patch_forward_method | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/fp16_utils.py | Moved fp16-related to: mmengine.optimizer.amp_optimizer_wrapper.AmpOptimWrapper and mmengine.optimizer.apex_optimizer_wrapper.ApexOptimWrapper | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/amp_optimizer_wrapper.py https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/apex_optimizer_wrapper.py |
mmcv.runner.fp16_utils.LossScaler | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/fp16_utils.py | Moved fp16-related to: mmengine.optimizer.amp_optimizer_wrapper.AmpOptimWrapper and mmengine.optimizer.apex_optimizer_wrapper.ApexOptimWrapper | https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/amp_optimizer_wrapper.py https://github.com/open-mmlab/mmengine/blob/main/mmengine/optim/optimizer/apex_optimizer_wrapper.py |
mmcv.runner.iter_based_runner.IterLoader | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/iter_based_runner.py | ||
mmcv.runner.iter_based_runner.IterBasedRunner | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/iter_based_runner.py | mmengine.runner.loops.IterBasedTrainLoop | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/loops.py |
mmcv.runner.log_buffer.LogBuffer | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/log_buffer.py | ||
mmcv.runner.priority.Priority | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/priority.py | mmengine.runer.priority.Priority | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/priority.py |
mmcv.runner.priority.get_priority | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/priority.py | mmengine.runner.priority.get_priority | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/priority.py |
mmcv.runner.utils.get_host_info | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/utils.py | ||
mmcv.runner.utils.get_time_str | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/utils.py | ||
mmcv.runner.utils.obj_from_dict | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/utils.py | ||
mmcv.runner.utils.set_random_seed | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/runner/utils.py | mmengine.runner.utils.set_random_seed | https://github.com/open-mmlab/mmengine/blob/main/mmengine/runner/utils.py |
mmcv.parallel
¶
MMCV | MMCV URL | MMEngine | MMEngine URL |
---|---|---|---|
mmcv.parallel._functions.scatter | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/_functions.py | ||
mmcv.parallel._functions.synchronize_stream | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/_functions.py | ||
mmcv.parallel._functions.get_input_device | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/_functions.py | ||
mmcv.parallel._functions.Scatter | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/_functions.py | ||
mmcv.parallel.collate.collate | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/collate.py | ||
mmcv.parallel.data_container.assert_tensor_type | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/data_container.py | ||
mmcv.parallel.data_container.DataContainer | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/data_container.py | Similar: mmengine/structures/base_data_element.BaseDataElement | https://github.com/open-mmlab/mmengine/blob/main/mmengine/structures/base_data_element.py |
mmcv.parallel.data_parallel.MMDataParallel | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/data_parallel.py | ||
mmcv.parallel.distributed.MMDistributedDataParallel | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/distributed.py | mmengine.model.wrappers.distributed.MMDistributedDataParallel | https://github.com/open-mmlab/mmengine/blob/main/mmengine/model/wrappers/distributed.py |
mmcv.parallel.distributed_deprecated.MMDistributedDataParallel | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/distributed.py | mmengine.model.wrappers.distributed.MMDistributedDataParallel | https://github.com/open-mmlab/mmengine/blob/main/mmengine/model/wrappers/distributed.py |
mmcv.parallel.registry.MODULE_WRAPPERS | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/registry.py | mmengine.registry.root.MODEL_WRAPPERS | https://github.com/open-mmlab/mmengine/blob/main/mmengine/registry/root.py |
mmcv.parallel.scatter_gather.scatter | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/scatter_gather.py | ||
mmcv.parallel.scatter_gather.scatter_kwargs | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/scatter_gather.py | ||
mmcv.parallel.utils.is_module_wrapper | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/parallel/utils.py | mmengine.model.wrappers.utils.is_model_wrapper | https://github.com/open-mmlab/mmengine/blob/main/mmengine/model/wrappers/utils.py |
mmcv.engine
¶
MMCV | MMCV URL | MMEngine | MMEngine URL |
---|---|---|---|
mmcv.engine.test.single_gpu_test | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/engine/test.py | ||
mmcv.engine.test.multi_gpu_test | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/engine/test.py | ||
mmcv.engine.test.collect_results_cpu | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/engine/test.py | ||
mmcv.engine.test.collect_results_gpu | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/engine/test.py |
mmcv.device
¶
MMCV | MMCV URL | MMEngine | MMEngine URL |
---|---|---|---|
mmcv.device.ipu | https://github.com/open-mmlab/mmcv/tree/v1.7.1/mmcv/device/ipu | ||
mmcv.device.mlu | https://github.com/open-mmlab/mmcv/tree/v1.7.1/mmcv/device/mlu | ||
mmcv.device.mps | https://github.com/open-mmlab/mmcv/tree/v1.7.1/mmcv/device/mps | ||
mmcv.device.npu | https://github.com/open-mmlab/mmcv/tree/v1.7.1/mmcv/device/npu | ||
mmcv.device._functions.scatter | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/device/_functions.py | ||
mmcv.device._functions.Scatter | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/device/_functions.py | ||
mmcv.device.scatter_gather.scatter | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/device/scatter_gather.py | ||
mmcv.device.scatter_gather.scatter_kwargs | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/device/scatter_gather.py | ||
mmcv.device.utils.get_device | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/device/utils.py | mmengine.device.utils.get_device | https://github.com/open-mmlab/mmengine/blob/main/mmengine/device/utils.py |
mmcv.utils
¶
MMCV | MMCV URL | MMEngine | MMEngine URL |
---|---|---|---|
mmcv.utils.config.BASE_KEY | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/config.py | mmengine.config.config.BASE_KEY | https://github.com/open-mmlab/mmengine/blob/main/mmengine/config/config.py |
mmcv.utils.config.DELETE_KEY | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/config.py | mmengine.config.config.DELETE_KEY | https://github.com/open-mmlab/mmengine/blob/main/mmengine/config/config.py |
mmcv.utils.config.DEPRECATION_KEY | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/config.py | mmengine.config.config.DEPRECATION_KEY | https://github.com/open-mmlab/mmengine/blob/main/mmengine/config/config.py |
mmcv.utils.config.ConfigDict | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/config.py | mmengine.config.config.ConfigDict | https://github.com/open-mmlab/mmengine/blob/main/mmengine/config/config.py |
mmcv.utils.config.add_args | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/config.py | mmengine.config.config.add_args | https://github.com/open-mmlab/mmengine/blob/main/mmengine/config/config.py |
mmcv.utils.config.Config | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/config.py | mmengine.config.config.Config | https://github.com/open-mmlab/mmengine/blob/main/mmengine/config/config.py |
mmcv.utils.config.DictAction | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/config.py | mmengine.config.config.DictAction | https://github.com/open-mmlab/mmengine/blob/main/mmengine/config/config.py |
mmcv.utils.device_type.is_ipu_available | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/device_type.py | ||
mmcv.utils.device_type.IS_IPU_AVAILABLE | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/device_type.py | ||
mmcv.utils.device_type.is_mlu_available | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/device_type.py | mmengine.device.utils.is_mlu_available | https://github.com/open-mmlab/mmengine/blob/main/mmengine/device/utils.py |
mmcv.utils.device_type.is_mps_available | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/device_type.py | mmengine.device.utils.is_mps_available | https://github.com/open-mmlab/mmengine/blob/main/mmengine/device/utils.py |
mmcv.utils.device_type.is_npu_available | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/device_type.py | mmengine.device.utils.is_npu_available | https://github.com/open-mmlab/mmengine/blob/main/mmengine/device/utils.py |
mmcv.utils.hub._is_legacy_zip_format | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/hub.py | mmengine.utils.dl_utils.hub._is_legacy_zip_format | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/hub.py |
mmcv.utils.hub._legacy_zip_load | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/hub.py | mmengine.utils.dl_utils.hub._legacy_zip_load | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/hub.py |
mmcv.utils.hub.load_url | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/hub.py | mmengine.utils.dl_utils.hub.load_url | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/hub.py |
mmcv.utils.logging.logger_initialized | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/logging.py | ||
mmcv.utils.logging.get_logger | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/logging.py | ||
mmcv.utils.logging.print_log | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/logging.py | ||
mmcv.utils.misc._ntuple | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc._ntuple | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.to_1tuple | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.to_1tuple | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.to_2tuple | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.to_2tuple | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.to_3tuple | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.to_3tuple | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.to_4tuple | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.to_4tuple | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.to_ntuple | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.to_ntuple | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.is_str | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.is_str | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.import_modules_from_strings | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.import_modules_from_strings | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.iter_cast | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.iter_cast | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.list_cast | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.list_cast | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.tuple_cast | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.tuple_cast | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.is_seq_of | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.is_seq_of | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.is_list_of | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.is_list_of | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.is_tuple_of | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.is_tuple_of | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.slice_list | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.slice_list | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.concat_list | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.concat_list | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.check_prerequisites | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.check_prerequisites | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc._check_py_package | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc._check_py_package | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc._check_executable | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc._check_executable | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.requires_package | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.requires_package | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.requires_executable | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.requires_executable | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.deprecated_api_warning | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.deprecated_api_warning | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.is_method_overridden | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.is_method_overridden | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.misc.has_method | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/misc.py | mmengine.utils.misc.has_method | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/misc.py |
mmcv.utils.parrots_wrapper.TORCH_VERSION | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/parrots_wrapper.py | mmengine.utils.dl_utils.parrots_wrapper.TORCH_VERSION | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/parrots_wrapper.py |
mmcv.utils.parrots_wrapper.is_cuda_available | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/parrots_wrapper.py | mmengine.devices.utils.is_cuda_available | https://github.com/open-mmlab/mmengine/blob/main/mmengine/device/utils.py |
mmcv.utils.parrots_wrapper.IS_CUDA_AVAILABLE | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/parrots_wrapper.py | ||
mmcv.utils.parrots_wrapper.is_rocm_pytorch | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/parrots_wrapper.py | mmengine.utils.dl_utils.parrots_wrapper.is_rocm_pytorch | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/parrots_wrapper.py |
mmcv.utils.parrots_wrapper._get_cuda_home | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/parrots_wrapper.py | mmengine.utils.dl_utils.parrots_wrapper._get_cuda_home | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/parrots_wrapper.py |
mmcv.utils.parrots_wrapper.get_build_config | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/parrots_wrapper.py | mmengine.utils.dl_utils.parrots_wrapper.get_build_config | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/parrots_wrapper.py |
mmcv.utils.parrots_wrapper._get_conv | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/parrots_wrapper.py | mmengine.utils.dl_utils.parrots_wrapper._get_conv | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/parrots_wrapper.py |
mmcv.utils.parrots_wrapper._get_dataloader | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/parrots_wrapper.py | mmengine.utils.dl_utils.parrots_wrapper._get_dataloader | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/parrots_wrapper.py |
mmcv.utils.parrots_wrapper._get_extension | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/parrots_wrapper.py | mmengine.utils.dl_utils.parrots_wrapper._get_extension | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/parrots_wrapper.py |
mmcv.utils.parrots_wrapper._get_pool | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/parrots_wrapper.py | mmengine.utils.dl_utils.parrots_wrapper._get_pool | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/parrots_wrapper.py |
mmcv.utils.parrots_wrapper._get_norm | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/parrots_wrapper.py | mmengine.utils.dl_utils.parrots_wrapper._get_norm | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/parrots_wrapper.py |
mmcv.utils.parrots_wrapper.SyncBatchNorm | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/parrots_wrapper.py | mmengine.utils.dl_utils.parrots_wrapper.SyncBatchNorm | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/parrots_wrapper.py |
mmcv.utils.path.is_filepath | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/path.py | mmengine.utils.path.is_filepath | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/path.py |
mmcv.utils.path.fopen | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/path.py | mmengine.utils.path.fopen | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/path.py |
mmcv.utils.path.check_file_exist | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/path.py | mmengine.path.check_file_exist | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/path.py |
mmcv.utils.path.mkdir_or_exist | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/path.py | mmengine.utils.path.mkdir_or_exist | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/path.py |
mmcv.utils.path.symlink | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/path.py | mmengine.utils.path.symlink | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/path.py |
mmcv.utils.path.scandir | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/path.py | mmengine.utils.path.scandir | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/path.py |
mmcv.utils.path.find_vcs_root | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/path.py | mmengine.utils.path.find_vcs_root | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/path.py |
mmcv.utils.progressbar.ProgressBar | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/progressbar.py | mmengine.utils.progressbar.ProgressBar | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/progressbar.py |
mmcv.utils.progressbar.track_progress | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/progressbar.py | mmengine.utils.progressbar.track_progress | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/progressbar.py |
mmcv.utils.progressbar.init_pool | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/progressbar.py | mmengine.utils.progressbar.init_pool | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/progressbar.py |
mmcv.utils.progressbar.track_parallel_progress | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/progressbar.py | mmengine.utils.progressbar.track_parallel_progress | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/progressbar.py |
mmcv.utils.progressbar.track_iter_progress | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/progressbar.py | mmengine.utils.progressbar.track_iter_progress | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/progressbar.py |
mmcv.utils.registry.build_from_cfg | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/registry.py | mmengine.registry.build_functions.build_from_cfg | https://github.com/open-mmlab/mmengine/blob/main/mmengine/registry/build_functions.py |
mmcv.utils.registry.Registry | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/registry.py | mmengine.registry.registry.Registry | https://github.com/open-mmlab/mmengine/blob/main/mmengine/registry/registry.py |
mmcv.utils.seed.worker_init_fn | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/seed.py | mmengine.dataset.utils.worker_init_fn | https://github.com/open-mmlab/mmengine/blob/main/mmengine/dataset/utils.py |
mmcv.utils.testing.check_python_script | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/testing.py | mmengine.testing.compare.check_python_script | https://github.com/open-mmlab/mmengine/blob/main/mmengine/testing/compare.py |
mmcv.utils.testing._any | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/testing.py | mmengine.testing.compare._any | https://github.com/open-mmlab/mmengine/blob/main/mmengine/testing/compare.py |
mmcv.utils.testing.assert_dict_contains_subset | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/testing.py | mmengine.testing.compare.assert_dict_contains_subset | https://github.com/open-mmlab/mmengine/blob/main/mmengine/testing/compare.py |
mmcv.utils.testing.assert_attrs_equal | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/testing.py | mmengine.testing.compare.assert_attrs_equal | https://github.com/open-mmlab/mmengine/blob/main/mmengine/testing/compare.py |
mmcv.utils.testing.assert_dict_has_keys | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/testing.py | mmengine.testing.compare.assert_dict_has_keys | https://github.com/open-mmlab/mmengine/blob/main/mmengine/testing/compare.py |
mmcv.utils.testing.assert_keys_equal | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/testing.py | mmengine.testing.compare.assert_keys_equal | https://github.com/open-mmlab/mmengine/blob/main/mmengine/testing/compare.py |
mmcv.utils.testing.assert_is_norm_layer | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/testing.py | mmengine.testing.compare.assert_is_norm_layer | https://github.com/open-mmlab/mmengine/blob/main/mmengine/testing/compare.py |
mmcv.utils.testing.assert_params_all_zeros | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/testing.py | mmengine.testing.compare.assert_params_all_zeros | https://github.com/open-mmlab/mmengine/blob/main/mmengine/testing/compare.py |
mmcv.utils.timer.TimerError | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/timer.py | mmengine.utils.timer.TimerError | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/timer.py |
mmcv.utils.timer.Timer | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/timer.py | mmengine.utils.timer.Timer | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/timer.py |
mmcv.utils.timer._g_timers | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/timer.py | mmengine.utils.timer._g_timers | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/timer.py |
mmcv.utils.timer.check_time | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/timer.py | mmengine.utils.timer.check_time | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/timer.py |
mmcv.utils.torch_ops._torch_version_meshgrid_indexing | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/torch_ops.py | mmengine.utils.dl_utils.torch_ops._torch_version_meshgrid_indexing | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/torch_ops.py |
mmcv.utils.torch_ops.torch_meshgrid | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/torch_ops.py | mmengine.utils.dl_utils.torch_ops.torch_meshgrid | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/torch_ops.py |
mmcv.utils.trace.is_jit_tracing | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/trace.py | mmengine.utils.dl_utils.trace.is_jit_tracing | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/dl_utils/trace.py |
mmcv.utils.version_utils.digit_version | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/version_utils.py | mmengine.utils.version_utils.digit_version | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/version_utils.py |
mmcv.utils.version_utils._minimal_ext_cmd | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/version_utils.py | mmengine.utils.version_utils._minimal_ext_cmd | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/version_utils.py |
mmcv.utils.version_utils.get_git_hash | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/utils/version_utils.py | mmengine.utils.version_utils.get_git_hash | https://github.com/open-mmlab/mmengine/blob/main/mmengine/utils/version_utils.py |
mmcv.cnn
¶
MMCV | MMCV URL | MMEngine | MMEngine URL |
---|---|---|---|
mmcv.cnn.utils.sync_bn._BatchNormXd | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/cnn/utils/sync_bn.py | mmengine.model.utils._BatchNormXd | https://github.com/open-mmlab/mmengine/blob/main/mmengine/model/utils.py |
mmcv.cnn.utils.sync_bn.revert_sync_batchnorm | https://github.com/open-mmlab/mmcv/blob/v1.7.1/mmcv/cnn/utils/sync_bn.py | mmengine.model.utils.revert_sync_batchnorm | https://github.com/open-mmlab/mmengine/blob/main/mmengine/model/utils.py |
mmcv.model_zoo
¶
MMCV | MMCV URL | MMEngine | MMEngine URL |
---|---|---|---|
mmcv.model_zoo.deprecated.json | https://github.com/open-mmlab/mmcv/tree/v1.7.1/mmcv/model_zoo/deprecated.json | mmengine.hub.deprecated.json | https://github.com/open-mmlab/mmengine/tree/main/mmengine/hub/deprecated.json |
mmcv.model_zoo.mmcls.json | https://github.com/open-mmlab/mmcv/tree/v1.7.1/mmcv/model_zoo/mmcls.json | mmengine.hub.mmcls.json | https://github.com/open-mmlab/mmengine/tree/main/mmengine/hub/mmcls.json |
mmcv.model_zoo.open_mmlab.json | https://github.com/open-mmlab/mmcv/tree/v1.7.1/mmcv/model_zoo/open_mmlab.json | mmengine.hub.openmmlab.json | https://github.com/open-mmlab/mmengine/tree/main/mmengine/hub/openmmlab.json |
mmcv.model_zoo.torchvision_0.12.json | https://github.com/open-mmlab/mmcv/tree/v1.7.1/mmcv/model_zoo/torchvision_0.12.json | mmengine.hub.torchvision_0.12.json | https://github.com/open-mmlab/mmengine/tree/main/mmengine/hub/torchvision_0.12.json |
Data Process¶
Image¶
This module provides some image processing methods, which requires opencv
to be installed first.
Read/Write/Show¶
To read or write images files, use imread
or imwrite
.
import mmcv
img = mmcv.imread('test.jpg')
img = mmcv.imread('test.jpg', flag='grayscale')
img_ = mmcv.imread(img) # nothing will happen, img_ = img
mmcv.imwrite(img, 'out.jpg')
To read images from bytes
with open('test.jpg', 'rb') as f:
data = f.read()
img = mmcv.imfrombytes(data)
To show an image file or a loaded image
mmcv.imshow('tests/data/color.jpg')
# this is equivalent to
for i in range(10):
img = np.random.randint(256, size=(100, 100, 3), dtype=np.uint8)
mmcv.imshow(img, win_name='test image', wait_time=200)
Color space conversion¶
Supported conversion methods:
bgr2gray
gray2bgr
bgr2rgb
rgb2bgr
bgr2hsv
hsv2bgr
img = mmcv.imread('tests/data/color.jpg')
img1 = mmcv.bgr2rgb(img)
img2 = mmcv.rgb2gray(img1)
img3 = mmcv.bgr2hsv(img)
Resize¶
There are three resize methods. All imresize_*
methods have an argument return_scale
,
if this argument is False
, then the return value is merely the resized image, otherwise
is a tuple (resized_img, scale)
.
# resize to a given size
mmcv.imresize(img, (1000, 600), return_scale=True)
# resize to the same size of another image
mmcv.imresize_like(img, dst_img, return_scale=False)
# resize by a ratio
mmcv.imrescale(img, 0.5)
# resize so that the max edge no longer than 1000, short edge no longer than 800
# without changing the aspect ratio
mmcv.imrescale(img, (1000, 800))
Rotate¶
To rotate an image by some angle, use imrotate
. The center can be specified,
which is the center of original image by default. There are two modes of rotating,
one is to keep the image size unchanged so that some parts of the image will be
cropped after rotating, the other is to extend the image size to fit the rotated
image.
img = mmcv.imread('tests/data/color.jpg')
# rotate the image clockwise by 30 degrees.
img_ = mmcv.imrotate(img, 30)
# rotate the image counterclockwise by 90 degrees.
img_ = mmcv.imrotate(img, -90)
# rotate the image clockwise by 30 degrees, and rescale it by 1.5x at the same time.
img_ = mmcv.imrotate(img, 30, scale=1.5)
# rotate the image clockwise by 30 degrees, with (100, 100) as the center.
img_ = mmcv.imrotate(img, 30, center=(100, 100))
# rotate the image clockwise by 30 degrees, and extend the image size.
img_ = mmcv.imrotate(img, 30, auto_bound=True)
Flip¶
To flip an image, use imflip
.
img = mmcv.imread('tests/data/color.jpg')
# flip the image horizontally
mmcv.imflip(img)
# flip the image vertically
mmcv.imflip(img, direction='vertical')
Crop¶
imcrop
can crop the image with one or more regions. Each region is represented by the upper left and lower right coordinates as (x1, y1, x2, y2).
import mmcv
import numpy as np
img = mmcv.imread('tests/data/color.jpg')
# crop the region (10, 10, 100, 120)
bboxes = np.array([10, 10, 100, 120])
patch = mmcv.imcrop(img, bboxes)
# crop two regions (10, 10, 100, 120) and (0, 0, 50, 50)
bboxes = np.array([[10, 10, 100, 120], [0, 0, 50, 50]])
patches = mmcv.imcrop(img, bboxes)
# crop two regions, and rescale the patches by 1.2x
patches = mmcv.imcrop(img, bboxes, scale=1.2)
Padding¶
There are two methods, impad
and impad_to_multiple
, to pad an image to the
specific size with given values.
img = mmcv.imread('tests/data/color.jpg')
# pad the image to (1000, 1200) with all zeros
img_ = mmcv.impad(img, shape=(1000, 1200), pad_val=0)
# pad the image to (1000, 1200) with different values for three channels.
img_ = mmcv.impad(img, shape=(1000, 1200), pad_val=(100, 50, 200))
# pad the image on left, right, top, bottom borders with all zeros
img_ = mmcv.impad(img, padding=(10, 20, 30, 40), pad_val=0)
# pad the image on left, right, top, bottom borders with different values
# for three channels.
img_ = mmcv.impad(img, padding=(10, 20, 30, 40), pad_val=(100, 50, 200))
# pad an image so that each edge is a multiple of some value.
img_ = mmcv.impad_to_multiple(img, 32)
Video¶
This module provides the following functionalities:
A
VideoReader
class with friendly apis to read and convert videos.Some methods for editing (cut, concat, resize) videos.
Optical flow read/write/warp.
VideoReader¶
The VideoReader
class provides sequence like apis to access video frames.
It will internally cache the frames which have been visited.
video = mmcv.VideoReader('test.mp4')
# obtain basic information
print(len(video))
print(video.width, video.height, video.resolution, video.fps)
# iterate over all frames
for frame in video:
print(frame.shape)
# read the next frame
img = video.read()
# read a frame by index
img = video[100]
# read some frames
img = video[5:10]
To convert a video to images or generate a video from a image directory.
# split a video into frames and save to a folder
video = mmcv.VideoReader('test.mp4')
video.cvt2frames('out_dir')
# generate video from frames
mmcv.frames2video('out_dir', 'test.avi')
Editing utils¶
There are also some methods for editing videos, which wraps the commands of ffmpeg.
# cut a video clip
mmcv.cut_video('test.mp4', 'clip1.mp4', start=3, end=10, vcodec='h264')
# join a list of video clips
mmcv.concat_video(['clip1.mp4', 'clip2.mp4'], 'joined.mp4', log_level='quiet')
# resize a video with the specified size
mmcv.resize_video('test.mp4', 'resized1.mp4', (360, 240))
# resize a video with a scaling ratio of 2
mmcv.resize_video('test.mp4', 'resized2.mp4', ratio=2)
Optical flow¶
mmcv
provides the following methods to operate on optical flows.
IO
Visualization
Flow warping
We provide two options to dump optical flow files: uncompressed and compressed. The uncompressed way just dumps the floating numbers to a binary file. It is lossless but the dumped file has a larger size. The compressed way quantizes the optical flow to 0-255 and dumps it as a jpeg image. The flow of x-dim and y-dim will be concatenated into a single image.
IO
flow = np.random.rand(800, 600, 2).astype(np.float32)
# dump the flow to a flo file (~3.7M)
mmcv.flowwrite(flow, 'uncompressed.flo')
# dump the flow to a jpeg file (~230K)
# the shape of the dumped image is (800, 1200)
mmcv.flowwrite(flow, 'compressed.jpg', quantize=True, concat_axis=1)
# read the flow file, the shape of loaded flow is (800, 600, 2) for both ways
flow = mmcv.flowread('uncompressed.flo')
flow = mmcv.flowread('compressed.jpg', quantize=True, concat_axis=1)
Visualization
It is possible to visualize optical flows with mmcv.flowshow()
.
mmcv.flowshow(flow)
Flow warping
img1 = mmcv.imread('img1.jpg')
flow = mmcv.flowread('flow.flo')
warped_img2 = mmcv.flow_warp(img1, flow)
img1 (left) and img2 (right)
optical flow (img2 -> img1)
warped image and difference with ground truth
Data Transformation¶
In the OpenMMLab algorithm library, dataset construction and data preparation are decoupled. Usually, the construction of the dataset only parses the dataset and records the basic information of each sample, while the data preparation is a series of data transformations including data loading, preprocessing, formatting, and other operations performed according to the basic information of the sample.
Design of data transformation¶
In MMCV, we use various callable data transformation classes to manipulate data. These data transformation classes can accept several configuration parameters for the instantiation and then process the input data dictionary by __call__
method. All data transformation methods accept a dictionary as the input and produce the output as a dictionary as well. A simple example is as follows:
>>> import numpy as np
>>> from mmcv.transforms import Resize
>>>
>>> transform = Resize(scale=(224, 224))
>>> data_dict = {'img': np.random.rand(256, 256, 3)}
>>> data_dict = transform(data_dict)
>>> print(data_dict['img'].shape)
(224, 224, 3)
The data transformation class reads some fields of the input dictionary and may add or update some fields. The keys of these fields are mostly fixed. For example, Resize
will always read fields such as "img"
in the input dictionary. More information about the conventions for input and output fields could be found in the documentation of the corresponding class.
注解
By convention, the order of image shape which is used as initialization parameters in data transformation (such as Resize, Pad) is (width, height). In the dictionary returned by the data transformation, the image related shape, such as img_shape
, ori_shape
, pad_shape
, etc., is (height, width).
MMCV provides a unified base class called BaseTransform
for all data transformation classes:
class BaseTransform(metaclass=ABCMeta):
def __call__(self, results: dict) -> dict:
return self.transform(results)
@abstractmethod
def transform(self, results: dict) -> dict:
pass
All data transformation classes must inherit BaseTransform
and implement the transform
method. Both the input and output of the transform
method are a dictionary. In the Custom data transformation class section, we will describe how to implement a data transformation class in more detail.
Data pipeline¶
As mentioned above, the inputs and outputs of all data transformations are dictionaries. Moreover, according to the [Convention on Datasets] (TODO) in OpenMMLab, the basic information of each sample in the dataset is also a dictionary. This way, we can connect all data transformation operations end to end and combine them into a data pipeline. This pipeline inputs the information dictionary of the samples in the dataset and outputs the information dictionary after a series of processing.
Taking the classification task as an example, we show a typical data pipeline in the figure below. For each sample, the information stored in the dataset is a dictionary, as shown on the far left in the figure. After each data transformation operation represented by the blue block, a new field (marked in green) will be added to the data dictionary or an existing field (marked in orange) will be updated.

The data pipeline is a list of several data transformation configuration dictionaries in the configuration file. Each dataset needs to set the parameter pipeline
to define the data preparation operations the dataset needs to perform. The configuration of the above data pipeline in the configuration file is as follows:
pipeline = [
dict(type='LoadImageFromFile'),
dict(type='Resize', size=256, keep_ratio=True),
dict(type='CenterCrop', crop_size=224),
dict(type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375]),
dict(type='ClsFormatBundle')
]
dataset = dict(
...
pipeline=pipeline,
...
)
Common data transformation classes¶
The commonly used data transformation classes can be roughly divided into data loading, data preprocessing and augmentation, and data formatting. In MMCV, we provide some commonly used classes as follows:
Data loading¶
To support the loading of large-scale datasets, data is usually not loaded when Dataset
is initialized. Only the corresponding path is loaded. Therefore, it is necessary to load specific data in the data pipeline.
Class | Feature |
---|---|
LoadImageFromFile |
Load from file path |
LoadAnnotations |
Load and organize the annotations (bbox, etc.) |
Data preprocessing and enhancement¶
Data preprocessing and augmentation usually involve transforming the image itself, such as cropping, padding, scaling, etc.
Class | Feature |
---|---|
Pad |
Padding |
CenterCrop |
Center crop |
Normalize |
Image normalization |
Resize |
Resize to the specified size or ratio |
RandomResize |
Scale the image randomly within the specified range |
RandomMultiscaleResize |
Scale the image to a random size from multiple options |
RandomGrayscale |
Random grayscale |
RandomFlip |
Random flip |
MultiScaleFlipAug |
Support scaling and flipping during the testing |
Data formatting¶
Data formatting operations are type conversions performed on the data.
Class | Feature |
---|---|
ToTensor |
Convert the specified data to torch.Tensor |
ImageToTensor |
Convert the image to torch.Tensor |
Customize data transformation classes¶
To implement a new data transformation class, you must inherit BaseTransform
and implement the transform
method. Here, we use a simple flip transform (MyFlip
) as an example:
import random
import mmcv
from mmcv.transforms import BaseTransform, TRANSFORMS
@TRANSFORMS.register_module()
class MyFlip(BaseTransform):
def __init__(self, direction: str):
super().__init__()
self.direction = direction
def transform(self, results: dict) -> dict:
img = results['img']
results['img'] = mmcv.imflip(img, direction=self.direction)
return results
Now, we can instantiate MyFlip
as a callable object to handle our data dictionary.
import numpy as np
transform = MyFlip(direction='horizontal')
data_dict = {'img': np.random.rand(224, 224, 3)}
data_dict = transform(data_dict)
processed_img = data_dict['img']
Alternatively, use MyFlip
transform in the pipeline
of the config file.
pipeline = [
...
dict(type='MyFlip', direction='horizontal'),
...
]
It should be noted that if you want to use it in the configuration file, you must ensure that the file where the MyFlip
class is located can be imported at the runtime.
Transform wrapper¶
Transform wrappers are a special class of data transformations. They do not operate on images, labels or other information in the data dictionary by themselves. Instead, they enhance the behavior of data transformations defined in them.
KeyMapper¶
KeyMapper
is used to map fields in the data dictionary. For example, image processing transforms usually get their values from the "img"
field in the data dictionary. But sometimes we want these transforms to handle images in other fields in the data dictionary, such as the "gt_img"
field.
When used with registry and configuration file, the field map wrapper should be used as follows:
pipeline = [
...
dict(type='KeyMapper',
mapping={
'img': 'gt_img', # map "gt_img" to "img"
'mask': ..., # The "mask" field in the raw data is not used. That is, for wrapped data transformations, the "mask" field is not included in the data
},
auto_remap=True, # remap "img" back to "gt_img" after the transformation
transforms=[
# only need to specify "img" in `RandomFlip`
dict(type='RandomFlip'),
])
...
]
With KeyMapper
, we don’t need to consider various possible input field names in the transform
method when we implement the data transformation class. We only need to deal with the default fields.
RandomChoice and RandomApply¶
RandomChoice
is used to randomly select a data transformation pipeline from the given choices. With this wrapper, we can easily implement some data augmentation functions, such as AutoAugment.
In configuration file, you can use RandomChoice
as follows:
pipeline = [
...
dict(type='RandomChoice',
transforms=[
[
dict(type='Posterize', bits=4),
dict(type='Rotate', angle=30.)
], # the first combo option
[
dict(type='Equalize'),
dict(type='Rotate', angle=30)
], # the second combo option
],
prob=[0.4, 0.6] # the prob of each combo
)
...
]
RandomApply
is used to randomly perform a combination of data transformations with a specified probability. For example:
pipeline = [
...
dict(type='RandomApply',
transforms=[dict(type='Rotate', angle=30.)],
prob=0.3) # perform the transformation with prob as 0.3
...
]
TransformBroadcaster¶
Usually, a data transformation class only reads the target of an operation from one field. While we can also use KeyMapper
to change the fields read, there is no way to apply transformations to the data of multiple fields at once. To achieve this, we need to use the multi-target extension wrapper TransformBroadcaster
.
TransformBroadcaster
has two uses, one is to apply data transformation to multiple specified fields, and the other is to apply data transformation to a group of targets under a field.
Apply to multiple fields
Suppose we need to apply a data transformation to images in two fields
"lq"
(low-quality) and"gt"
(ground-truth).pipeline = [ dict(type='TransformBroadcaster', # apply to the "lq" and "gt" fields respectively, and set the "img" field to both mapping={'img': ['lq', 'gt']}, # remap the "img" field back to the original field after the transformation auto_remap=True, # whether to share random variables in the transformation of each target # more introduction will be referred in the following chapters (random variable sharing) share_random_params=True, transforms=[ # only need to manipulate the "img" field in the `RandomFlip` class dict(type='RandomFlip'), ]) ]
In the
mapping
setting of the multi-target extension, we can also use...
to ignore the specified original field. As shown in the following example, the wrappedRandomCrop
will crop the image in the field"img"
and update the size of the cropped image if the field"img_shape"
exists. If we want to do the same random cropping for both image fields"lq"
and"gt"
at the same time but update the"img_shape"
field only once, we can do it as in the example:pipeline = [ dict(type='TransformBroadcaster', mapping={ 'img': ['lq', 'gt'], 'img_shape': ['img_shape', ...], }, # remap the "img" and "img_shape" fields back to their original fields after the transformation auto_remap=True, # whether to share random variables in the transformation of each target # more introduction will be referred in the following chapters (random variable sharing) share_random_params=True, transforms=[ # "img" and "img_shape" fields are manipulated in the `RandomCrop` class # if "img_shape" is missing, only operate on "img" dict(type='RandomCrop'), ]) ]
A set of targets applied to a field
Suppose we need to apply a data transformation to the
"images"
field, which is a list of images.pipeline = [ dict(type='TransformBroadcaster', # map each image under the "images" field to the "img" field mapping={'img': 'images'}, # remap the images under the "img" field back to the list in the "images" field after the transformation auto_remap=True, # whether to share random variables in the transformation of each target share_random_params=True, transforms=[ # in the `RandomFlip` transformation class, we only need to manipulate the "img" field dict(type='RandomFlip'), ]) ]
Decorator cache_randomness
¶
In TransformBroadcaster
, we provide the share_random_params
option to support sharing random states across multiple data transformations. For example, in a super-resolution task, we want to apply the same random transformations simultaneously to the low-resolution image and the original image. If we use this function in a custom data transformation class, we need to mark which random variables support sharing in the class. This can be achieved with the decorator cache_randomness
.
Taking MyFlip
from the above example, we want to perform flipping randomly with a certain probability:
from mmcv.transforms.utils import cache_randomness
@TRANSFORMS.register_module()
class MyRandomFlip(BaseTransform):
def __init__(self, prob: float, direction: str):
super().__init__()
self.prob = prob
self.direction = direction
@cache_randomness # label the output of the method as a shareable random variable
def do_flip(self):
flip = True if random.random() > self.prob else False
return flip
def transform(self, results: dict) -> dict:
img = results['img']
if self.do_flip():
results['img'] = mmcv.imflip(img, direction=self.direction)
return results
In the above example, we decorate the do_flip
method with cache_randomness
, marking the method return value flip
as a random variable that supports sharing. Therefore, in the transformation of TransformBroadcaster
to multiple targets, the value of this variable will remain the same.
Decorator avoid_cache_randomness
¶
In some cases, we cannot separate the process of generating random variables in data transformation into a class method. For example, modules from third-party libraries used in data transformation encapsulate the relevant parts of random variables inside, making them impossible to be extracted as class methods for data transformation. Such data transformations cannot support shared random variables through the decorator cache_randomness
annotation, and thus cannot share random variables during multi-objective expansion.
To avoid misuse of such data transformations in multi-object extensions, we provide another decorator, avoid_cache_randomness
, to mark such data transformations:
from mmcv.transforms.utils import avoid_cache_randomness
@TRANSFORMS.register_module()
@avoid_cache_randomness
class MyRandomTransform(BaseTransform):
def transform(self, results: dict) -> dict:
...
Data transformation classes marked with avoid_cache_randomness
will throw an exception when their instance is wrapped by TransformBroadcaster
and the parameter share_random_params
is set to True. This reminds the user not to use it in this way.
There are a few things to keep in mind when using avoid_cache_randomness
:
avoid_cache_randomness
is only used to decorate data transformation classes (subclasses ofBaseTransfrom
) and cannot be used to decorate other general classes, class methods, or functionsWhen a data transformation decorated with
avoid_cache_randomness
is used as a base class, its subclasses will not inherit its feature. If the subclass is still unable to share random variables,avoid_cache_randomness
should be used again.A data transformation needs to be modified with
avoid_cache_randomness
only when a data transformation is random and cannot share its random parameters. Data transformations without randomness require no decoration
Visualization¶
mmcv
can show images and annotations (currently supported types include bounding boxes).
# show an image file
mmcv.imshow('a.jpg')
# show a loaded image
img = np.random.rand(100, 100, 3)
mmcv.imshow(img)
# show image with bounding boxes
img = np.random.rand(100, 100, 3)
bboxes = np.array([[0, 0, 50, 50], [20, 20, 60, 60]])
mmcv.imshow_bboxes(img, bboxes)
mmcv
can also visualize special images such as optical flows.
flow = mmcv.flowread('test.flo')
mmcv.flowshow(flow)
CNN¶
We provide some building bricks for CNNs, including layer building, module bundles and weight initialization.
Layer building¶
We may need to try different layers of the same type when running experiments, but do not want to modify the code from time to time. Here we provide some layer building methods to construct layers from a dict, which can be written in configs or specified via command line arguments.
Usage¶
A simplest example is
from mmcv.cnn import build_conv_layer
cfg = dict(type='Conv3d')
layer = build_conv_layer(cfg, in_channels=3, out_channels=8, kernel_size=3)
build_conv_layer
: Supported types are Conv1d, Conv2d, Conv3d, Conv (alias for Conv2d).build_norm_layer
: Supported types are BN1d, BN2d, BN3d, BN (alias for BN2d), SyncBN, GN, LN, IN1d, IN2d, IN3d, IN (alias for IN2d).build_activation_layer
: Supported types are ReLU, LeakyReLU, PReLU, RReLU, ReLU6, ELU, Sigmoid, Tanh, GELU.build_upsample_layer
: Supported types are nearest, bilinear, deconv, pixel_shuffle.build_padding_layer
: Supported types are zero, reflect, replicate.
Extension¶
We also allow extending the building methods with custom layers and operators.
Write and register your own module.
from mmengine.registry import MODELS @MODELS.register_module() class MyUpsample: def __init__(self, scale_factor): pass def forward(self, x): pass
Import
MyUpsample
somewhere (e.g., in__init__.py
) and then use it.from mmcv.cnn import build_upsample_layer cfg = dict(type='MyUpsample', scale_factor=2) layer = build_upsample_layer(cfg)
Module bundles¶
We also provide common module bundles to facilitate the network construction.
ConvModule
is a bundle of convolution, normalization and activation layers,
please refer to the api for details.
from mmcv.cnn import ConvModule
# conv + bn + relu
conv = ConvModule(3, 8, 2, norm_cfg=dict(type='BN'))
# conv + gn + relu
conv = ConvModule(3, 8, 2, norm_cfg=dict(type='GN', num_groups=2))
# conv + relu
conv = ConvModule(3, 8, 2)
# conv
conv = ConvModule(3, 8, 2, act_cfg=None)
# conv + leaky relu
conv = ConvModule(3, 8, 3, padding=1, act_cfg=dict(type='LeakyReLU'))
# bn + conv + relu
conv = ConvModule(
3, 8, 2, norm_cfg=dict(type='BN'), order=('norm', 'conv', 'act'))
ops¶
We implement common ops used in detection, segmentation, etc.
Device | CPU | CUDA | MLU | MPS | Ascend |
---|---|---|---|---|---|
ActiveRotatedFilter | √ | √ | √ | ||
AssignScoreWithK | √ | ||||
BallQuery | √ | √ | √ | ||
BBoxOverlaps | √ | √ | √ | √ | |
BorderAlign | √ | ||||
BoxIouRotated | √ | √ | √ | √ | |
BoxIouQuadri | √ | √ | |||
CARAFE | √ | √ | |||
ChamferDistance | √ | √ | |||
CrissCrossAttention | √ | ||||
ContourExpand | √ | ||||
ConvexIoU | √ | ||||
CornerPool | √ | ||||
Correlation | √ | ||||
Deformable Convolution v1/v2 | √ | √ | √ | √ | |
Deformable RoIPool | √ | √ | √ | ||
DiffIoURotated | √ | √ | |||
DynamicScatter | √ | √ | |||
FurthestPointSample | √ | ||||
FurthestPointSampleWithDist | √ | ||||
FusedBiasLeakyrelu | √ | √ | |||
GatherPoints | √ | √ | |||
GroupPoints | √ | ||||
Iou3d | √ | √ | |||
KNN | √ | ||||
MaskedConv | √ | √ | √ | ||
MergeCells | √ | ||||
MinAreaPolygon | √ | ||||
ModulatedDeformConv2d | √ | √ | √ | √ | |
MultiScaleDeformableAttn | √ | √ | √ | ||
NMS | √ | √ | √ | √ | |
NMSRotated | √ | √ | √ | √ | |
NMSQuadri | √ | √ | |||
PixelGroup | √ | ||||
PointsInBoxes | √ | √ | |||
PointsInPolygons | √ | √ | |||
PSAMask | √ | √ | √ | √ | |
RotatedFeatureAlign | √ | √ | √ | √ | |
RoIPointPool3d | √ | √ | |||
RoIPool | √ | √ | √ | ||
RoIAlignRotated | √ | √ | √ | √ | |
RiRoIAlignRotated | √ | ||||
RoIAlign | √ | √ | √ | √ | |
RoIAwarePool3d | √ | √ | |||
SAConv2d | √ | ||||
SigmoidFocalLoss | √ | √ | √ | ||
SoftmaxFocalLoss | √ | √ | |||
SoftNMS | √ | ||||
Sparse Convolution | √ | √ | |||
Synchronized BatchNorm | √ | ||||
ThreeInterpolate | √ | ||||
ThreeNN | √ | √ | |||
TINShift | √ | √ | |||
UpFirDn2d | √ | ||||
Voxelization | √ | √ | √ | √ | |
PrRoIPool | √ | ||||
BezierAlign | √ | √ | |||
BiasAct | √ | ||||
FilteredLrelu | √ | ||||
Conv2dGradfix | √ |
MMCV Operators¶
To make custom operators in MMCV more standard, precise definitions of each operator are listed in this document.
MMCVBorderAlign¶
Description¶
Applies border_align
over the input feature based on predicted bboxes.
For each border line (e.g. top, left, bottom or right) of each box, border_align does the following:
uniformly samples
pool_size
+1 positions on this line, involving the start and end points.the corresponding features on these points are computed by bilinear interpolation.
max pooling over all the
pool_size
+1 positions are used for computing pooled feature.
Read BorderDet: Border Feature for Dense Object Detection for more detailed information.
Parameters¶
Type | Parameter | Description |
---|---|---|
int |
pool_size |
number of positions sampled over the boxes' borders(e.g. top, bottom, left, right). |
Inputs¶
- input: T
- Features with shape [N,4C,H,W]. Channels ranged in [0,C), [C,2C), [2C,3C), [3C,4C) represent the top, left, bottom, right features respectively
- boxes: T
- Boxes with shape [N,H*W,4]. Coordinate format (x1,y1,x2,y2).
Outputs¶
- output: T
- Pooled features with shape [N,C,H*W,4]. The order is(top,left,bottom,right) for the last dimension.
Type Constraints¶
T:tensor(float32)
MMCVCARAFE¶
Description¶
CARAFE operator performs feature upsampling.
Read CARAFE: Content-Aware ReAssembly of FEatures for more detailed information.
Parameters¶
Type | Parameter | Description |
---|---|---|
int |
kernel_size |
reassemble kernel size, should be odd integer |
int |
group_size |
reassemble group size |
float |
scale_factor |
upsample ratio(>=1) |
Inputs¶
- features: T
- Input features. 4-D tensor of shape (N, C, H, W). N is the batch size.
- masks: T
- The input mask
Outputs¶
- output: T
- The upsampled features. 4-D tensor of shape (N, C, H * scale_factor, W * scale_factor). N is the batch size.
Type Constraints¶
T:tensor(float32)
MMCVCAWeight¶
Description¶
Operator for Criss-Cross Attention Read CCNet: Criss-Cross Attention for SemanticSegmentation for more detailed information.
Parameters¶
None
Inputs¶
- t: T
- The query matrix of shape (N, C', H, W).
- f: T
- The key matrix of shape (N, C', H, W).
Outputs¶
- weight: T
- The attention map of shape (N, H+W-1, H, W).
Type Constraints¶
T:tensor(float32)
MMCVCAMap¶
Description¶
Operator for Criss-Cross Attention Read CCNet: Criss-Cross Attention for SemanticSegmentation for more detailed information.
Parameters¶
None
Inputs¶
- weight: T
- Output from the operator MMCVCAWeight.
- value: T
- The value matrix of shape (N, C, H, W).
Outputs¶
- output: T
- Output tensor of aggregated contextual information
Type Constraints¶
T:tensor(float32)
MMCVCornerPool¶
Description¶
Perform CornerPool on input
features. Read CornerNet – Detecting Objects as Paired Keypoints for more details.
Parameters¶
Type | Parameter | Description |
---|---|---|
int |
mode |
corner pool mode, (0: top , 1: bottom , 2: left , 3: right ) |
Inputs¶
- input: T
- Input features. 4-D tensor of shape (N, C, H, W). N is the batch size.
Outputs¶
- output: T
- The pooled features. 4-D tensor of shape (N, C, H, W).
Type Constraints¶
T:tensor(float32)
MMCVDeformConv2d¶
Description¶
Applies a deformable 2D convolution over an input signal composed of several input planes.
Read Deformable Convolutional Networks for detail.
Parameters¶
Type | Parameter | Description |
---|---|---|
list of ints |
stride |
The stride of the convolving kernel, (sH, sW). Defaults to (1, 1) . |
list of ints |
padding |
Paddings on both sides of the input, (padH, padW). Defaults to (0, 0) . |
list of ints |
dilation |
The spacing between kernel elements (dH, dW). Defaults to (1, 1) . |
int |
groups |
Split input into groups. input_channel should be divisible by the number of groups. Defaults to 1 . |
int |
deformable_groups |
Groups of deformable offset. Defaults to 1 . |
int |
bias |
Whether to add a learnable bias to the output. 0 stands for False and 1 stands for True . Defaults to 0 . |
int |
im2col_step |
Groups of deformable offset. Defaults to 32 . |
Inputs¶
- input: T
- Input feature; 4-D tensor of shape (N, C, inH, inW), where N is the batch size, C is the number of channels, inH and inW are the height and width of the data.
- offset: T
- Input offset; 4-D tensor of shape (N, deformable_group* 2* kH* kW, outH, outW), where kH and kW are the height and width of weight, outH and outW is the height and width of offset and output.
- weight: T
- Input weight; 4-D tensor of shape (output_channel, input_channel, kH, kW).
Outputs¶
- output: T
- Output feature; 4-D tensor of shape (N, output_channel, outH, outW).
Type Constraints¶
T:tensor(float32, Linear)
MMCVModulatedDeformConv2d¶
Description¶
Perform Modulated Deformable Convolution on input feature, read Deformable ConvNets v2: More Deformable, Better Results for detail.
Parameters¶
Type | Parameter | Description |
---|---|---|
list of ints |
stride |
The stride of the convolving kernel. (sH, sW) |
list of ints |
padding |
Paddings on both sides of the input. (padH, padW) |
list of ints |
dilation |
The spacing between kernel elements. (dH, dW) |
int |
deformable_groups |
Groups of deformable offset. |
int |
groups |
Split input into groups. input_channel should be divisible by the number of groups. |
Inputs¶
- feature: T
- Input feature; 4-D tensor of shape (N, C, inH, inW), where N is the batch size, C is the number of channels, inH and inW are the height and width of the data.
- offset: T
- Input offset; 4-D tensor of shape (N, deformable_group* 2* kH* kW, outH, outW), where kH and kW are the height and width of weight, outH and outW are the height and width of offset and output.
- mask: T
- Input mask; 4-D tensor of shape (N, deformable_group* kH* kW, outH, outW), where kH and kW are the height and width of weight, outH and outW are the height and width of offset and output.
- weight]: T
- Input weight; 4-D tensor of shape (output_channel, input_channel, kH, kW).
- bias: T, optional
- Input bias; 1-D tensor of shape (output_channel).
Outputs¶
- output: T
- Output feature; 4-D tensor of shape (N, output_channel, outH, outW).
Type Constraints¶
T:tensor(float32, Linear)
MMCVDeformRoIPool¶
Description¶
Deformable roi pooling layer
Parameters¶
Type | Parameter | Description |
---|---|---|
int |
output_height |
height of output roi |
int |
output_width |
width of output roi |
float |
spatial_scale |
used to scale the input boxes |
int |
sampling_ratio |
number of input samples to take for each output sample. 0 means to take samples densely for current models. |
float |
gamma |
gamma |
Inputs¶
- input: T
- Input feature map; 4D tensor of shape (N, C, H, W), where N is the batch size, C is the numbers of channels, H and W are the height and width of the data.
- rois: T
- RoIs (Regions of Interest) to pool over; 2-D tensor of shape (num_rois, 5) given as [[batch_index, x1, y1, x2, y2], ...]. The RoIs' coordinates are the coordinate system of input.
- offset: T
- offset of height and width. Defaults to a tensor of zero
Outputs¶
- feat: T
- RoI pooled output, 4-D tensor of shape (num_rois, C, output_height, output_width). The r-th batch element feat[r-1] is a pooled feature map corresponding to the r-th RoI RoIs[r-1].
Type Constraints¶
T:tensor(float32)
MMCVMaskedConv2d¶
Description¶
Performs a masked 2D convolution from PixelRNN Read Pixel Recurrent Neural Networks for more detailed information.
Parameters¶
Type | Parameter | Description |
---|---|---|
list of ints |
stride |
The stride of the convolving kernel. (sH, sW). Only support stride=1 in mmcv |
list of ints |
padding |
Paddings on both sides of the input. (padH, padW). Defaults to (0, 0) . |
Inputs¶
- features: T
- Input features; 4D tensor of shape (N, C, H, W), where N is the batch size, C is the numbers of channels, H and W are the height and width of the data.
- mask: T
- Input mask; 3D tensor of shape (N, H, W)
- weight: T
- The learnable weights of the module
- bias: T
- The learnable bias of the module
Outputs¶
- output: T
- The output convolved feature
Type Constraints¶
T:tensor(float32)
MMCVPSAMask¶
Description¶
An operator from PSANet.
Read PSANet: Point-wise Spatial Attention Network for Scene Parsing for more detailed information.
Parameters¶
Type | Parameter | Description |
---|---|---|
int |
psa_type |
0 means collect and 1 means distribute |
list of ints |
mask_size |
The size of mask |
Inputs¶
- input: T
- Input feature; 4D tensor of shape (N, C, H, W), where N is the batch size, C is the numbers of channels, H and W are the height and width of the data.
Outputs¶
- output: T
- Output tensor of shape (N, H * W, H, W)
Type Constraints¶
T:tensor(float32)
NonMaxSuppression¶
Description¶
Filter out boxes has high IoU overlap with previously selected boxes or low score. Output the indices of valid boxes.
Note this definition is slightly different with onnx: NonMaxSuppression
Parameters¶
Type | Parameter | Description |
---|---|---|
int |
center_point_box |
0 - the box data is supplied as [y1, x1, y2, x2], 1-the box data is supplied as [x_center, y_center, width, height]. |
int |
max_output_boxes_per_class |
The maximum number of boxes to be selected per batch per class. Default to 0, number of output boxes equal to number of input boxes. |
float |
iou_threshold |
The threshold for deciding whether boxes overlap too much with respect to IoU. Value range [0, 1]. Default to 0. |
float |
score_threshold |
The threshold for deciding when to remove boxes based on score. |
int |
offset |
0 or 1, boxes' width or height is (x2 - x1 + offset). |
Inputs¶
- boxes: T
- Input boxes. 3-D tensor of shape (num_batches, spatial_dimension, 4).
- scores: T
- Input scores. 3-D tensor of shape (num_batches, num_classes, spatial_dimension).
Outputs¶
- indices: tensor(int32, Linear)
- Selected indices. 2-D tensor of shape (num_selected_indices, 3) as [[batch_index, class_index, box_index], ...].
- num_selected_indices=num_batches* num_classes* min(max_output_boxes_per_class, spatial_dimension).
- All invalid indices will be filled with -1.
Type Constraints¶
T:tensor(float32, Linear)
MMCVRoIAlign¶
Description¶
Perform RoIAlign on output feature, used in bbox_head of most two-stage detectors.
Parameters¶
Type | Parameter | Description |
---|---|---|
int |
output_height |
height of output roi |
int |
output_width |
width of output roi |
float |
spatial_scale |
used to scale the input boxes |
int |
sampling_ratio |
number of input samples to take for each output sample. 0 means to take samples densely for current models. |
str |
mode |
pooling mode in each bin. avg or max |
int |
aligned |
If aligned=0 , use the legacy implementation in MMDetection. Else, align the results more perfectly. |
Inputs¶
- input: T
- Input feature map; 4D tensor of shape (N, C, H, W), where N is the batch size, C is the numbers of channels, H and W are the height and width of the data.
- rois: T
- RoIs (Regions of Interest) to pool over; 2-D tensor of shape (num_rois, 5) given as [[batch_index, x1, y1, x2, y2], ...]. The RoIs' coordinates are the coordinate system of input.
Outputs¶
- feat: T
- RoI pooled output, 4-D tensor of shape (num_rois, C, output_height, output_width). The r-th batch element feat[r-1] is a pooled feature map corresponding to the r-th RoI RoIs[r-1].
Type Constraints¶
T:tensor(float32)
MMCVRoIAlignRotated¶
Description¶
Perform RoI align pooling for rotated proposals
Parameters¶
Type | Parameter | Description |
---|---|---|
int |
output_height |
height of output roi |
int |
output_width |
width of output roi |
float |
spatial_scale |
used to scale the input boxes |
int |
sampling_ratio |
number of input samples to take for each output sample. 0 means to take samples densely for current models. |
str |
mode |
pooling mode in each bin. avg or max |
int |
aligned |
If aligned=0 , use the legacy implementation in MMDetection. Else, align the results more perfectly. |
int |
clockwise |
If aligned=0 , use the legacy implementation in MMDetection. Else, align the results more perfectly. |
Inputs¶
- features: T
- Input feature map; 4D tensor of shape (N, C, H, W)
- rois: T
- RoIs (Regions of Interest) to pool over; 2-D tensor of shape (num_rois, 5) given as [[batch_index, x1, y1, x2, y2], ...]. The RoIs' coordinates are the coordinate system of input.
Outputs¶
- RoI pooled output, 4-D tensor of shape (num_rois, C, output_height, output_width). The r-th batch element feat[r-1] is a pooled feature map corresponding to the r-th RoI RoIs[r-1].
Type Constraints¶
T:tensor(float32)
grid_sampler*¶
Description¶
Perform sample from input
with pixel locations from grid
.
Check torch.nn.functional.grid_sample for more information.
Parameters¶
Type | Parameter | Description |
---|---|---|
int |
interpolation_mode |
Interpolation mode to calculate output values. (0: bilinear , 1: nearest ) |
int |
padding_mode |
Padding mode for outside grid values. (0: zeros , 1: border , 2: reflection ) |
int |
align_corners |
If align_corners=1 , the extrema (-1 and 1 ) are considered as referring to the center points of the input's corner pixels. If align_corners=0 , they are instead considered as referring to the corner points of the input's corner pixels, making the sampling more resolution agnostic. |
Inputs¶
- input: T
- Input feature; 4-D tensor of shape (N, C, inH, inW), where N is the batch size, C is the numbers of channels, inH and inW are the height and width of the data.
- grid: T
- Input offset; 4-D tensor of shape (N, outH, outW, 2), where outH and outW are the height and width of offset and output.
Outputs¶
- output: T
- Output feature; 4-D tensor of shape (N, C, outH, outW).
Type Constraints¶
T:tensor(float32, Linear)
cummax*¶
Description¶
Returns a tuple (values
, indices
) where values
is the cumulative maximum elements of input
in the dimension dim
. And indices
is the index location of each maximum value found in the dimension dim
. Read torch.cummax for more details.
Parameters¶
Type | Parameter | Description |
---|---|---|
int |
dim |
the dimension to do the operation over |
Inputs¶
- input: T
- The input tensor with various shapes. Tensor with empty element is also supported.
Outputs¶
- output: T
- Output the cumulative maximum elements of `input` in the dimension `dim`, with the same shape and dtype as `input`.
- indices: tensor(int64)
- Output the index location of each cumulative maximum value found in the dimension `dim`, with the same shape as `input`.
Type Constraints¶
T:tensor(float32)
cummin*¶
Description¶
Returns a tuple (values
, indices
) where values
is the cumulative minimum elements of input
in the dimension dim
. And indices
is the index location of each minimum value found in the dimension dim
. Read torch.cummin for more details.
Parameters¶
Type | Parameter | Description |
---|---|---|
int |
dim |
the dimension to do the operation over |
Inputs¶
- input: T
- The input tensor with various shapes. Tensor with empty element is also supported.
Outputs¶
- output: T
- Output the cumulative minimum elements of `input` in the dimension `dim`, with the same shape and dtype as `input`.
- indices: tensor(int64)
- Output the index location of each cumulative minimum value found in the dimension `dim`, with the same shape as `input`.
Type Constraints¶
T:tensor(float32)
Reminders¶
Operators endwith
*
are defined in Torch and are included here for the conversion to ONNX.
v2.0.0¶
The OpenMMLab team released a new generation of training engine MMEngine at the World Artificial Intelligence Conference on September 1, 2022. It is a foundational library for training deep learning models. Compared with MMCV, it provides a universal and powerful runner, an open architecture with a more unified interface, and a more customizable training process.
The OpenMMLab team released MMCV v2.0.0 on April 6, 2023. In the 2.x version, it has the following significant changes:
(1) It removed the following components:
mmcv.fileio
module, removed in PR #2179. FileIO module from mmengine will be used wherever required.mmcv.runner
,mmcv.parallel
,mmcv. engine
andmmcv.device
, removed in PR #2216.All classes in
mmcv.utils
(egConfig
andRegistry
) and many functions, removed in PR #2217. Only a few functions related to mmcv are reserved.mmcv.onnx
,mmcv.tensorrt
modules and related functions, removed in PR #2225.Removed all root registrars in MMCV and registered classes or functions to the root registrar in MMEngine.
(2) It added the mmcv.transforms
data transformation module.
(3) It renamed the package name mmcv to mmcv-lite and mmcv-full to mmcv in PR #2235. Also, change the default value of the environment variable MMCV_WITH_OPS
from 0 to 1.
MMCV < 2.0 | MMCV >= 2.0 |
---|---|
# Contains ops, because the highest version of mmcv-full is less than 2.0.0, so there is no need to add version restrictions
pip install openmim
mim install mmcv-full
# do not contain ops
pip install openmim
mim install "mmcv < 2.0.0"
|
# Contains ops
pip install openmim
mim install mmcv
# Ops are not included, because the starting version of mmcv-lite is 2.0.0rc1, so there is no need to add version restrictions
pip install openmim
mim install mmcv-lite
|
v1.3.18¶
Some ops have different implementations on different devices. Lots of macros and type checks are scattered in several files, which makes the code hard to maintain. For example:
if (input.device().is_cuda()) {
#ifdef MMCV_WITH_CUDA
CHECK_CUDA_INPUT(input);
CHECK_CUDA_INPUT(rois);
CHECK_CUDA_INPUT(output);
CHECK_CUDA_INPUT(argmax_y);
CHECK_CUDA_INPUT(argmax_x);
roi_align_forward_cuda(input, rois, output, argmax_y, argmax_x,
aligned_height, aligned_width, spatial_scale,
sampling_ratio, pool_mode, aligned);
#else
AT_ERROR("RoIAlign is not compiled with GPU support");
#endif
} else {
CHECK_CPU_INPUT(input);
CHECK_CPU_INPUT(rois);
CHECK_CPU_INPUT(output);
CHECK_CPU_INPUT(argmax_y);
CHECK_CPU_INPUT(argmax_x);
roi_align_forward_cpu(input, rois, output, argmax_y, argmax_x,
aligned_height, aligned_width, spatial_scale,
sampling_ratio, pool_mode, aligned);
}
Registry and dispatcher are added to manage these implementations.
void ROIAlignForwardCUDAKernelLauncher(Tensor input, Tensor rois, Tensor output,
Tensor argmax_y, Tensor argmax_x,
int aligned_height, int aligned_width,
float spatial_scale, int sampling_ratio,
int pool_mode, bool aligned);
void roi_align_forward_cuda(Tensor input, Tensor rois, Tensor output,
Tensor argmax_y, Tensor argmax_x,
int aligned_height, int aligned_width,
float spatial_scale, int sampling_ratio,
int pool_mode, bool aligned) {
ROIAlignForwardCUDAKernelLauncher(
input, rois, output, argmax_y, argmax_x, aligned_height, aligned_width,
spatial_scale, sampling_ratio, pool_mode, aligned);
}
// register cuda implementation
void roi_align_forward_impl(Tensor input, Tensor rois, Tensor output,
Tensor argmax_y, Tensor argmax_x,
int aligned_height, int aligned_width,
float spatial_scale, int sampling_ratio,
int pool_mode, bool aligned);
REGISTER_DEVICE_IMPL(roi_align_forward_impl, CUDA, roi_align_forward_cuda);
// roi_align.cpp
// use the dispatcher to invoke different implementation depending on device type of input tensors.
void roi_align_forward_impl(Tensor input, Tensor rois, Tensor output,
Tensor argmax_y, Tensor argmax_x,
int aligned_height, int aligned_width,
float spatial_scale, int sampling_ratio,
int pool_mode, bool aligned) {
DISPATCH_DEVICE_IMPL(roi_align_forward_impl, input, rois, output, argmax_y,
argmax_x, aligned_height, aligned_width, spatial_scale,
sampling_ratio, pool_mode, aligned);
}
v1.3.11¶
In order to flexibly support more backends and hardwares like NVIDIA GPUs
and AMD GPUs
, the directory of mmcv/ops/csrc
is refactored. Note that this refactoring will not affect the usage in API. For related information, please refer to PR1206.
The original directory was organized as follows.
.
├── common_cuda_helper.hpp
├── ops_cuda_kernel.cuh
├── pytorch_cpp_helper.hpp
├── pytorch_cuda_helper.hpp
├── parrots_cpp_helper.hpp
├── parrots_cuda_helper.hpp
├── parrots_cudawarpfunction.cuh
├── onnxruntime
│ ├── onnxruntime_register.h
│ ├── onnxruntime_session_options_config_keys.h
│ ├── ort_mmcv_utils.h
│ ├── ...
│ ├── onnx_ops.h
│ └── cpu
│ ├── onnxruntime_register.cpp
│ ├── ...
│ └── onnx_ops_impl.cpp
├── parrots
│ ├── ...
│ ├── ops.cpp
│ ├── ops_cuda.cu
│ ├── ops_parrots.cpp
│ └── ops_pytorch.h
├── pytorch
│ ├── ...
│ ├── ops.cpp
│ ├── ops_cuda.cu
│ ├── pybind.cpp
└── tensorrt
├── trt_cuda_helper.cuh
├── trt_plugin_helper.hpp
├── trt_plugin.hpp
├── trt_serialize.hpp
├── ...
├── trt_ops.hpp
└── plugins
├── trt_cuda_helper.cu
├── trt_plugin.cpp
├── ...
├── trt_ops.cpp
└── trt_ops_kernel.cu
After refactored, it is organized as follows.
.
├── common
│ ├── box_iou_rotated_utils.hpp
│ ├── parrots_cpp_helper.hpp
│ ├── parrots_cuda_helper.hpp
│ ├── pytorch_cpp_helper.hpp
│ ├── pytorch_cuda_helper.hpp
│ └── cuda
│ ├── common_cuda_helper.hpp
│ ├── parrots_cudawarpfunction.cuh
│ ├── ...
│ └── ops_cuda_kernel.cuh
├── onnxruntime
│ ├── onnxruntime_register.h
│ ├── onnxruntime_session_options_config_keys.h
│ ├── ort_mmcv_utils.h
│ ├── ...
│ ├── onnx_ops.h
│ └── cpu
│ ├── onnxruntime_register.cpp
│ ├── ...
│ └── onnx_ops_impl.cpp
├── parrots
│ ├── ...
│ ├── ops.cpp
│ ├── ops_parrots.cpp
│ └── ops_pytorch.h
├── pytorch
│ ├── info.cpp
│ ├── pybind.cpp
│ ├── ...
│ ├── ops.cpp
│ └── cuda
│ ├── ...
│ └── ops_cuda.cu
└── tensorrt
├── trt_cuda_helper.cuh
├── trt_plugin_helper.hpp
├── trt_plugin.hpp
├── trt_serialize.hpp
├── ...
├── trt_ops.hpp
└── plugins
├── trt_cuda_helper.cu
├── trt_plugin.cpp
├── ...
├── trt_ops.cpp
└── trt_ops_kernel.cu
Frequently Asked Questions¶
We list some common troubles faced by many users and their corresponding solutions here. Feel free to enrich the list if you find any frequent issues and have ways to help others to solve them.
Installation¶
KeyError: “xxx: ‘yyy is not in the zzz registry’”
The registry mechanism will be triggered only when the file of the module is imported. So you need to import that file somewhere. More details can be found at KeyError: “MaskRCNN: ‘RefineRoIHead is not in the models registry’”.
“No module named ‘mmcv.ops’”; “No module named ‘mmcv._ext’”
Uninstall existing mmcv in the environment using
pip uninstall mmcv
Install mmcv-full following the installation instruction or Build MMCV from source
“invalid device function” or “no kernel image is available for execution”
Check the CUDA compute capability of you GPU
Run
python mmdet/utils/collect_env.py
to check whether PyTorch, torchvision, and MMCV are built for the correct GPU architecture. You may need to setTORCH_CUDA_ARCH_LIST
to reinstall MMCV. The compatibility issue could happen when using old GPUS, e.g., Tesla K80 (3.7) on colab.Check whether the running environment is the same as that when mmcv/mmdet is compiled. For example, you may compile mmcv using CUDA 10.0 bug run it on CUDA9.0 environments
“undefined symbol” or “cannot open xxx.so”
If those symbols are CUDA/C++ symbols (e.g., libcudart.so or GLIBCXX), check whether the CUDA/GCC runtimes are the same as those used for compiling mmcv
If those symbols are Pytorch symbols (e.g., symbols containing caffe, aten, and TH), check whether the Pytorch version is the same as that used for compiling mmcv
Run
python mmdet/utils/collect_env.py
to check whether PyTorch, torchvision, and MMCV are built by and running on the same environment
“RuntimeError: CUDA error: invalid configuration argument”
This error may be caused by the poor performance of GPU. Try to decrease the value of THREADS_PER_BLOCK and recompile mmcv.
“RuntimeError: nms is not compiled with GPU support”
This error is because your CUDA environment is not installed correctly. You may try to re-install your CUDA environment and then delete the build/ folder before re-compile mmcv.
“Segmentation fault”
Check your GCC version and use GCC >= 5.4. This usually caused by the incompatibility between PyTorch and the environment (e.g., GCC < 4.9 for PyTorch). We also recommend the users to avoid using GCC 5.5 because many feedbacks report that GCC 5.5 will cause “segmentation fault” and simply changing it to GCC 5.4 could solve the problem
Check whether PyTorch is correctly installed and could use CUDA op, e.g. type the following command in your terminal and see whether they could correctly output results
python -c 'import torch; print(torch.cuda.is_available())'
If PyTorch is correctly installed, check whether MMCV is correctly installed. If MMCV is correctly installed, then there will be no issue of the command
python -c 'import mmcv; import mmcv.ops'
If MMCV and PyTorch are correctly installed, you can use
ipdb
to set breakpoints or directly addprint
to debug and see which part leads thesegmentation fault
“libtorch_cuda_cu.so: cannot open shared object file”
mmcv-full
depends on the share object but it can not be found. We can check whether the object exists in~/miniconda3/envs/{environment-name}/lib/python3.7/site-packages/torch/lib
or try to re-install the PyTorch.“fatal error C1189: #error: – unsupported Microsoft Visual Studio version!”
If you are building mmcv-full on Windows and the version of CUDA is 9.2, you will probably encounter the error
"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\include\crt/host_config.h(133): fatal error C1189: #error: -- unsupported Microsoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!"
, in which case you can use a lower version of Microsoft Visual Studio like vs2017.“error: member “torch::jit::detail::ModulePolicy::all_slots” may not be initialized”
If your version of PyTorch is 1.5.0 and you are building mmcv-full on Windows, you will probably encounter the error
- torch/csrc/jit/api/module.h(474): error: member "torch::jit::detail::ModulePolicy::all_slots" may not be initialized
. The way to solve the error is to replace all thestatic constexpr bool all_slots = false;
withstatic bool all_slots = false;
at this filehttps://github.com/pytorch/pytorch/blob/v1.5.0/torch/csrc/jit/api/module.h
. More details can be found at member “torch::jit::detail::AttributePolicy::all_slots” may not be initialized.“error: a member with an in-class initializer must be const”
If your version of PyTorch is 1.6.0 and you are building mmcv-full on Windows, you will probably encounter the error
"- torch/include\torch/csrc/jit/api/module.h(483): error: a member with an in-class initializer must be const"
. The way to solve the error is to replace all theCONSTEXPR_EXCEPT_WIN_CUDA
withconst
attorch/include\torch/csrc/jit/api/module.h
. More details can be found at Ninja: build stopped: subcommand failed.“error: member “torch::jit::ProfileOptionalOp::Kind” may not be initialized”
If your version of PyTorch is 1.7.0 and you are building mmcv-full on Windows, you will probably encounter the error
torch/include\torch/csrc/jit/ir/ir.h(1347): error: member "torch::jit::ProfileOptionalOp::Kind" may not be initialized
. The way to solve the error needs to modify several local files of PyTorch:delete
static constexpr Symbol Kind = ::c10::prim::profile;
andtatic constexpr Symbol Kind = ::c10::prim::profile_optional;
attorch/include\torch/csrc/jit/ir/ir.h
replace
explicit operator type&() { return *(this->value); }
withexplicit operator type&() { return *((type*)this->value); }
attorch\include\pybind11\cast.h
replace all the
CONSTEXPR_EXCEPT_WIN_CUDA
withconst
attorch/include\torch/csrc/jit/api/module.h
More details can be found at Ensure default extra_compile_args.
Compatibility issue between MMCV and MMDetection; “ConvWS is already registered in conv layer”
Please install the correct version of MMCV for the version of your MMDetection following the installation instruction.
Usage¶
“RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one”
This error indicates that your module has parameters that were not used in producing loss. This phenomenon may be caused by running different branches in your code in DDP mode. More datails at Expected to have finished reduction in the prior iteration before starting a new one.
You can set
find_unused_parameters = True
in the config to solve the above problems or find those unused parameters manually
“RuntimeError: Trying to backward through the graph a second time”
GradientCumulativeOptimizerHook
andOptimizerHook
are both set which causes theloss.backward()
to be called twice soRuntimeError
was raised. We can only use one of these. More datails at Trying to backward through the graph a second time.
Contributing to OpenMMLab¶
Welcome to the MMCV community, we are committed to building a cutting-edge computer vision foundational library and all kinds of contributions are welcomed, including but not limited to
Fix bug
You can directly post a Pull Request to fix typo in code or documents
The steps to fix the bug of code implementation are as follows.
If the modification involve significant changes, you should create an issue first and describe the error information and how to trigger the bug. Other developers will discuss with you and propose an proper solution.
Posting a pull request after fixing the bug and adding corresponding unit test.
New Feature or Enhancement
If the modification involve significant changes, you should create an issue to discuss with our developers to propose an proper design.
Post a Pull Request after implementing the new feature or enhancement and add corresponding unit test.
Document
You can directly post a pull request to fix documents. If you want to add a document, you should first create an issue to check if it is reasonable.
Pull Request Workflow¶
If you’re not familiar with Pull Request, don’t worry! The following guidance will tell you how to create a Pull Request step by step. If you want to dive into the develop mode of Pull Request, you can refer to the official documents
1. Fork and clone¶
If you are posting a pull request for the first time, you should fork the OpenMMLab repositories by clicking the Fork button in the top right corner of the GitHub page, and the forked repositories will appear under your GitHub profile.

Then, you can clone the repositories to local:
git clone git@github.com:{username}/mmcv.git
After that, you should ddd official repository as the upstream repository
git remote add upstream git@github.com:open-mmlab/mmcv
Check whether remote repository has been added successfully by git remote -v
origin git@github.com:{username}/mmcv.git (fetch)
origin git@github.com:{username}/mmcv.git (push)
upstream git@github.com:open-mmlab/mmcv (fetch)
upstream git@github.com:open-mmlab/mmcv (push)
注解
Here’s a brief introduction to origin and upstream. When we use “git clone”, we create an “origin” remote by default, which points to the repository cloned from. As for “upstream”, we add it ourselves to point to the target repository. Of course, if you don’t like the name “upstream”, you could name it as you wish. Usually, we’ll push the code to “origin”. If the pushed code conflicts with the latest code in official(“upstream”), we should pull the latest code from upstream to resolve the conflicts, and then push to “origin” again. The posted Pull Request will be updated automatically.
2. Configure pre-commit¶
You should configure pre-commit in the local development environment to make sure the code style matches that of OpenMMLab. Note: The following code should be executed under the MMCV directory.
pip install -U pre-commit
pre-commit install
Check that pre-commit is configured successfully, and install the hooks defined in .pre-commit-config.yaml
.
pre-commit run --all-files


注解
Chinese users may fail to download the pre-commit hooks due to the network issue. In this case, you could download these hooks from gitee by setting the .pre-commit-config-zh-cn.yaml
pre-commit install -c .pre-commit-config-zh-cn.yaml pre-commit run –all-files -c .pre-commit-config-zh-cn.yaml
If the installation process is interrupted, you can repeatedly run pre-commit run ...
to continue the installation.
If the code does not conform to the code style specification, pre-commit will raise a warning and fixes some of the errors automatically.

If we want to commit our code bypassing the pre-commit hook, we can use the --no-verify
option(only for temporarily commit.
git commit -m "xxx" --no-verify
3. Create a development branch¶
After configuring the pre-commit, we should create a branch based on the main branch to develop the new feature or fix the bug. The proposed branch name is username/pr_name
git checkout -b yhc/refactor_contributing_doc
In subsequent development, if the main branch of the local repository is behind the main branch of “upstream”, we need to pull the upstream for synchronization, and then execute the above command:
git pull upstream main
4. Commit the code and pass the unit test¶
MMCV introduces mypy to do static type checking to increase the robustness of the code. Therefore, we need to add Type Hints to our code and pass the mypy check. If you are not familiar with Type Hints, you can refer to this tutorial.
The committed code should pass through the unit test
# Pass all unit tests pytest tests # Pass the unit test of runner pytest tests/test_runner/test_runner.py
If the unit test fails for lack of dependencies, you can install the dependencies referring to the guidance
If the documents are modified/added, we should check the rendering result referring to guidance
5. Push the code to remote¶
We could push the local commits to remote after passing through the check of unit test and pre-commit. You can associate the local branch with remote branch by adding -u
option.
git push -u origin {branch_name}
This will allow you to use the git push
command to push code directly next time, without having to specify a branch or the remote repository.
6. Create a Pull Request¶
(1) Create a pull request in GitHub’s Pull request interface

(2) Modify the PR description according to the guidelines so that other developers can better understand your changes

Find more details about Pull Request description in pull request guidelines.
note
(a) The Pull Request description should contain the reason for the change, the content of the change, and the impact of the change, and be associated with the relevant Issue (see documentation
(b) If it is your first contribution, please sign the CLA

(c) Check whether the Pull Request pass through the CI

MMCV will run unit test for the posted Pull Request on different platforms (Linux, Window, Mac), based on different versions of Python, PyTorch, CUDA to make sure the code is correct. We can see the specific test information by clicking Details
in the above image so that we can modify the code.
(3) If the Pull Request passes the CI, then you can wait for the review from other developers. You’ll modify the code based on the reviewer’s comments, and repeat the steps 4-5 until all reviewers approve it. Then, we will merge it ASAP.

7. Resolve conflicts¶
If your local branch conflicts with the latest main branch of “upstream”, you’ll need to resolove them. There are two ways to do this:
git fetch --all --prune
git rebase upstream/main
or
git fetch --all --prune
git merge upstream/main
If you are very good at handling conflicts, then you can use rebase to resolve conflicts, as this will keep your commit logs tidy. If you are not familiar with rebase
, then you can use merge
to resolve conflicts.
Guidance¶
Unit test¶
If you cannot run the unit test of some modules for lacking of some dependencies, such as video module, you can try to install the following dependencies:
# Linux
sudo apt-get update -y
sudo apt-get install -y libturbojpeg
sudo apt-get install -y ffmpeg
# Windows
conda install ffmpeg
We should also make sure the committed code will not decrease the coverage of unit test, we could run the following command to check the coverage of unit test:
python -m coverage run -m pytest /path/to/test_file
python -m coverage html
# check file in htmlcov/index.html
Document rendering¶
If the documents are modified/added, we should check the rendering result. We could install the dependencies and run the following command to render the documents and check the results:
pip install -r requirements/docs.txt
cd docs/zh_cn/
# or docs/en
make html
# check file in ./docs/zh_cn/_build/html/index.html
Code style¶
Python¶
We adopt PEP8 as the preferred code style.
We use the following tools for linting and formatting:
flake8: A wrapper around some linter tools.
isort: A Python utility to sort imports.
yapf: A formatter for Python files.
codespell: A Python utility to fix common misspellings in text files.
mdformat: Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files.
docformatter: A formatter to format docstring.
Style configurations of yapf and isort can be found in setup.cfg.
We use pre-commit hook that checks and formats for flake8
, yapf
, isort
, trailing whitespaces
, markdown files
,
fixes end-of-files
, double-quoted-strings
, python-encoding-pragma
, mixed-line-ending
, sorts requirments.txt
automatically on every commit.
The config for a pre-commit hook is stored in .pre-commit-config.
C++ and CUDA¶
We follow the Google C++ Style Guide.
PR Specs¶
Use pre-commit hook to avoid issues of code style
One short-time branch should be matched with only one PR
Accomplish a detailed change in one PR. Avoid large PR
Bad: Support Faster R-CNN
Acceptable: Add a box head to Faster R-CNN
Good: Add a parameter to box head to support custom conv-layer number
Provide clear and significant commit message
Provide clear and meaningful PR description
Task name should be clarified in title. The general format is: [Prefix] Short description of the PR (Suffix)
Prefix: add new feature [Feature], fix bug [Fix], related to documents [Docs], in developing [WIP] (which will not be reviewed temporarily)
Introduce main changes, results and influences on other modules in short description
Associate related issues and pull requests with a milestone
Pull Request (PR)¶
Content has been migrated to contributing guidance.
mmcv.image¶
mmcv.image
IO¶
Read an image from bytes. |
|
Read an image. |
|
Write image to file. |
|
Select a backend for image decoding. |
Color Space¶
Convert a BGR image to grayscale image. |
|
Convert a BGR image to HLS |
|
Convert a BGR image to HSV |
|
Convert a BGR image to RGB |
|
Convert a BGR image to YCbCr image. |
|
Convert a grayscale image to BGR image. |
|
Convert a grayscale image to RGB image. |
|
Convert a HLS image to BGR |
|
Convert a HSV image to BGR |
|
Convert an image from the src colorspace to dst colorspace. |
|
Convert a RGB image to BGR |
|
Convert a RGB image to grayscale image. |
|
Convert a RGB image to YCbCr image. |
|
Convert a YCbCr image to BGR image. |
|
Convert a YCbCr image to RGB image. |
Geometric¶
Randomly cut out a rectangle from the original img. |
|
Crop image patches. |
|
Flip an image horizontally or vertically. |
|
Pad the given image to a certain shape or pad on all sides with specified padding mode and padding value. |
|
Pad an image to ensure each edge to be multiple to some number. |
|
Resize image while keeping the aspect ratio. |
|
Resize image to a given size. |
|
Resize image to the same size of a given image. |
|
Resize image according to a given size or scale factor and then rounds up the the resized or rescaled image size to the nearest value that can be divided by the divisor. |
|
Rotate an image. |
|
Shear an image. |
|
Translate an image. |
|
Calculate the new size to be rescaled to. |
Photometric¶
Adjust image brightness. |
|
It blends the source image and its gray image: |
|
Adjust image contrast. |
|
Adjust hue of an image. |
|
AlexNet-style PCA jitter. |
|
Adjust image sharpness. |
|
Auto adjust image contrast. |
|
Use CLAHE method to process the image. |
|
Equalize the image histogram. |
|
Invert (negate) an image. |
|
Normalize an image with mean and std. |
|
Transform array by look-up table. |
|
Posterize an image (reduce the number of bits for each color channel) |
|
Solarize an image (invert all pixel values above a threshold) |
Miscellaneous¶
Convert tensor to 3-channel images or 1-channel gray images. |
mmcv.video¶
mmcv.video
IO¶
Video class with similar usage to a list object. |
|
Read the frame images from a directory and join them as a video. |
Optical Flow¶
Recover from quantized flow. |
|
Read dense optical flow from bytes. |
|
Use flow to warp img. |
|
Read an optical flow map. |
|
Write optical flow to file. |
|
Quantize flow to [0, 255]. |
|
Read the optical flow in KITTI datasets from bytes. |
Video Processing¶
Concatenate multiple videos into a single one. |
|
Convert a video with ffmpeg. |
|
Cut a clip from a video. |
|
Resize a video. |
mmcv.visualization¶
mmcv.visualization
Image¶
Show an image. |
|
Draw bboxes on an image. |
|
Draw bboxes and class labels (with scores) on an image. |
Optical Flow¶
Convert flow map to RGB image. |
|
Show optical flow. |
|
Build a color wheel. |
mmcv.cnn¶
mmcv.cnn
Module¶
ContextBlock module in GCNet. |
|
AWS (Adaptive Weight Standardization) |
|
A conv block that bundles conv/norm/activation layers. |
|
Depthwise separable convolution module. |
|
GeneralizedAttention module. |
|
Hard Sigmoid Module. |
|
Hard Swish Module. |
|
1D Non-local module. |
|
2D Non-local module. |
|
3D Non-local module. |
|
A learnable scale parameter. |
|
Swish Module. |
|
Enable Conv2d with receptive field searching ability. |
Build Function¶
Build activation layer. |
|
Build convolution layer. |
|
Build normalization layer. |
|
Build padding layer. |
|
Build plugin layer. |
|
Build upsample layer. |
Miscellaneous¶
Recursively fuse conv and bn in a module. |
|
Check if a layer is a normalization layer. |
|
Get complexity information of a model. |
mmcv.ops¶
Border align pooling layer. |
|
CARAFE: Content-Aware ReAssembly of FEatures |
|
A unified package of CARAFE upsampler that contains: 1) channel compressor 2) content encoder 3) CARAFE op. |
|
alias of |
|
alias of |
|
Corner Pooling. |
|
Correlation operator |
|
Criss-Cross Attention Module. |
|
Deformable 2D convolution. |
|
A Deformable Conv Encapsulation that acts as normal Conv layers. |
|
Scatters points into voxels, used in the voxel encoder with dynamic voxelization. |
|
Fused bias leaky ReLU. |
|
Group xyz with feature. |
|
alias of |
|
A MaskedConv2d which inherits the official Conv2d. |
|
alias of |
|
A ModulatedDeformable Conv Encapsulation that acts as normal Conv layers. |
|
An attention module used in Deformable-Detr. |
|
Points sampling. |
|
The operation of precision RoI pooling. |
|
Groups points with a ball query of radius. |
|
Rotation-invariant RoI align pooling layer for rotated proposals. |
|
RoI align pooling layer. |
|
RoI align pooling layer for rotated proposals. |
|
Encode the geometry-specific features of each 3D proposal. |
|
Encode the geometry-specific features of each 3D proposal. |
|
SAC (Switchable Atrous Convolution) |
|
place holder, All module subclass from this will take sptensor in SparseSequential. |
|
A sequential container. |
|
Synchronized Batch Normalization. |
|
Temporal Interlace Shift. |
|
Convert kitti points(N, >=3) to voxels. |
Performs non-maximum suppression in a batched fashion. |
|
Calculate overlap between two set of bboxes. |
|
Return intersection-over-union (Jaccard index) of boxes. |
|
Calculate boxes 3D IoU. |
|
Calculate boxes IoU in the Bird’s Eye View. |
|
Calculate boxes BEV overlap. |
|
Expand kernel contours so that foreground pixels are assigned into instances. |
|
Return generalized intersection-over-union (Jaccard index) between point sets and polygons. |
|
Return intersection-over-union (Jaccard index) between point sets and polygons. |
|
Calculate differentiable iou of rotated 2d boxes. |
|
Calculate differentiable iou of rotated 3d boxes. |
|
Fused bias leaky ReLU function. |
|
Find the smallest polygons that surrounds all points in the point sets. |
|
Dispatch to either CPU or GPU NMS implementations. |
|
3D NMS function GPU implementation (for BEV boxes). |
|
Normal 3D NMS function GPU implementation. |
|
NMS function GPU implementation (for BEV boxes). |
|
Matched dets into different groups by NMS. |
|
Normal NMS function GPU implementation (for BEV boxes). |
|
Performs non-maximum suppression (NMS) on the rotated boxes according to their intersection-over-union (IoU). |
|
Group pixels into text instances, which is widely used text detection methods. |
|
A wrapper around |
|
Find all boxes in which each point is (CUDA). |
|
Find all boxes in which each point is (CPU). |
|
Find the box in which each point is (CUDA). |
|
Judging whether points are inside polygons, which is used in the ATSS assignment for the rotated boxes. |
|
Convert roi based relative point coordinates to image based absolute point coordinates. |
|
pytorch edition of tensorflow scatter_nd. |
|
Dispatch to only CPU Soft NMS implementations. |
|
Pad, upsample, filter, and downsample a batch of 2D images. |
|
mmcv.transforms¶
Base class for all transformations. |
|
Test-time augmentation transform. |
Loading¶
Load and process the |
|
Load an image from file. |
Processing¶
Crop the center of the image, segmentation masks, bounding boxes and key points. |
|
Test-time augmentation with multiple scales and flipping. |
|
Normalize the image. |
|
Pad the image & segmentation map. |
|
Resize images & bbox & mask from a list of multiple scales. |
|
Flip the image & bbox & keypoints & segmentation map. |
|
Randomly convert image to grayscale with a probability. |
|
Random resize images & bbox & keypoints. |
|
Resize images & bbox & seg & keypoints. |
|
Convert some results to |
|
Convert image to |
Wrapper¶
Compose multiple transforms sequentially. |
|
A transform wrapper to map and reorganize the input/output of the wrapped transforms (or sub-pipeline). |
|
Apply transforms randomly with a given probability. |
|
Process data with a randomly chosen transform from given candidates. |
|
A transform wrapper to apply the wrapped transforms to multiple data items. |
mmcv.arraymisc¶
Quantize an array of (-inf, inf) to [0, levels-1]. |
|
Dequantize an array. |
mmcv.utils¶
bool(x) -> bool |
|
bool(x) -> bool |
|
bool(x) -> bool |
|
Collect the information of the running environments. |
|