提交 bbf1d06c 编写于 作者: C chenkai

Fix all register_module

上级 e57fe961
......@@ -307,7 +307,7 @@ Flops: 37.1 GMac
Params: 28.04 M
```
**Note**: This tool is still experimental and we do not guarantee that the number is correct.
**Note**: This tool is still experimental and we do not guarantee that the number is correct.
You may well use the result for simple comparisons, but double check it before you adopt it in technical reports or papers.
(1) FLOPs are related to the input shape while parameters are not. The default input shape is (1, 3, 340, 256) for 2D recognizer, (1, 3, 32, 340, 256) for 3D recognizer.
......@@ -469,7 +469,7 @@ In `mmaction/core/optimizer/my_optimizer.py`:
from .registry import OPTIMIZERS
from torch.optim import Optimizer
@OPTIMIZERS.register_module
@OPTIMIZERS.register_module()
class MyOptimizer(Optimizer):
```
......@@ -495,7 +495,7 @@ In `mmaction/core/optimizer/my_optimizer_constructor.py`:
from .default_constructor import DefaultOptimizerConstructor
from .registry import OPTIMIZER_BUILDERS
@OPTIMIZER_BUILDERS.register_module
@OPTIMIZER_BUILDERS.register_module()
class MyOptimizerConstructor(DefaultOptimizerConstructor):
```
......@@ -526,7 +526,7 @@ import torch.nn as nn
from ..registry import BACKBONES
@BACKBONES.register_module
@BACKBONES.register_module()
class ResNet(nn.Module):
def __init__(self, arg1, arg2):
......@@ -555,7 +555,7 @@ from ..registry import HEADS
from .base import BaseHead
@HEADS.register_module
@HEADS.register_module()
class TSNHead(BaseHead):
def __init__(self, arg1, arg2):
......
......@@ -13,10 +13,10 @@ the arguments of models' forward method is returned, and it will be fed into the
> Since the data in action recognition & localization may not be the same size (image size, gt bbox size, etc.), the `DataContainer` type in MMCV is used to help collect and distribute data of different size. See [here](https://github.com/open-mmlab/mmcv/blob/master/mmcv/parallel/data_container.py) for more details.
The data preparation pipeline and the dataset is decoupled.
The data preparation pipeline and the dataset is decoupled.
Usually a dataset
defines how to process the annotations while a data pipeline defines all the steps to prepare a data dict.
A data preparation pipeline consists of a sequence of operations.
A data preparation pipeline consists of a sequence of operations.
Each operation takes a dict as input and also output a dict for the next transformation.
A typical pipeline is shown in the following figure.
......@@ -202,7 +202,7 @@ in [TSM: Temporal Shift Module for Efficient Video Understanding](https://arxiv.
from ..registry import BACKBONES
from .resnet import ResNet
@BACKBONES.register_module
@BACKBONES.register_module()
class ResNetTSM(ResNet):
def __init__(self,
......
......@@ -12,7 +12,7 @@ You need to first implement the new optimizer in a file, e.g., in `mmaction/core
from .registry import OPTIMIZERS
from torch.optim import Optimizer
@OPTIMIZERS.register_module
@OPTIMIZERS.register_module()
class MyOptimizer(Optimizer):
def __init__(self, a, b, c):
......@@ -63,7 +63,7 @@ In `mmaction/core/optimizer/my_optimizer_constructor.py`:
from .default_constructor import DefaultOptimizerConstructor
from .registry import OPTIMIZER_BUILDERS
@OPTIMIZER_BUILDERS.register_module
@OPTIMIZER_BUILDERS.register_module()
class MyOptimizerConstructor(DefaultOptimizerConstructor):
```
......@@ -107,7 +107,7 @@ import torch.nn as nn
from ..registry import BACKBONES
@BACKBONES.register_module
@BACKBONES.register_module()
class ResNet(nn.Module):
def __init__(self, arg1, arg2):
......@@ -152,7 +152,7 @@ from ..registry import HEADS
from .base import BaseHead
@HEADS.register_module
@HEADS.register_module()
class TSNHead(BaseHead):
def __init__(self, arg1, arg2):
......@@ -200,7 +200,7 @@ def my_loss(pred, target):
return loss
@LOSSES.register_module
@LOSSES.register_module()
class MyLoss(nn.Module):
def forward(self, pred, target):
......
......@@ -2,7 +2,7 @@ from mmcv.runner import OPTIMIZERS
from torch.optim import SGD
@OPTIMIZERS.register_module
@OPTIMIZERS.register_module()
class CopyOfSGD(SGD):
"""A clone of torch.optim.SGD.
......
......@@ -3,7 +3,7 @@ from mmcv.runner import OPTIMIZER_BUILDERS, DefaultOptimizerConstructor
from mmcv.utils import SyncBatchNorm, _BatchNorm, _ConvNd
@OPTIMIZER_BUILDERS.register_module
@OPTIMIZER_BUILDERS.register_module()
class TSMOptimizerConstructor(DefaultOptimizerConstructor):
"""Optimizer constructor in TSM model.
......
......@@ -10,7 +10,7 @@ from .base import BaseDataset
from .registry import DATASETS
@DATASETS.register_module
@DATASETS.register_module()
class ActivityNetDataset(BaseDataset):
"""ActivityNet dataset for temporal action localization.
......
from .registry import DATASETS
@DATASETS.register_module
@DATASETS.register_module()
class RepeatDataset(object):
"""A wrapper of repeated dataset.
......
......@@ -42,7 +42,7 @@ def _init_lazy_if_proper(results, lazy):
assert 'lazy' not in results, 'Use Fuse after lazy operations'
@PIPELINES.register_module
@PIPELINES.register_module()
class Fuse(object):
"""Fuse lazy operations.
......@@ -86,7 +86,7 @@ class Fuse(object):
return results
@PIPELINES.register_module
@PIPELINES.register_module()
class RandomCrop(object):
"""Vanilla square random crop that specifics the output size.
......@@ -154,7 +154,7 @@ class RandomCrop(object):
return repr_str
@PIPELINES.register_module
@PIPELINES.register_module()
class RandomResizedCrop(object):
"""Random crop that specifics the area and height-weight ratio range.
......@@ -278,7 +278,7 @@ class RandomResizedCrop(object):
return repr_str
@PIPELINES.register_module
@PIPELINES.register_module()
class MultiScaleCrop(object):
"""Crop images with a list of randomly selected scales.
......@@ -423,7 +423,7 @@ class MultiScaleCrop(object):
return repr_str
@PIPELINES.register_module
@PIPELINES.register_module()
class Resize(object):
"""Resize images to a specific size.
......@@ -510,7 +510,7 @@ class Resize(object):
return repr_str
@PIPELINES.register_module
@PIPELINES.register_module()
class Flip(object):
"""Flip the input images with a probability.
......@@ -570,7 +570,7 @@ class Flip(object):
return repr_str
@PIPELINES.register_module
@PIPELINES.register_module()
class Normalize(object):
"""Normalize images with the given mean and std value.
......@@ -619,7 +619,7 @@ class Normalize(object):
return repr_str
@PIPELINES.register_module
@PIPELINES.register_module()
class CenterCrop(object):
"""Crop the center area from images.
......@@ -683,7 +683,7 @@ class CenterCrop(object):
return repr_str
@PIPELINES.register_module
@PIPELINES.register_module()
class ThreeCrop(object):
"""Crop images into three crops.
......@@ -748,7 +748,7 @@ class ThreeCrop(object):
return repr_str
@PIPELINES.register_module
@PIPELINES.register_module()
class TenCrop(object):
"""Crop the images into 10 crops (corner + center + flip).
......@@ -811,7 +811,7 @@ class TenCrop(object):
return repr_str
@PIPELINES.register_module
@PIPELINES.register_module()
class MultiGroupCrop(object):
"""Randomly crop the images into several groups.
......
......@@ -5,7 +5,7 @@ from mmcv.utils import build_from_cfg
from ..registry import PIPELINES
@PIPELINES.register_module
@PIPELINES.register_module()
class Compose(object):
"""Compose a data pipeline with a sequence of transforms.
......
......@@ -28,7 +28,7 @@ def to_tensor(data):
raise TypeError(f'type {type(data)} cannot be converted to tensor.')
@PIPELINES.register_module
@PIPELINES.register_module()
class ToTensor(object):
"""Convert some values in results dict to `torch.Tensor` type
in data loader pipeline.
......@@ -49,7 +49,7 @@ class ToTensor(object):
return f'{self.__class__.__name__}(keys={self.keys})'
@PIPELINES.register_module
@PIPELINES.register_module()
class ToDataContainer(object):
"""Convert the data to DataContainer.
......@@ -73,7 +73,7 @@ class ToDataContainer(object):
return self.__class__.__name__ + f'(fields={self.fields})'
@PIPELINES.register_module
@PIPELINES.register_module()
class ImageToTensor(object):
"""Convert image type to `torch.Tensor` type.
......@@ -93,7 +93,7 @@ class ImageToTensor(object):
return f'{self.__class__.__name__}(keys={self.keys})'
@PIPELINES.register_module
@PIPELINES.register_module()
class Transpose(object):
"""Transpose image channels to a given order.
......@@ -116,7 +116,7 @@ class Transpose(object):
f'keys={self.keys}, order={self.order})')
@PIPELINES.register_module
@PIPELINES.register_module()
class Collect(object):
"""Collect data from the loader relevant to the specific task.
......@@ -184,7 +184,7 @@ class Collect(object):
f'keys={self.keys}, meta_keys={self.meta_keys})')
@PIPELINES.register_module
@PIPELINES.register_module()
class FormatShape(object):
"""Format final imgs shape to the given input_format
......
......@@ -11,7 +11,7 @@ from ...utils import get_random_string, get_shm_dir, get_thread_id
from ..registry import PIPELINES
@PIPELINES.register_module
@PIPELINES.register_module()
class SampleFrames(object):
"""Sample frames from the video.
......@@ -141,7 +141,7 @@ class SampleFrames(object):
return results
@PIPELINES.register_module
@PIPELINES.register_module()
class DenseSampleFrames(SampleFrames):
"""Select frames from the video by dense sample strategy.
......@@ -224,7 +224,7 @@ class DenseSampleFrames(SampleFrames):
return clip_offsets
@PIPELINES.register_module
@PIPELINES.register_module()
class PyAVInit(object):
"""Using pyav to initialize the video.
......@@ -263,7 +263,7 @@ class PyAVInit(object):
return results
@PIPELINES.register_module
@PIPELINES.register_module()
class PyAVDecode(object):
"""Using pyav to decode the video.
......@@ -316,7 +316,7 @@ class PyAVDecode(object):
return repr_str
@PIPELINES.register_module
@PIPELINES.register_module()
class DecordInit(object):
"""Using decord to initialize the video_reader.
......@@ -363,7 +363,7 @@ class DecordInit(object):
shutil.rmtree(self.tmp_folder)
@PIPELINES.register_module
@PIPELINES.register_module()
class DecordDecode(object):
"""Using decord to decode the video.
......@@ -396,7 +396,7 @@ class DecordDecode(object):
return results
@PIPELINES.register_module
@PIPELINES.register_module()
class OpenCVInit(object):
"""Using OpenCV to initalize the video_reader.
......@@ -435,7 +435,7 @@ class OpenCVInit(object):
shutil.rmtree(self.tmp_folder)
@PIPELINES.register_module
@PIPELINES.register_module()
class OpenCVDecode(object):
"""Using OpenCV to decode the video.
......@@ -474,7 +474,7 @@ class OpenCVDecode(object):
return results
@PIPELINES.register_module
@PIPELINES.register_module()
class FrameSelector(object):
"""Select raw frames with given indices.
......@@ -526,7 +526,7 @@ class FrameSelector(object):
return results
@PIPELINES.register_module
@PIPELINES.register_module()
class LoadLocalizationFeature(object):
"""Load Video features for localizer with given video_name list.
......@@ -556,7 +556,7 @@ class LoadLocalizationFeature(object):
return results
@PIPELINES.register_module
@PIPELINES.register_module()
class GenerateLocalizationLabels(object):
"""Load video label for localizer with given video_name list.
......@@ -587,7 +587,7 @@ class GenerateLocalizationLabels(object):
return results
@PIPELINES.register_module
@PIPELINES.register_module()
class LoadProposals(object):
"""Loading proposals with given proposal results.
......
......@@ -9,7 +9,7 @@ from .base import BaseDataset
from .registry import DATASETS
@DATASETS.register_module
@DATASETS.register_module()
class RawframeDataset(BaseDataset):
"""Rawframe dataset for action recognition.
......
......@@ -8,7 +8,7 @@ from .base import BaseDataset
from .registry import DATASETS
@DATASETS.register_module
@DATASETS.register_module()
class VideoDataset(BaseDataset):
"""Video dataset for action recognition.
......
......@@ -285,7 +285,7 @@ def make_res_layer(block,
return nn.Sequential(*layers)
@BACKBONES.register_module
@BACKBONES.register_module()
class ResNet(nn.Module):
"""ResNet backbone.
......
......@@ -2,7 +2,7 @@ from ..registry import BACKBONES
from .resnet3d import ResNet3d
@BACKBONES.register_module
@BACKBONES.register_module()
class ResNet2Plus1d(ResNet3d):
"""ResNet (2+1)d backbone.
......
......@@ -283,7 +283,7 @@ class Bottleneck3d(nn.Module):
return out
@BACKBONES.register_module
@BACKBONES.register_module()
class ResNet3d(nn.Module):
"""ResNet 3d backbone.
......
......@@ -333,7 +333,7 @@ def build_pathway(cfg, *args, **kwargs):
return pathway
@BACKBONES.register_module
@BACKBONES.register_module()
class ResNet3dSlowFast(nn.Module):
"""Slowfast backbone.
......
......@@ -321,7 +321,7 @@ class TemporalInterlace(nn.Module):
return x_out, x_offset, x_weight
@BACKBONES.register_module
@BACKBONES.register_module()
class ResNetTIN(ResNet):
"""ResNet backbone for TIN.
......
......@@ -71,7 +71,7 @@ class TemporalShift(nn.Module):
return out.view(n, c, h, w)
@BACKBONES.register_module
@BACKBONES.register_module()
class ResNetTSM(ResNet):
"""ResNet backbone for TSM.
......
......@@ -5,7 +5,7 @@ from ..registry import HEADS
from .base import BaseHead
@HEADS.register_module
@HEADS.register_module()
class I3DHead(BaseHead):
"""Classification head for I3D.
......
......@@ -6,7 +6,7 @@ from ..registry import HEADS
from .base import BaseHead
@HEADS.register_module
@HEADS.register_module()
class SlowFastHead(BaseHead):
"""The classification head for Slowfast.
......
......@@ -7,7 +7,7 @@ from ..registry import HEADS
from .base import AvgConsensus, BaseHead
@HEADS.register_module
@HEADS.register_module()
class TINHead(BaseHead):
"""Class head for TIN.
......
......@@ -6,7 +6,7 @@ from ..registry import HEADS
from .base import AvgConsensus, BaseHead
@HEADS.register_module
@HEADS.register_module()
class TSMHead(BaseHead):
"""Class head for TSM.
......
......@@ -5,7 +5,7 @@ from ..registry import HEADS
from .base import AvgConsensus, BaseHead
@HEADS.register_module
@HEADS.register_module()
class TSNHead(BaseHead):
"""Class head for TSN.
......
......@@ -10,7 +10,7 @@ from ..registry import LOCALIZERS
from .utils import post_processing
@LOCALIZERS.register_module
@LOCALIZERS.register_module()
class BMN(nn.Module):
"""Boundary Matching Network for temporal action proposal generation.
......
......@@ -9,7 +9,7 @@ from ..registry import LOCALIZERS
from .utils import post_processing
@LOCALIZERS.register_module
@LOCALIZERS.register_module()
class TEM(nn.Module):
"""Temporal Evaluation Model for Boundary Sensetive Network.
......@@ -195,7 +195,7 @@ class TEM(nn.Module):
return self.forward_test(raw_feature, video_meta)
@LOCALIZERS.register_module
@LOCALIZERS.register_module()
class PEM(nn.Module):
"""Proposals Evaluation Model for Boundary Sensetive Network.
......
......@@ -27,7 +27,7 @@ def binary_logistic_regression_loss(reg_score,
return loss
@LOSSES.register_module
@LOSSES.register_module()
class BinaryLogisticRegressionLoss(nn.Module):
"""Binary Logistic Regression Loss
......
......@@ -6,7 +6,7 @@ from ..registry import LOSSES
from .binary_logistic_regression_loss import binary_logistic_regression_loss
@LOSSES.register_module
@LOSSES.register_module()
class BMNLoss(nn.Module):
"""BMN Loss.
......
......@@ -4,7 +4,7 @@ from ..registry import LOSSES
from .base import BaseWeightedLoss
@LOSSES.register_module
@LOSSES.register_module()
class CrossEntropyLoss(BaseWeightedLoss):
"""Cross Entropy Loss."""
......@@ -13,7 +13,7 @@ class CrossEntropyLoss(BaseWeightedLoss):
return loss_cls
@LOSSES.register_module
@LOSSES.register_module()
class BCELossWithLogits(BaseWeightedLoss):
"""Binary Cross Entropy Loss with logits."""
......
......@@ -4,7 +4,7 @@ from ..registry import LOSSES
from .base import BaseWeightedLoss
@LOSSES.register_module
@LOSSES.register_module()
class NLLLoss(BaseWeightedLoss):
"""NLL Loss.
......
......@@ -2,7 +2,7 @@ from ..registry import RECOGNIZERS
from .base import BaseRecognizer
@RECOGNIZERS.register_module
@RECOGNIZERS.register_module()
class Recognizer2D(BaseRecognizer):
"""2D recognizer model framework."""
......
......@@ -2,7 +2,7 @@ from ..registry import RECOGNIZERS
from .base import BaseRecognizer
@RECOGNIZERS.register_module
@RECOGNIZERS.register_module()
class Recognizer3D(BaseRecognizer):
"""3D recognizer model framework."""
......
......@@ -13,7 +13,7 @@ from mmaction.core import set_random_seed, train_model
from mmaction.datasets.registry import DATASETS
@DATASETS.register_module
@DATASETS.register_module()
class ExampleDataset(Dataset):
def __init__(self, test_mode=False):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册