Skip to content

Commit

Permalink
Merge pull request #4 from Clarifai/796-4
Browse files Browse the repository at this point in the history
Revert previous changes
  • Loading branch information
wemoveon2 authored Oct 8, 2024
2 parents a5a9fe3 + 8fcde38 commit 315d0be
Show file tree
Hide file tree
Showing 75 changed files with 98 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .dev_scripts/benchmark_regression/1-benchmark_valid.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

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
Expand Down
4 changes: 2 additions & 2 deletions docs/en/tutorials/MMClassification_python.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions docs/zh_CN/tutorials/MMClassification_python_cn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion mmcls/apis/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/apis/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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,
Expand Down
6 changes: 3 additions & 3 deletions mmcls/apis/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions mmcls/core/hook/class_num_check_hook.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
2 changes: 1 addition & 1 deletion mmcls/core/hook/lr_updater.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
4 changes: 2 additions & 2 deletions mmcls/core/hook/precise_bn_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/core/optimizers/lamb.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
import math

import torch
from mmengine.runner import OPTIMIZERS
from mmcv.runner import OPTIMIZERS
from torch.optim import Optimizer


Expand Down
2 changes: 1 addition & 1 deletion mmcls/core/utils/dist_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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)

Expand Down
2 changes: 1 addition & 1 deletion mmcls/datasets/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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

Expand Down
2 changes: 1 addition & 1 deletion mmcls/datasets/cifar.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/datasets/mnist.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/datasets/samplers/repeat_aug.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/base_backbone.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
4 changes: 2 additions & 2 deletions mmcls/models/backbones/convnext.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/cspnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/efficientnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/hrnet.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/mlp_mixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/mobilenet_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/poolformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/repmlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
Expand Down
6 changes: 3 additions & 3 deletions mmcls/models/backbones/repvgg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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
Expand Down Expand Up @@ -208,7 +208,7 @@ def _fuse_conv_bn(self, branch):
"""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
Expand Down Expand Up @@ -237,7 +237,7 @@ def _norm_to_conv3x3(self, branch_nrom):
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/res2net.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/resnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/shufflenet_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/shufflenet_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/swin_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/t2t_vit.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/tnt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/twins.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/backbones/vision_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
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
Expand Down
2 changes: 1 addition & 1 deletion mmcls/models/classifiers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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

Expand Down
6 changes: 3 additions & 3 deletions mmcls/models/classifiers/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def extract_feat(self, img, stage='neck'):
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
Expand All @@ -69,7 +69,7 @@ def extract_feat(self, img, stage='neck'):
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
Expand All @@ -87,7 +87,7 @@ def extract_feat(self, img, stage='neck'):
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
Expand Down
Loading

0 comments on commit 315d0be

Please sign in to comment.