diff --git a/.dev_scripts/benchmark_regression/1-benchmark_valid.py b/.dev_scripts/benchmark_regression/1-benchmark_valid.py index 7324913c..3fbf16e7 100644 --- a/.dev_scripts/benchmark_regression/1-benchmark_valid.py +++ b/.dev_scripts/benchmark_regression/1-benchmark_valid.py @@ -7,7 +7,7 @@ from typing import OrderedDict import numpy as np import torch -from mmengine.config import Config +from mmcv import Config from mmcv.parallel import collate, scatter from modelindex.load_model_index import load from rich.console import Console diff --git a/docs/en/tutorials/MMClassification_python.ipynb b/docs/en/tutorials/MMClassification_python.ipynb index 6fe1064f..d0acfa58 100755 --- a/docs/en/tutorials/MMClassification_python.ipynb +++ b/docs/en/tutorials/MMClassification_python.ipynb @@ -945,7 +945,7 @@ "text/plain": [ "(mmcls.models.classifiers.image.ImageClassifier,\n", " mmcls.models.classifiers.base.BaseClassifier,\n", - " mmengine.runner.base_module.BaseModule,\n", + " mmcv.runner.base_module.BaseModule,\n", " torch.nn.modules.module.Module,\n", " object)" ] @@ -1113,7 +1113,7 @@ }, "source": [ "# Load the base config file\n", - "from mmengine.config import Config\n", + "from mmcv import Config\n", "cfg = Config.fromfile('configs/mobilenet_v2/mobilenet-v2_8xb32_in1k.py')\n", "\n", "# Modify the number of classes in the head.\n", diff --git a/docs/zh_CN/tutorials/MMClassification_python_cn.ipynb b/docs/zh_CN/tutorials/MMClassification_python_cn.ipynb index 52477da0..adbbeeb3 100755 --- a/docs/zh_CN/tutorials/MMClassification_python_cn.ipynb +++ b/docs/zh_CN/tutorials/MMClassification_python_cn.ipynb @@ -947,7 +947,7 @@ "text/plain": [ "(mmcls.models.classifiers.image.ImageClassifier,\n", " mmcls.models.classifiers.base.BaseClassifier,\n", - " mmengine.runner.base_module.BaseModule,\n", + " mmcv.runner.base_module.BaseModule,\n", " torch.nn.modules.module.Module,\n", " object)" ] @@ -1115,7 +1115,7 @@ }, "source": [ "# 载入已经存在的配置文件\n", - "from mmengine.config import Config\n", + "from mmcv import Config\n", "cfg = Config.fromfile('configs/mobilenet_v2/mobilenet-v2_8xb32_in1k.py')\n", "\n", "# 修改模型分类头中的类别数目\n", diff --git a/mmcls/apis/inference.py b/mmcls/apis/inference.py index 1e45c1db..09e00418 100644 --- a/mmcls/apis/inference.py +++ b/mmcls/apis/inference.py @@ -5,7 +5,7 @@ import mmcv import numpy as np import torch from mmcv.parallel import collate, scatter -from mmengine.runner import load_checkpoint +from mmcv.runner import load_checkpoint from mmcls.datasets.pipelines import Compose from mmcls.models import build_classifier diff --git a/mmcls/apis/test.py b/mmcls/apis/test.py index 46e315bd..3b20c809 100644 --- a/mmcls/apis/test.py +++ b/mmcls/apis/test.py @@ -10,7 +10,7 @@ import numpy as np import torch import torch.distributed as dist from mmcv.image import tensor2imgs -from mmengine.dist.utils import get_dist_info +from mmcv.runner import get_dist_info def single_gpu_test(model, diff --git a/mmcls/apis/train.py b/mmcls/apis/train.py index de203c7f..aa263d2d 100644 --- a/mmcls/apis/train.py +++ b/mmcls/apis/train.py @@ -6,9 +6,9 @@ import numpy as np import torch import torch.distributed as dist from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmengine.runner import (DistSamplerSeedHook, Fp16OptimizerHook, +from mmcv.runner import (DistSamplerSeedHook, Fp16OptimizerHook, build_optimizer, build_runner, get_dist_info) -from mmengine.runner.hooks import DistEvalHook, EvalHook +from mmcv.runner.hooks import DistEvalHook, EvalHook from mmcls.core import DistOptimizerHook from mmcls.datasets import build_dataloader, build_dataset @@ -89,7 +89,7 @@ def train_model(model, distributed (bool): Whether to train the model in a distributed environment. Defaults to False. validate (bool): Whether to do validation with - :obj:`mmengine.runner.EvalHook`. Defaults to False. + :obj:`mmcv.runner.EvalHook`. Defaults to False. timestamp (str, optional): The timestamp string to auto generate the name of log files. Defaults to None. device (str, optional): TODO diff --git a/mmcls/core/hook/class_num_check_hook.py b/mmcls/core/hook/class_num_check_hook.py index b45404e5..52c2c9a5 100644 --- a/mmcls/core/hook/class_num_check_hook.py +++ b/mmcls/core/hook/class_num_check_hook.py @@ -1,6 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved -from mmengine.runner import IterBasedRunner -from mmengine.runner.hooks import HOOKS, Hook +from mmcv.runner import IterBasedRunner +from mmcv.runner.hooks import HOOKS, Hook from mmcv.utils import is_seq_of diff --git a/mmcls/core/hook/lr_updater.py b/mmcls/core/hook/lr_updater.py index 122fc2be..021f66b5 100644 --- a/mmcls/core/hook/lr_updater.py +++ b/mmcls/core/hook/lr_updater.py @@ -1,7 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. from math import cos, pi -from mmengine.runner.hooks import HOOKS, LrUpdaterHook +from mmcv.runner.hooks import HOOKS, LrUpdaterHook @HOOKS.register_module() diff --git a/mmcls/core/hook/precise_bn_hook.py b/mmcls/core/hook/precise_bn_hook.py index 831fa47f..384fd806 100644 --- a/mmcls/core/hook/precise_bn_hook.py +++ b/mmcls/core/hook/precise_bn_hook.py @@ -9,8 +9,8 @@ from typing import List, Optional import mmcv import torch import torch.nn as nn -from mmengine.runner import EpochBasedRunner, get_dist_info -from mmengine.runner.hooks import HOOKS, Hook +from mmcv.runner import EpochBasedRunner, get_dist_info +from mmcv.runner.hooks import HOOKS, Hook from mmcv.utils import print_log from torch.functional import Tensor from torch.nn import GroupNorm diff --git a/mmcls/core/optimizers/lamb.py b/mmcls/core/optimizers/lamb.py index 6a7bce58..c65fbae2 100644 --- a/mmcls/core/optimizers/lamb.py +++ b/mmcls/core/optimizers/lamb.py @@ -59,7 +59,7 @@ Modifications Copyright 2021 Ross Wightman import math import torch -from mmengine.runner import OPTIMIZERS +from mmcv.runner import OPTIMIZERS from torch.optim import Optimizer diff --git a/mmcls/core/utils/dist_utils.py b/mmcls/core/utils/dist_utils.py index 6209705e..8912cea4 100644 --- a/mmcls/core/utils/dist_utils.py +++ b/mmcls/core/utils/dist_utils.py @@ -4,7 +4,7 @@ from collections import OrderedDict import numpy as np import torch import torch.distributed as dist -from mmengine.runner import OptimizerHook, get_dist_info +from mmcv.runner import OptimizerHook, get_dist_info from torch._utils import (_flatten_dense_tensors, _take_tensors, _unflatten_dense_tensors) diff --git a/mmcls/datasets/builder.py b/mmcls/datasets/builder.py index 81fec8a7..1c74af9c 100644 --- a/mmcls/datasets/builder.py +++ b/mmcls/datasets/builder.py @@ -7,7 +7,7 @@ from functools import partial import numpy as np import torch from mmcv.parallel import collate -from mmengine.dist.utils import get_dist_info +from mmcv.runner import get_dist_info from mmcv.utils import Registry, build_from_cfg, digit_version from torch.utils.data import DataLoader diff --git a/mmcls/datasets/cifar.py b/mmcls/datasets/cifar.py index 313ec9b4..453b8d9d 100644 --- a/mmcls/datasets/cifar.py +++ b/mmcls/datasets/cifar.py @@ -5,7 +5,7 @@ import pickle import numpy as np import torch.distributed as dist -from mmengine.dist.utils import get_dist_info +from mmcv.runner import get_dist_info from .base_dataset import BaseDataset from .builder import DATASETS diff --git a/mmcls/datasets/mnist.py b/mmcls/datasets/mnist.py index a8813783..4065e0d5 100644 --- a/mmcls/datasets/mnist.py +++ b/mmcls/datasets/mnist.py @@ -6,7 +6,7 @@ import os.path as osp import numpy as np import torch import torch.distributed as dist -from mmengine.dist.utils import get_dist_info, master_only +from mmcv.runner import get_dist_info, master_only from .base_dataset import BaseDataset from .builder import DATASETS diff --git a/mmcls/datasets/samplers/repeat_aug.py b/mmcls/datasets/samplers/repeat_aug.py index 38c9b6d4..5de096bd 100644 --- a/mmcls/datasets/samplers/repeat_aug.py +++ b/mmcls/datasets/samplers/repeat_aug.py @@ -1,7 +1,7 @@ import math import torch -from mmengine.dist.utils import get_dist_info +from mmcv.runner import get_dist_info from torch.utils.data import Sampler from mmcls.core.utils import sync_random_seed diff --git a/mmcls/models/backbones/base_backbone.py b/mmcls/models/backbones/base_backbone.py index 2ce4a86e..c1050fab 100644 --- a/mmcls/models/backbones/base_backbone.py +++ b/mmcls/models/backbones/base_backbone.py @@ -1,7 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. from abc import ABCMeta, abstractmethod -from mmengine.runner import BaseModule +from mmcv.runner import BaseModule class BaseBackbone(BaseModule, metaclass=ABCMeta): diff --git a/mmcls/models/backbones/convnext.py b/mmcls/models/backbones/convnext.py index 8764f7e2..1e0a3e9c 100644 --- a/mmcls/models/backbones/convnext.py +++ b/mmcls/models/backbones/convnext.py @@ -8,8 +8,8 @@ import torch.nn as nn import torch.nn.functional as F from mmcv.cnn.bricks import (NORM_LAYERS, DropPath, build_activation_layer, build_norm_layer) -from mmengine.runner import BaseModule -from mmengine.runner.base_module import ModuleList, Sequential +from mmcv.runner import BaseModule +from mmcv.runner.base_module import ModuleList, Sequential from ..builder import BACKBONES from .base_backbone import BaseBackbone diff --git a/mmcls/models/backbones/cspnet.py b/mmcls/models/backbones/cspnet.py index 610635b3..70aff4c8 100644 --- a/mmcls/models/backbones/cspnet.py +++ b/mmcls/models/backbones/cspnet.py @@ -6,7 +6,7 @@ import torch import torch.nn as nn from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule from mmcv.cnn.bricks import DropPath -from mmengine.runner import BaseModule, Sequential +from mmcv.runner import BaseModule, Sequential from torch.nn.modules.batchnorm import _BatchNorm from ..builder import BACKBONES diff --git a/mmcls/models/backbones/efficientnet.py b/mmcls/models/backbones/efficientnet.py index 15b42063..ede2c184 100644 --- a/mmcls/models/backbones/efficientnet.py +++ b/mmcls/models/backbones/efficientnet.py @@ -7,7 +7,7 @@ import torch import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn.bricks import ConvModule, DropPath -from mmengine.runner import BaseModule, Sequential +from mmcv.runner import BaseModule, Sequential from mmcls.models.backbones.base_backbone import BaseBackbone from mmcls.models.utils import InvertedResidual, SELayer, make_divisible diff --git a/mmcls/models/backbones/hrnet.py b/mmcls/models/backbones/hrnet.py index 9618e253..57baf0ca 100644 --- a/mmcls/models/backbones/hrnet.py +++ b/mmcls/models/backbones/hrnet.py @@ -1,7 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.cnn import build_conv_layer, build_norm_layer -from mmengine.runner import BaseModule, ModuleList, Sequential +from mmcv.runner import BaseModule, ModuleList, Sequential from torch.nn.modules.batchnorm import _BatchNorm from ..builder import BACKBONES diff --git a/mmcls/models/backbones/mlp_mixer.py b/mmcls/models/backbones/mlp_mixer.py index a54aec87..13171a4b 100644 --- a/mmcls/models/backbones/mlp_mixer.py +++ b/mmcls/models/backbones/mlp_mixer.py @@ -4,7 +4,7 @@ from typing import Sequence import torch.nn as nn from mmcv.cnn import build_norm_layer from mmcv.cnn.bricks.transformer import FFN, PatchEmbed -from mmengine.runner.base_module import BaseModule, ModuleList +from mmcv.runner.base_module import BaseModule, ModuleList from ..builder import BACKBONES from ..utils import to_2tuple diff --git a/mmcls/models/backbones/mobilenet_v2.py b/mmcls/models/backbones/mobilenet_v2.py index 674dda3f..8f171eda 100644 --- a/mmcls/models/backbones/mobilenet_v2.py +++ b/mmcls/models/backbones/mobilenet_v2.py @@ -2,7 +2,7 @@ import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import ConvModule -from mmengine.runner import BaseModule +from mmcv.runner import BaseModule from torch.nn.modules.batchnorm import _BatchNorm from mmcls.models.utils import make_divisible diff --git a/mmcls/models/backbones/poolformer.py b/mmcls/models/backbones/poolformer.py index ab403bcd..e3fc4e1c 100644 --- a/mmcls/models/backbones/poolformer.py +++ b/mmcls/models/backbones/poolformer.py @@ -4,7 +4,7 @@ from typing import Sequence import torch import torch.nn as nn from mmcv.cnn.bricks import DropPath, build_activation_layer, build_norm_layer -from mmengine.runner import BaseModule +from mmcv.runner import BaseModule from ..builder import BACKBONES from .base_backbone import BaseBackbone diff --git a/mmcls/models/backbones/repmlp.py b/mmcls/models/backbones/repmlp.py index 31c7ab7f..9e6e2ed9 100644 --- a/mmcls/models/backbones/repmlp.py +++ b/mmcls/models/backbones/repmlp.py @@ -6,7 +6,7 @@ import torch.nn.functional as F from mmcv.cnn import (ConvModule, build_activation_layer, build_conv_layer, build_norm_layer) from mmcv.cnn.bricks.transformer import PatchEmbed as _PatchEmbed -from mmengine.runner import BaseModule, ModuleList, Sequential +from mmcv.runner import BaseModule, ModuleList, Sequential from mmcls.models.builder import BACKBONES from mmcls.models.utils import SELayer, to_2tuple diff --git a/mmcls/models/backbones/repvgg.py b/mmcls/models/backbones/repvgg.py index 3805e725..0186e623 100644 --- a/mmcls/models/backbones/repvgg.py +++ b/mmcls/models/backbones/repvgg.py @@ -3,7 +3,7 @@ import torch import torch.nn.functional as F import torch.utils.checkpoint as cp from mmcv.cnn import build_activation_layer, build_conv_layer, build_norm_layer -from mmengine.runner import BaseModule, Sequential +from mmcv.runner import BaseModule, Sequential from mmcv.utils.parrots_wrapper import _BatchNorm from ..builder import BACKBONES @@ -208,7 +208,7 @@ class RepVGGBlock(BaseModule): """Fuse the parameters in a branch with a conv and bn. Args: - branch (mmengine.runner.Sequential): A branch with conv and bn. + branch (mmcv.runner.Sequential): A branch with conv and bn. Returns: tuple[torch.Tensor, torch.Tensor]: The parameters obtained after @@ -237,7 +237,7 @@ class RepVGGBlock(BaseModule): branch (nn.BatchNorm2d): A branch only with bn in the block. Returns: - tmp_conv3x3 (mmengine.runner.Sequential): a sequential with conv3x3 and + tmp_conv3x3 (mmcv.runner.Sequential): a sequential with conv3x3 and bn. """ input_dim = self.in_channels // self.groups diff --git a/mmcls/models/backbones/res2net.py b/mmcls/models/backbones/res2net.py index a241a9f8..491b6f47 100644 --- a/mmcls/models/backbones/res2net.py +++ b/mmcls/models/backbones/res2net.py @@ -5,7 +5,7 @@ import torch import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import build_conv_layer, build_norm_layer -from mmengine.runner import ModuleList, Sequential +from mmcv.runner import ModuleList, Sequential from ..builder import BACKBONES from .resnet import Bottleneck as _Bottleneck diff --git a/mmcls/models/backbones/resnet.py b/mmcls/models/backbones/resnet.py index 7cd4c9d7..d01ebe0c 100644 --- a/mmcls/models/backbones/resnet.py +++ b/mmcls/models/backbones/resnet.py @@ -5,7 +5,7 @@ import torch.utils.checkpoint as cp from mmcv.cnn import (ConvModule, build_activation_layer, build_conv_layer, build_norm_layer, constant_init) from mmcv.cnn.bricks import DropPath -from mmengine.runner import BaseModule +from mmcv.runner import BaseModule from mmcv.utils.parrots_wrapper import _BatchNorm from ..builder import BACKBONES diff --git a/mmcls/models/backbones/shufflenet_v1.py b/mmcls/models/backbones/shufflenet_v1.py index a36e1981..0b6c70f0 100644 --- a/mmcls/models/backbones/shufflenet_v1.py +++ b/mmcls/models/backbones/shufflenet_v1.py @@ -4,7 +4,7 @@ import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import (ConvModule, build_activation_layer, constant_init, normal_init) -from mmengine.runner import BaseModule +from mmcv.runner import BaseModule from torch.nn.modules.batchnorm import _BatchNorm from mmcls.models.utils import channel_shuffle, make_divisible diff --git a/mmcls/models/backbones/shufflenet_v2.py b/mmcls/models/backbones/shufflenet_v2.py index 1c21274e..bfe7ac82 100644 --- a/mmcls/models/backbones/shufflenet_v2.py +++ b/mmcls/models/backbones/shufflenet_v2.py @@ -3,7 +3,7 @@ import torch import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import ConvModule, constant_init, normal_init -from mmengine.runner import BaseModule +from mmcv.runner import BaseModule from torch.nn.modules.batchnorm import _BatchNorm from mmcls.models.utils import channel_shuffle diff --git a/mmcls/models/backbones/swin_transformer.py b/mmcls/models/backbones/swin_transformer.py index 075a3f1b..2295c267 100644 --- a/mmcls/models/backbones/swin_transformer.py +++ b/mmcls/models/backbones/swin_transformer.py @@ -9,7 +9,7 @@ import torch.utils.checkpoint as cp from mmcv.cnn import build_norm_layer from mmcv.cnn.bricks.transformer import FFN, PatchEmbed, PatchMerging from mmcv.cnn.utils.weight_init import trunc_normal_ -from mmengine.runner.base_module import BaseModule, ModuleList +from mmcv.runner.base_module import BaseModule, ModuleList from mmcv.utils.parrots_wrapper import _BatchNorm from ..builder import BACKBONES diff --git a/mmcls/models/backbones/t2t_vit.py b/mmcls/models/backbones/t2t_vit.py index f7b34483..e3160ccd 100644 --- a/mmcls/models/backbones/t2t_vit.py +++ b/mmcls/models/backbones/t2t_vit.py @@ -8,7 +8,7 @@ import torch.nn as nn from mmcv.cnn import build_norm_layer from mmcv.cnn.bricks.transformer import FFN from mmcv.cnn.utils.weight_init import trunc_normal_ -from mmengine.runner.base_module import BaseModule, ModuleList +from mmcv.runner.base_module import BaseModule, ModuleList from ..builder import BACKBONES from ..utils import MultiheadAttention, resize_pos_embed, to_2tuple diff --git a/mmcls/models/backbones/tnt.py b/mmcls/models/backbones/tnt.py index 51dedac2..b03120b9 100644 --- a/mmcls/models/backbones/tnt.py +++ b/mmcls/models/backbones/tnt.py @@ -6,7 +6,7 @@ import torch.nn as nn from mmcv.cnn import build_norm_layer from mmcv.cnn.bricks.transformer import FFN, MultiheadAttention from mmcv.cnn.utils.weight_init import trunc_normal_ -from mmengine.runner.base_module import BaseModule, ModuleList +from mmcv.runner.base_module import BaseModule, ModuleList from ..builder import BACKBONES from ..utils import to_2tuple diff --git a/mmcls/models/backbones/twins.py b/mmcls/models/backbones/twins.py index 384fc860..0e3c47a4 100644 --- a/mmcls/models/backbones/twins.py +++ b/mmcls/models/backbones/twins.py @@ -9,7 +9,7 @@ from mmcv.cnn.bricks.drop import build_dropout from mmcv.cnn.bricks.transformer import FFN, PatchEmbed from mmcv.cnn.utils.weight_init import (constant_init, normal_init, trunc_normal_init) -from mmengine.runner import BaseModule, ModuleList +from mmcv.runner import BaseModule, ModuleList from torch.nn.modules.batchnorm import _BatchNorm from mmcls.models.builder import BACKBONES diff --git a/mmcls/models/backbones/vision_transformer.py b/mmcls/models/backbones/vision_transformer.py index 1f2d39e3..87a70640 100644 --- a/mmcls/models/backbones/vision_transformer.py +++ b/mmcls/models/backbones/vision_transformer.py @@ -7,7 +7,7 @@ import torch.nn as nn from mmcv.cnn import build_norm_layer from mmcv.cnn.bricks.transformer import FFN, PatchEmbed from mmcv.cnn.utils.weight_init import trunc_normal_ -from mmengine.runner.base_module import BaseModule, ModuleList +from mmcv.runner.base_module import BaseModule, ModuleList from mmcls.utils import get_root_logger from ..builder import BACKBONES diff --git a/mmcls/models/classifiers/base.py b/mmcls/models/classifiers/base.py index 36ebcfa4..0fe6ef18 100644 --- a/mmcls/models/classifiers/base.py +++ b/mmcls/models/classifiers/base.py @@ -6,7 +6,7 @@ from typing import Sequence import mmcv import torch import torch.distributed as dist -from mmengine.runner import BaseModule, auto_fp16 +from mmcv.runner import BaseModule, auto_fp16 from mmcls.core.visualization import imshow_infos diff --git a/mmcls/models/classifiers/image.py b/mmcls/models/classifiers/image.py index da174bfd..b49333b7 100644 --- a/mmcls/models/classifiers/image.py +++ b/mmcls/models/classifiers/image.py @@ -52,7 +52,7 @@ class ImageClassifier(BaseClassifier): 1. Backbone output >>> import torch - >>> from mmengine.config import Config + >>> from mmcv import Config >>> from mmcls.models import build_classifier >>> >>> cfg = Config.fromfile('configs/resnet/resnet18_8xb32_in1k.py').model @@ -69,7 +69,7 @@ class ImageClassifier(BaseClassifier): 2. Neck output >>> import torch - >>> from mmengine.config import Config + >>> from mmcv import Config >>> from mmcls.models import build_classifier >>> >>> cfg = Config.fromfile('configs/resnet/resnet18_8xb32_in1k.py').model @@ -87,7 +87,7 @@ class ImageClassifier(BaseClassifier): 3. Pre-logits output (without the final linear classifier head) >>> import torch - >>> from mmengine.config import Config + >>> from mmcv import Config >>> from mmcls.models import build_classifier >>> >>> cfg = Config.fromfile('configs/vision_transformer/vit-base-p16_pt-64xb64_in1k-224.py').model diff --git a/mmcls/models/heads/base_head.py b/mmcls/models/heads/base_head.py index 860cfee3..e8936f28 100644 --- a/mmcls/models/heads/base_head.py +++ b/mmcls/models/heads/base_head.py @@ -1,7 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. from abc import ABCMeta, abstractmethod -from mmengine.runner import BaseModule +from mmcv.runner import BaseModule class BaseHead(BaseModule, metaclass=ABCMeta): diff --git a/mmcls/models/heads/stacked_head.py b/mmcls/models/heads/stacked_head.py index 1883e50a..bbb0dc24 100644 --- a/mmcls/models/heads/stacked_head.py +++ b/mmcls/models/heads/stacked_head.py @@ -4,7 +4,7 @@ from typing import Dict, Sequence import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import build_activation_layer, build_norm_layer -from mmengine.runner import BaseModule, ModuleList +from mmcv.runner import BaseModule, ModuleList from ..builder import HEADS from .cls_head import ClsHead diff --git a/mmcls/models/heads/vision_transformer_head.py b/mmcls/models/heads/vision_transformer_head.py index 2d89448f..d0586cb9 100644 --- a/mmcls/models/heads/vision_transformer_head.py +++ b/mmcls/models/heads/vision_transformer_head.py @@ -6,7 +6,7 @@ import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import build_activation_layer from mmcv.cnn.utils.weight_init import trunc_normal_ -from mmengine.runner import Sequential +from mmcv.runner import Sequential from ..builder import HEADS from .cls_head import ClsHead diff --git a/mmcls/models/necks/hr_fuse.py b/mmcls/models/necks/hr_fuse.py index be3dd4bf..1acc3827 100644 --- a/mmcls/models/necks/hr_fuse.py +++ b/mmcls/models/necks/hr_fuse.py @@ -1,7 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.cnn.bricks import ConvModule -from mmengine.runner import BaseModule +from mmcv.runner import BaseModule from ..backbones.resnet import Bottleneck, ResLayer from ..builder import NECKS diff --git a/mmcls/models/utils/attention.py b/mmcls/models/utils/attention.py index e4ccb260..155127f7 100644 --- a/mmcls/models/utils/attention.py +++ b/mmcls/models/utils/attention.py @@ -7,7 +7,7 @@ import torch.nn.functional as F from mmcv.cnn.bricks.registry import DROPOUT_LAYERS from mmcv.cnn.bricks.transformer import build_dropout from mmcv.cnn.utils.weight_init import trunc_normal_ -from mmengine.runner.base_module import BaseModule +from mmcv.runner.base_module import BaseModule from ..builder import ATTENTION from .helpers import to_2tuple diff --git a/mmcls/models/utils/embed.py b/mmcls/models/utils/embed.py index 1e129374..7dd27cd5 100644 --- a/mmcls/models/utils/embed.py +++ b/mmcls/models/utils/embed.py @@ -6,7 +6,7 @@ import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import build_conv_layer, build_norm_layer -from mmengine.runner.base_module import BaseModule +from mmcv.runner.base_module import BaseModule from .helpers import to_2tuple diff --git a/mmcls/models/utils/inverted_residual.py b/mmcls/models/utils/inverted_residual.py index ff5b71ba..7c432943 100644 --- a/mmcls/models/utils/inverted_residual.py +++ b/mmcls/models/utils/inverted_residual.py @@ -3,7 +3,7 @@ import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import ConvModule from mmcv.cnn.bricks import DropPath -from mmengine.runner import BaseModule +from mmcv.runner import BaseModule from .se_layer import SELayer diff --git a/mmcls/models/utils/position_encoding.py b/mmcls/models/utils/position_encoding.py index b22875f4..99f32de0 100644 --- a/mmcls/models/utils/position_encoding.py +++ b/mmcls/models/utils/position_encoding.py @@ -1,6 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn -from mmengine.runner.base_module import BaseModule +from mmcv.runner.base_module import BaseModule class ConditionalPositionEncoding(BaseModule): diff --git a/mmcls/models/utils/se_layer.py b/mmcls/models/utils/se_layer.py index 11aad64c..47a830ac 100644 --- a/mmcls/models/utils/se_layer.py +++ b/mmcls/models/utils/se_layer.py @@ -2,7 +2,7 @@ import mmcv import torch.nn as nn from mmcv.cnn import ConvModule -from mmengine.runner import BaseModule +from mmcv.runner import BaseModule from .make_divisible import make_divisible diff --git a/requirements/mminstall.txt b/requirements/mminstall.txt index 5df4a7fb..6306cb53 100644 --- a/requirements/mminstall.txt +++ b/requirements/mminstall.txt @@ -1,2 +1 @@ -mmcv==2.2.0 -mmengine==0.10.5 \ No newline at end of file +mmcv-full>=1.4.2,<1.6.0 diff --git a/tests/test_downstream/test_mmdet_inference.py b/tests/test_downstream/test_mmdet_inference.py index 5ae6211b..096c5db7 100644 --- a/tests/test_downstream/test_mmdet_inference.py +++ b/tests/test_downstream/test_mmdet_inference.py @@ -1,6 +1,6 @@ # Copyright (c) OpenMMLab. All rights reserved. import numpy as np -from mmengine.config import Config +from mmcv import Config from mmdet.apis import inference_detector from mmdet.models import build_detector diff --git a/tests/test_models/test_backbones/test_deit.py b/tests/test_models/test_backbones/test_deit.py index 599c1d84..5f11a3ae 100644 --- a/tests/test_models/test_backbones/test_deit.py +++ b/tests/test_models/test_backbones/test_deit.py @@ -6,7 +6,7 @@ from copy import deepcopy from unittest import TestCase import torch -from mmengine.runner import load_checkpoint, save_checkpoint +from mmcv.runner import load_checkpoint, save_checkpoint from mmcls.models.backbones import DistilledVisionTransformer from .utils import timm_resize_pos_embed diff --git a/tests/test_models/test_backbones/test_repmlp.py b/tests/test_models/test_backbones/test_repmlp.py index 084020b6..dcab2cfb 100644 --- a/tests/test_models/test_backbones/test_repmlp.py +++ b/tests/test_models/test_backbones/test_repmlp.py @@ -5,7 +5,7 @@ from copy import deepcopy from unittest import TestCase import torch -from mmengine.runner import load_checkpoint, save_checkpoint +from mmcv.runner import load_checkpoint, save_checkpoint from mmcls.models.backbones import RepMLPNet diff --git a/tests/test_models/test_backbones/test_repvgg.py b/tests/test_models/test_backbones/test_repvgg.py index 48e64abe..f4c78abc 100644 --- a/tests/test_models/test_backbones/test_repvgg.py +++ b/tests/test_models/test_backbones/test_repvgg.py @@ -4,7 +4,7 @@ import tempfile import pytest import torch -from mmengine.runner import load_checkpoint, save_checkpoint +from mmcv.runner import load_checkpoint, save_checkpoint from torch import nn from torch.nn.modules import GroupNorm from torch.nn.modules.batchnorm import _BatchNorm diff --git a/tests/test_models/test_backbones/test_swin_transformer.py b/tests/test_models/test_backbones/test_swin_transformer.py index a8dbb89f..b90ac0ed 100644 --- a/tests/test_models/test_backbones/test_swin_transformer.py +++ b/tests/test_models/test_backbones/test_swin_transformer.py @@ -7,7 +7,7 @@ from itertools import chain from unittest import TestCase import torch -from mmengine.runner import load_checkpoint, save_checkpoint +from mmcv.runner import load_checkpoint, save_checkpoint from mmcv.utils.parrots_wrapper import _BatchNorm from mmcls.models.backbones import SwinTransformer diff --git a/tests/test_models/test_backbones/test_t2t_vit.py b/tests/test_models/test_backbones/test_t2t_vit.py index d0cdbcb3..cc7e839c 100644 --- a/tests/test_models/test_backbones/test_t2t_vit.py +++ b/tests/test_models/test_backbones/test_t2t_vit.py @@ -6,7 +6,7 @@ from copy import deepcopy from unittest import TestCase import torch -from mmengine.runner import load_checkpoint, save_checkpoint +from mmcv.runner import load_checkpoint, save_checkpoint from mmcls.models.backbones import T2T_ViT from .utils import timm_resize_pos_embed diff --git a/tests/test_models/test_backbones/test_vision_transformer.py b/tests/test_models/test_backbones/test_vision_transformer.py index c3f5c4e5..26cc7370 100644 --- a/tests/test_models/test_backbones/test_vision_transformer.py +++ b/tests/test_models/test_backbones/test_vision_transformer.py @@ -6,7 +6,7 @@ from copy import deepcopy from unittest import TestCase import torch -from mmengine.runner import load_checkpoint, save_checkpoint +from mmcv.runner import load_checkpoint, save_checkpoint from mmcls.models.backbones import VisionTransformer from .utils import timm_resize_pos_embed diff --git a/tests/test_models/test_classifiers.py b/tests/test_models/test_classifiers.py index 50e5e94e..b9487d11 100644 --- a/tests/test_models/test_classifiers.py +++ b/tests/test_models/test_classifiers.py @@ -5,7 +5,7 @@ from copy import deepcopy import numpy as np import torch -from mmengine.config import ConfigDict +from mmcv import ConfigDict from mmcls.models import CLASSIFIERS from mmcls.models.classifiers import ImageClassifier diff --git a/tests/test_runtime/test_eval_hook.py b/tests/test_runtime/test_eval_hook.py index 580909a5..b925bdeb 100644 --- a/tests/test_runtime/test_eval_hook.py +++ b/tests/test_runtime/test_eval_hook.py @@ -3,12 +3,12 @@ import logging import tempfile from unittest.mock import MagicMock, patch -import mmengine.runner +import mmcv.runner import pytest import torch import torch.nn as nn -from mmengine.runner import obj_from_dict -from mmengine.runner.hooks import DistEvalHook, EvalHook +from mmcv.runner import obj_from_dict +from mmcv.runner.hooks import DistEvalHook, EvalHook from torch.utils.data import DataLoader, Dataset from mmcls.apis import single_gpu_test @@ -65,7 +65,7 @@ def test_iter_eval_hook(): # test EvalHook with tempfile.TemporaryDirectory() as tmpdir: eval_hook = EvalHook(data_loader, by_epoch=False) - runner = mmengine.runner.IterBasedRunner( + runner = mmcv.runner.IterBasedRunner( model=model, optimizer=optimizer, work_dir=tmpdir, @@ -103,7 +103,7 @@ def test_epoch_eval_hook(): # test EvalHook with interval with tempfile.TemporaryDirectory() as tmpdir: eval_hook = EvalHook(data_loader, by_epoch=True, interval=2) - runner = mmengine.runner.EpochBasedRunner( + runner = mmcv.runner.EpochBasedRunner( model=model, optimizer=optimizer, work_dir=tmpdir, @@ -149,7 +149,7 @@ def test_dist_eval_hook(): p = patch('mmcv.engine.multi_gpu_test', multi_gpu_test) p.start() eval_hook = DistEvalHook(data_loader, by_epoch=False) - runner = mmengine.runner.IterBasedRunner( + runner = mmcv.runner.IterBasedRunner( model=model, optimizer=optimizer, work_dir=tmpdir, @@ -191,7 +191,7 @@ def test_dist_eval_hook_epoch(): p = patch('mmcv.engine.multi_gpu_test', multi_gpu_test) p.start() eval_hook = DistEvalHook(data_loader, by_epoch=True, interval=2) - runner = mmengine.runner.EpochBasedRunner( + runner = mmcv.runner.EpochBasedRunner( model=model, optimizer=optimizer, work_dir=tmpdir, diff --git a/tests/test_runtime/test_hooks.py b/tests/test_runtime/test_hooks.py index 8ae64b02..70140d9e 100644 --- a/tests/test_runtime/test_hooks.py +++ b/tests/test_runtime/test_hooks.py @@ -7,8 +7,8 @@ import numpy as np import pytest import torch import torch.nn as nn -from mmengine.runner import build_runner -from mmengine.runner.hooks import Hook, IterTimerHook +from mmcv.runner import build_runner +from mmcv.runner.hooks import Hook, IterTimerHook from torch.utils.data import DataLoader import mmcls.core # noqa: F401 diff --git a/tests/test_runtime/test_num_class_hook.py b/tests/test_runtime/test_num_class_hook.py index 9bc4f373..fe8fb059 100644 --- a/tests/test_runtime/test_num_class_hook.py +++ b/tests/test_runtime/test_num_class_hook.py @@ -3,10 +3,10 @@ import logging import tempfile from unittest.mock import MagicMock -import mmengine.runner as mmcv_runner +import mmcv.runner as mmcv_runner import pytest import torch -from mmengine.runner import obj_from_dict +from mmcv.runner import obj_from_dict from torch.utils.data import DataLoader, Dataset from mmcls.core.hook import ClassNumCheckHook diff --git a/tests/test_runtime/test_optimizer.py b/tests/test_runtime/test_optimizer.py index 537d5db6..2fdaeb08 100644 --- a/tests/test_runtime/test_optimizer.py +++ b/tests/test_runtime/test_optimizer.py @@ -6,8 +6,8 @@ from typing import Iterable import torch import torch.nn as nn -from mmengine.runner import build_optimizer -from mmengine.runner.optimizer.builder import OPTIMIZERS +from mmcv.runner import build_optimizer +from mmcv.runner.optimizer.builder import OPTIMIZERS from mmcv.utils.registry import build_from_cfg from torch.autograd import Variable from torch.optim.optimizer import Optimizer diff --git a/tests/test_runtime/test_preciseBN_hook.py b/tests/test_runtime/test_preciseBN_hook.py index 2213276c..d9cd7156 100644 --- a/tests/test_runtime/test_preciseBN_hook.py +++ b/tests/test_runtime/test_preciseBN_hook.py @@ -4,7 +4,7 @@ import pytest import torch import torch.nn as nn from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmengine.runner import EpochBasedRunner, IterBasedRunner, build_optimizer +from mmcv.runner import EpochBasedRunner, IterBasedRunner, build_optimizer from mmcv.utils import get_logger from mmcv.utils.logging import print_log from torch.utils.data import DataLoader, Dataset diff --git a/tests/test_utils/test_setup_env.py b/tests/test_utils/test_setup_env.py index 7fa74f94..2679dbbf 100644 --- a/tests/test_utils/test_setup_env.py +++ b/tests/test_utils/test_setup_env.py @@ -4,7 +4,7 @@ import os import platform import cv2 -from mmengine.config import Config +from mmcv import Config from mmcls.utils import setup_multi_processes diff --git a/tools/analysis_tools/eval_metric.py b/tools/analysis_tools/eval_metric.py index 2453ffe9..1c95dbc0 100644 --- a/tools/analysis_tools/eval_metric.py +++ b/tools/analysis_tools/eval_metric.py @@ -2,7 +2,7 @@ import argparse import mmcv -from mmengine.config import Config, DictAction +from mmcv import Config, DictAction from mmcls.datasets import build_dataset diff --git a/tools/analysis_tools/get_flops.py b/tools/analysis_tools/get_flops.py index 51dd86d9..58683d98 100644 --- a/tools/analysis_tools/get_flops.py +++ b/tools/analysis_tools/get_flops.py @@ -1,7 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. import argparse -from mmengine.config import Config +from mmcv import Config from mmcv.cnn.utils import get_model_complexity_info from mmcls.models import build_classifier diff --git a/tools/convert_models/efficientnet_to_mmcls.py b/tools/convert_models/efficientnet_to_mmcls.py index 8d2028aa..d1b097bd 100644 --- a/tools/convert_models/efficientnet_to_mmcls.py +++ b/tools/convert_models/efficientnet_to_mmcls.py @@ -4,7 +4,7 @@ import os import numpy as np import torch -from mmengine.runner import Sequential +from mmcv.runner import Sequential from tensorflow.python.training import py_checkpoint_reader from mmcls.models.backbones.efficientnet import EfficientNet diff --git a/tools/convert_models/twins2mmcls.py b/tools/convert_models/twins2mmcls.py index 8b822ad9..e0ea04c2 100644 --- a/tools/convert_models/twins2mmcls.py +++ b/tools/convert_models/twins2mmcls.py @@ -5,7 +5,7 @@ from collections import OrderedDict import mmcv import torch -from mmengine.runner import CheckpointLoader +from mmcv.runner import CheckpointLoader def convert_twins(args, ckpt): diff --git a/tools/deployment/pytorch2mlmodel.py b/tools/deployment/pytorch2mlmodel.py index da577963..814cbe94 100644 --- a/tools/deployment/pytorch2mlmodel.py +++ b/tools/deployment/pytorch2mlmodel.py @@ -8,7 +8,7 @@ from functools import partial import mmcv import numpy as np import torch -from mmengine.runner import load_checkpoint +from mmcv.runner import load_checkpoint from torch import nn from mmcls.models import build_classifier diff --git a/tools/deployment/pytorch2onnx.py b/tools/deployment/pytorch2onnx.py index 7b02657c..8015e861 100644 --- a/tools/deployment/pytorch2onnx.py +++ b/tools/deployment/pytorch2onnx.py @@ -8,7 +8,7 @@ import numpy as np import onnxruntime as rt import torch from mmcv.onnx import register_extra_symbolics -from mmengine.runner import load_checkpoint +from mmcv.runner import load_checkpoint from mmcls.models import build_classifier diff --git a/tools/deployment/pytorch2torchscript.py b/tools/deployment/pytorch2torchscript.py index e70118ef..f261b7c9 100644 --- a/tools/deployment/pytorch2torchscript.py +++ b/tools/deployment/pytorch2torchscript.py @@ -7,7 +7,7 @@ from functools import partial import mmcv import numpy as np import torch -from mmengine.runner import load_checkpoint +from mmcv.runner import load_checkpoint from torch import nn from mmcls.models import build_classifier diff --git a/tools/kfold-cross-valid.py b/tools/kfold-cross-valid.py index d186527a..c6d8d89d 100644 --- a/tools/kfold-cross-valid.py +++ b/tools/kfold-cross-valid.py @@ -10,8 +10,8 @@ from pathlib import Path import mmcv import torch -from mmengine.config import Config, DictAction -from mmengine.dist.utils import get_dist_info, init_dist +from mmcv import Config, DictAction +from mmcv.runner import get_dist_info, init_dist from mmcls import __version__ from mmcls.apis import init_random_seed, set_random_seed, train_model diff --git a/tools/misc/print_config.py b/tools/misc/print_config.py index 31eaf8ed..a2781a60 100644 --- a/tools/misc/print_config.py +++ b/tools/misc/print_config.py @@ -1,7 +1,7 @@ # Copyright (c) OpenMMLab. All rights reserved. import argparse -from mmengine.config import Config, DictAction +from mmcv import Config, DictAction def parse_args(): diff --git a/tools/misc/verify_dataset.py b/tools/misc/verify_dataset.py index 7d1a0d45..6114adb1 100644 --- a/tools/misc/verify_dataset.py +++ b/tools/misc/verify_dataset.py @@ -4,7 +4,7 @@ import fcntl import os from pathlib import Path -from mmengine.config import Config, DictAction, track_parallel_progress, track_progress +from mmcv import Config, DictAction, track_parallel_progress, track_progress from mmcls.datasets import PIPELINES, build_dataset diff --git a/tools/test.py b/tools/test.py index f58e9176..4ade85fc 100644 --- a/tools/test.py +++ b/tools/test.py @@ -9,7 +9,7 @@ import numpy as np import torch from mmcv import DictAction from mmcv.parallel import MMDataParallel, MMDistributedDataParallel -from mmengine.runner import (get_dist_info, init_dist, load_checkpoint, +from mmcv.runner import (get_dist_info, init_dist, load_checkpoint, wrap_fp16_model) from mmcls.apis import multi_gpu_test, single_gpu_test diff --git a/tools/train.py b/tools/train.py index d279bc7f..cf21c93a 100644 --- a/tools/train.py +++ b/tools/train.py @@ -9,8 +9,8 @@ import warnings import mmcv import torch import torch.distributed as dist -from mmengine.config import Config, DictAction -from mmengine.dist.utils import get_dist_info, init_dist +from mmcv import Config, DictAction +from mmcv.runner import get_dist_info, init_dist from mmcls import __version__ from mmcls.apis import init_random_seed, set_random_seed, train_model diff --git a/tools/visualizations/vis_cam.py b/tools/visualizations/vis_cam.py index bf7af333..a1fcadac 100644 --- a/tools/visualizations/vis_cam.py +++ b/tools/visualizations/vis_cam.py @@ -8,7 +8,7 @@ from pathlib import Path import mmcv import numpy as np -from mmengine.config import Config, DictAction +from mmcv import Config, DictAction from mmcv.utils import to_2tuple from torch.nn import BatchNorm1d, BatchNorm2d, GroupNorm, LayerNorm diff --git a/tools/visualizations/vis_lr.py b/tools/visualizations/vis_lr.py index 557321a0..bd344215 100644 --- a/tools/visualizations/vis_lr.py +++ b/tools/visualizations/vis_lr.py @@ -9,8 +9,8 @@ from pprint import pformat import matplotlib.pyplot as plt import mmcv import torch.nn as nn -from mmengine.config import Config, DictAction, ProgressBar -from mmengine.runner import (EpochBasedRunner, IterBasedRunner, IterLoader, +from mmcv import Config, DictAction, ProgressBar +from mmcv.runner import (EpochBasedRunner, IterBasedRunner, IterLoader, build_optimizer) from torch.utils.data import DataLoader diff --git a/tools/visualizations/vis_pipeline.py b/tools/visualizations/vis_pipeline.py index 268a5bdf..ffb9b183 100644 --- a/tools/visualizations/vis_pipeline.py +++ b/tools/visualizations/vis_pipeline.py @@ -12,7 +12,7 @@ from typing import List import cv2 import mmcv import numpy as np -from mmengine.config import Config, DictAction, ProgressBar +from mmcv import Config, DictAction, ProgressBar from mmcls.core import visualization as vis from mmcls.datasets.builder import PIPELINES, build_dataset, build_from_cfg