repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
STTS
STTS-main/VideoSwin/mmaction/core/evaluation/eval_detection.py
import json import numpy as np from mmcv.utils import print_log from ...utils import get_root_logger from .accuracy import interpolated_precision_recall, pairwise_temporal_iou class ActivityNetLocalization: """Class to evaluate detection results on ActivityNet. Args: ground_truth_filename (str | No...
9,363
39.017094
79
py
STTS
STTS-main/VideoSwin/mmaction/core/evaluation/ava_utils.py
import csv import logging import time from collections import defaultdict import numpy as np from .ava_evaluation import object_detection_evaluation as det_eval from .ava_evaluation import standard_fields def det2csv(dataset, results, custom_classes): csv_results = [] for idx in range(len(dataset)): ...
8,215
33.666667
79
py
STTS
STTS-main/VideoSwin/mmaction/core/evaluation/eval_hooks.py
import os import os.path as osp import warnings from math import inf import torch.distributed as dist from torch.nn.modules.batchnorm import _BatchNorm from torch.utils.data import DataLoader try: from mmcv.runner import EvalHook as BasicEvalHook from mmcv.runner import DistEvalHook as BasicDistEvalHook ...
16,695
41.700767
79
py
STTS
STTS-main/VideoSwin/mmaction/core/evaluation/accuracy.py
import numpy as np def confusion_matrix(y_pred, y_real, normalize=None): """Compute confusion matrix. Args: y_pred (list[int] | np.ndarray[int]): Prediction labels. y_real (list[int] | np.ndarray[int]): Ground truth labels. normalize (str | None): Normalizes confusion matrix over the ...
20,710
38.449524
79
py
STTS
STTS-main/VideoSwin/mmaction/core/evaluation/__init__.py
from .accuracy import (average_precision_at_temporal_iou, average_recall_at_avg_proposals, confusion_matrix, get_weighted_score, interpolated_precision_recall, mean_average_precision, mean_class_accuracy, mmit_mean_average_preci...
866
50
78
py
STTS
STTS-main/VideoSwin/mmaction/core/evaluation/ava_evaluation/per_image_evaluation.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
16,948
46.211699
79
py
STTS
STTS-main/VideoSwin/mmaction/core/evaluation/ava_evaluation/standard_fields.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
5,313
44.810345
79
py
STTS
STTS-main/VideoSwin/mmaction/core/evaluation/ava_evaluation/np_box_list.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
4,923
34.171429
79
py
STTS
STTS-main/VideoSwin/mmaction/core/evaluation/ava_evaluation/metrics.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
5,689
38.79021
79
py
STTS
STTS-main/VideoSwin/mmaction/core/evaluation/ava_evaluation/__init__.py
0
0
0
py
STTS
STTS-main/VideoSwin/mmaction/core/evaluation/ava_evaluation/object_detection_evaluation.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
24,757
42.057391
79
py
STTS
STTS-main/VideoSwin/mmaction/core/evaluation/ava_evaluation/np_box_ops.py
# Copyright 2017 The TensorFlow Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applica...
3,462
33.979798
80
py
STTS
STTS-main/VideoSwin/mmaction/core/bbox/bbox_target.py
import torch import torch.nn.functional as F def bbox_target(pos_bboxes_list, neg_bboxes_list, gt_labels, cfg): """Generate classification targets for bboxes. Args: pos_bboxes_list (list[Tensor]): Positive bboxes list. neg_bboxes_list (list[Tensor]): Negative bboxes list. gt_labels (l...
1,334
30.785714
73
py
STTS
STTS-main/VideoSwin/mmaction/core/bbox/__init__.py
from .assigners import MaxIoUAssignerAVA from .bbox_target import bbox_target from .transforms import bbox2result __all__ = ['MaxIoUAssignerAVA', 'bbox_target', 'bbox2result']
177
28.666667
61
py
STTS
STTS-main/VideoSwin/mmaction/core/bbox/transforms.py
import numpy as np def bbox2result(bboxes, labels, num_classes, thr=0.01): """Convert detection results to a list of numpy arrays. Args: bboxes (Tensor): shape (n, 4) labels (Tensor): shape (n, #num_classes) num_classes (int): class number, including background class thr (floa...
1,167
30.567568
76
py
STTS
STTS-main/VideoSwin/mmaction/core/bbox/assigners/__init__.py
from .max_iou_assigner_ava import MaxIoUAssignerAVA __all__ = ['MaxIoUAssignerAVA']
85
20.5
51
py
STTS
STTS-main/VideoSwin/mmaction/core/bbox/assigners/max_iou_assigner_ava.py
import torch from mmaction.utils import import_module_error_class try: from mmdet.core.bbox import AssignResult, MaxIoUAssigner from mmdet.core.bbox.builder import BBOX_ASSIGNERS mmdet_imported = True except (ImportError, ModuleNotFoundError): mmdet_imported = False if mmdet_imported: @BBOX_ASSI...
6,032
42.402878
79
py
STTS
STTS-main/VideoSwin/mmaction/core/runner/omnisource_runner.py
# Copyright (c) Open-MMLab. All rights reserved. import time import warnings import mmcv from mmcv.runner import EpochBasedRunner, Hook from mmcv.runner.utils import get_host_info def cycle(iterable): iterator = iter(iterable) while True: try: yield next(iterator) except StopItera...
6,589
39.429448
79
py
STTS
STTS-main/VideoSwin/mmaction/core/runner/__init__.py
from .omnisource_runner import OmniSourceDistSamplerSeedHook, OmniSourceRunner __all__ = ['OmniSourceRunner', 'OmniSourceDistSamplerSeedHook']
144
35.25
78
py
STTS
STTS-main/VideoSwin/mmaction/core/hooks/__init__.py
from .output import OutputHook __all__ = ['OutputHook']
57
13.5
30
py
STTS
STTS-main/VideoSwin/mmaction/core/hooks/output.py
import functools import warnings import torch class OutputHook: """Output feature map of some layers. Args: module (nn.Module): The whole module to get layers. outputs (tuple[str] | list[str]): Layer name to output. Default: None. as_tensor (bool): Determine to return a tensor or a n...
2,040
29.014706
84
py
STTS
STTS-main/VideoSwin/mmaction/core/optimizer/topk_optimizer_constructor.py
import torch from mmcv.runner import OPTIMIZER_BUILDERS, DefaultOptimizerConstructor from mmcv.utils import SyncBatchNorm, _BatchNorm, _ConvNd @OPTIMIZER_BUILDERS.register_module() class TopkOptimizerConstructor(DefaultOptimizerConstructor): """Optimizer constructor in TSM model. This constructor builds opti...
2,226
32.238806
77
py
STTS
STTS-main/VideoSwin/mmaction/core/optimizer/tsm_optimizer_constructor.py
import torch from mmcv.runner import OPTIMIZER_BUILDERS, DefaultOptimizerConstructor from mmcv.utils import SyncBatchNorm, _BatchNorm, _ConvNd @OPTIMIZER_BUILDERS.register_module() class TSMOptimizerConstructor(DefaultOptimizerConstructor): """Optimizer constructor in TSM model. This constructor builds optim...
4,074
36.045455
77
py
STTS
STTS-main/VideoSwin/mmaction/core/optimizer/copy_of_sgd.py
from mmcv.runner import OPTIMIZERS from torch.optim import SGD @OPTIMIZERS.register_module() class CopyOfSGD(SGD): """A clone of torch.optim.SGD. A customized optimizer could be defined like CopyOfSGD. You may derive from built-in optimizers in torch.optim, or directly implement a new optimizer. """
320
25.75
79
py
STTS
STTS-main/VideoSwin/mmaction/core/optimizer/__init__.py
from .copy_of_sgd import CopyOfSGD from .tsm_optimizer_constructor import TSMOptimizerConstructor from .topk_optimizer_constructor import TopkOptimizerConstructor __all__ = ['CopyOfSGD', 'TSMOptimizerConstructor', 'TopkOptimizerConstructor']
243
39.666667
78
py
STTS
STTS-main/VideoSwin/mmaction/models/__init__.py
from .backbones import (C3D, X3D, MobileNetV2, MobileNetV2TSM, ResNet, ResNet2Plus1d, ResNet3d, ResNet3dCSN, ResNet3dLayer, ResNet3dSlowFast, ResNet3dSlowOnly, ResNetAudio, ResNetTIN, ResNetTSM, TANet) from .builder import (BACKBONES, DETECTORS, HE...
2,178
57.891892
79
py
STTS
STTS-main/VideoSwin/mmaction/models/builder.py
import warnings from mmcv.cnn import MODELS as MMCV_MODELS from mmcv.utils import Registry from mmaction.utils import import_module_error_func MODELS = Registry('models', parent=MMCV_MODELS) BACKBONES = MODELS NECKS = MODELS HEADS = MODELS RECOGNIZERS = MODELS LOSSES = MODELS LOCALIZERS = MODELS try: from mmdet...
2,741
28.804348
107
py
STTS
STTS-main/VideoSwin/mmaction/models/localizers/base.py
from abc import ABCMeta, abstractmethod from collections import OrderedDict import torch import torch.distributed as dist import torch.nn as nn from .. import builder class BaseLocalizer(nn.Module, metaclass=ABCMeta): """Base class for localizers. All localizers should subclass it. All subclass should over...
5,143
34.722222
79
py
STTS
STTS-main/VideoSwin/mmaction/models/localizers/bsn.py
import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from ...localization import temporal_iop from ..builder import LOCALIZERS, build_loss from .base import BaseLocalizer from .utils import post_processing @LOCALIZERS.register_module() class TEM(BaseLocalizer): """Temporal Evalua...
15,855
39.141772
79
py
STTS
STTS-main/VideoSwin/mmaction/models/localizers/ssn.py
import torch import torch.nn as nn from .. import builder from ..builder import LOCALIZERS from .base import BaseLocalizer @LOCALIZERS.register_module() class SSN(BaseLocalizer): """Temporal Action Detection with Structured Segment Networks. Args: backbone (dict): Config for building backbone. ...
5,048
36.4
79
py
STTS
STTS-main/VideoSwin/mmaction/models/localizers/__init__.py
from .base import BaseLocalizer from .bmn import BMN from .bsn import PEM, TEM from .ssn import SSN __all__ = ['PEM', 'TEM', 'BMN', 'SSN', 'BaseLocalizer']
157
21.571429
55
py
STTS
STTS-main/VideoSwin/mmaction/models/localizers/bmn.py
import math import numpy as np import torch import torch.nn as nn from ...localization import temporal_iop, temporal_iou from ..builder import LOCALIZERS, build_loss from .base import BaseLocalizer from .utils import post_processing @LOCALIZERS.register_module() class BMN(BaseLocalizer): """Boundary Matching Ne...
17,788
41.659472
93
py
STTS
STTS-main/VideoSwin/mmaction/models/localizers/utils/post_processing.py
from mmaction.localization import soft_nms def post_processing(result, video_info, soft_nms_alpha, soft_nms_low_threshold, soft_nms_high_threshold, post_process_top_k, feature_extraction_interval): """Post process for temporal proposals generation. Args: result...
1,807
39.177778
79
py
STTS
STTS-main/VideoSwin/mmaction/models/localizers/utils/__init__.py
from .post_processing import post_processing __all__ = ['post_processing']
76
18.25
44
py
STTS
STTS-main/VideoSwin/mmaction/models/recognizers/base.py
import warnings from abc import ABCMeta, abstractmethod from collections import OrderedDict import torch import torch.distributed as dist import torch.nn as nn import torch.nn.functional as F from mmcv.runner import auto_fp16 from .. import builder class BaseRecognizer(nn.Module, metaclass=ABCMeta): """Base cla...
12,392
36.554545
79
py
STTS
STTS-main/VideoSwin/mmaction/models/recognizers/recognizer3d.py
import torch from torch import nn from ..builder import RECOGNIZERS from .base import BaseRecognizer def copyParams(module_src, module_dest): params_src = module_src.named_parameters() params_dest = module_dest.named_parameters() dict_dest = dict(params_dest) for name, param in params_src: ...
4,166
30.330827
78
py
STTS
STTS-main/VideoSwin/mmaction/models/recognizers/recognizer2d.py
import torch from torch import nn from ..builder import RECOGNIZERS from .base import BaseRecognizer @RECOGNIZERS.register_module() class Recognizer2D(BaseRecognizer): """2D recognizer model framework.""" def forward_train(self, imgs, labels, **kwargs): """Defines the computation performed at every ...
6,572
34.33871
79
py
STTS
STTS-main/VideoSwin/mmaction/models/recognizers/__init__.py
from .audio_recognizer import AudioRecognizer from .base import BaseRecognizer from .recognizer2d import Recognizer2D from .recognizer3d import Recognizer3D __all__ = ['BaseRecognizer', 'Recognizer2D', 'Recognizer3D', 'AudioRecognizer']
238
33.142857
79
py
STTS
STTS-main/VideoSwin/mmaction/models/recognizers/audio_recognizer.py
from ..builder import RECOGNIZERS from .base import BaseRecognizer @RECOGNIZERS.register_module() class AudioRecognizer(BaseRecognizer): """Audio recognizer model framework.""" def forward(self, audios, label=None, return_loss=True): """Define the computation performed at every call.""" if re...
3,632
34.617647
79
py
STTS
STTS-main/VideoSwin/mmaction/models/common/tam.py
import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import constant_init, kaiming_init, normal_init class TAM(nn.Module): """Temporal Adaptive Module(TAM) for TANet. This module is proposed in `TAM: TEMPORAL ADAPTIVE MODULE FOR VIDEO RECOGNITION <https://arxiv.org/pdf/2005.06803>`_ A...
5,051
36.422222
79
py
STTS
STTS-main/VideoSwin/mmaction/models/common/conv_audio.py
import torch import torch.nn as nn from mmcv.cnn import CONV_LAYERS, ConvModule, constant_init, kaiming_init from torch.nn.modules.utils import _pair @CONV_LAYERS.register_module() class ConvAudio(nn.Module): """Conv2d module for AudioResNet backbone. <https://arxiv.org/abs/2001.08740>`_. Args: ...
3,225
29.72381
77
py
STTS
STTS-main/VideoSwin/mmaction/models/common/lfb.py
import io import os.path as osp import warnings import numpy as np import torch import torch.distributed as dist from mmcv.runner import get_dist_info try: import lmdb lmdb_imported = True except (ImportError, ModuleNotFoundError): lmdb_imported = False class LFB: """Long-Term Feature Bank (LFB). ...
7,493
38.650794
79
py
STTS
STTS-main/VideoSwin/mmaction/models/common/conv2plus1d.py
import torch.nn as nn from mmcv.cnn import CONV_LAYERS, build_norm_layer, constant_init, kaiming_init from torch.nn.modules.utils import _triple @CONV_LAYERS.register_module() class Conv2plus1d(nn.Module): """(2+1)d Conv module for R(2+1)d backbone. https://arxiv.org/pdf/1711.11248.pdf. Args: in...
3,453
31.895238
79
py
STTS
STTS-main/VideoSwin/mmaction/models/common/__init__.py
from .conv2plus1d import Conv2plus1d from .conv_audio import ConvAudio from .lfb import LFB from .tam import TAM __all__ = ['Conv2plus1d', 'ConvAudio', 'LFB', 'TAM']
167
23
52
py
STTS
STTS-main/VideoSwin/mmaction/models/necks/tpn.py
import numpy as np import torch import torch.nn as nn from mmcv.cnn import ConvModule, constant_init, normal_init, xavier_init from ..builder import NECKS, build_loss class Identity(nn.Module): """Identity mapping.""" def forward(self, x): return x class DownSample(nn.Module): """DownSample mo...
16,411
35.552339
79
py
STTS
STTS-main/VideoSwin/mmaction/models/necks/__init__.py
from .tpn import TPN __all__ = ['TPN']
40
9.25
20
py
STTS
STTS-main/VideoSwin/mmaction/models/roi_extractors/__init__.py
from .single_straight3d import SingleRoIExtractor3D __all__ = ['SingleRoIExtractor3D']
88
21.25
51
py
STTS
STTS-main/VideoSwin/mmaction/models/roi_extractors/single_straight3d.py
import torch import torch.nn as nn import torch.nn.functional as F from mmaction.utils import import_module_error_class try: from mmcv.ops import RoIAlign, RoIPool except (ImportError, ModuleNotFoundError): @import_module_error_class('mmcv-full') class RoIAlign(nn.Module): pass @import_modul...
4,474
33.689922
79
py
STTS
STTS-main/VideoSwin/mmaction/models/losses/base.py
from abc import ABCMeta, abstractmethod import torch.nn as nn class BaseWeightedLoss(nn.Module, metaclass=ABCMeta): """Base class for loss. All subclass should overwrite the ``_forward()`` method which returns the normal loss without loss weights. Args: loss_weight (float): Factor scalar mu...
1,181
25.266667
77
py
STTS
STTS-main/VideoSwin/mmaction/models/losses/margin_loss.py
import torch import torch.nn.functional as F import torch.nn as nn from ..builder import LOSSES def batched_index_select(input, dim, index): for i in range(1, len(input.shape)): if i != dim: index = index.unsqueeze(i) expanse = list(input.shape) expanse[0] = -1 expanse[dim] = -1 ...
2,004
34.175439
91
py
STTS
STTS-main/VideoSwin/mmaction/models/losses/distill_loss.py
import torch.nn.functional as F import torch.nn as nn from ..builder import LOSSES @LOSSES.register_module() class DistillationLoss(nn.Module): """ This module wraps a standard criterion and adds an extra knowledge distillation loss by taking a teacher model prediction and using it as additional supervis...
2,144
34.75
91
py
STTS
STTS-main/VideoSwin/mmaction/models/losses/ohem_hinge_loss.py
import torch class OHEMHingeLoss(torch.autograd.Function): """This class is the core implementation for the completeness loss in paper. It compute class-wise hinge loss and performs online hard example mining (OHEM). """ @staticmethod def forward(ctx, pred, labels, is_positive, ohem_rati...
2,497
37.430769
77
py
STTS
STTS-main/VideoSwin/mmaction/models/losses/bmn_loss.py
import torch import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .binary_logistic_regression_loss import binary_logistic_regression_loss @LOSSES.register_module() class BMNLoss(nn.Module): """BMN Loss. From paper https://arxiv.org/abs/1907.09702, code https://github.c...
7,173
38.635359
79
py
STTS
STTS-main/VideoSwin/mmaction/models/losses/nll_loss.py
import torch.nn.functional as F from ..builder import LOSSES from .base import BaseWeightedLoss @LOSSES.register_module() class NLLLoss(BaseWeightedLoss): """NLL Loss. It will calculate NLL loss given cls_score and label. """ def _forward(self, cls_score, label, **kwargs): """Forward functi...
688
24.518519
74
py
STTS
STTS-main/VideoSwin/mmaction/models/losses/hvu_loss.py
import torch import torch.nn.functional as F from ..builder import LOSSES from .base import BaseWeightedLoss @LOSSES.register_module() class HVULoss(BaseWeightedLoss): """Calculate the BCELoss for HVU. Args: categories (tuple[str]): Names of tag categories, tags are organized in this ord...
6,676
46.021127
79
py
STTS
STTS-main/VideoSwin/mmaction/models/losses/binary_logistic_regression_loss.py
import torch import torch.nn as nn from ..builder import LOSSES def binary_logistic_regression_loss(reg_score, label, threshold=0.5, ratio_range=(1.05, 21), eps=1e-5): "...
2,061
32.258065
75
py
STTS
STTS-main/VideoSwin/mmaction/models/losses/ssn_loss.py
import torch import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .ohem_hinge_loss import OHEMHingeLoss @LOSSES.register_module() class SSNLoss(nn.Module): @staticmethod def activity_loss(activity_score, labels, activity_indexer): """Activity Loss. It will...
7,274
39.416667
102
py
STTS
STTS-main/VideoSwin/mmaction/models/losses/cross_entropy_loss.py
import torch import torch.nn.functional as F import torch.nn as nn from ..builder import LOSSES from .base import BaseWeightedLoss @LOSSES.register_module() class CrossEntropyLoss(BaseWeightedLoss): """Cross Entropy Loss. Support two kinds of labels and their corresponding loss type. It's worth mentionin...
4,774
39.12605
132
py
STTS
STTS-main/VideoSwin/mmaction/models/losses/__init__.py
from .base import BaseWeightedLoss from .binary_logistic_regression_loss import BinaryLogisticRegressionLoss from .bmn_loss import BMNLoss from .cross_entropy_loss import BCELossWithLogits, CrossEntropyLoss from .hvu_loss import HVULoss from .nll_loss import NLLLoss from .ohem_hinge_loss import OHEMHingeLoss from .ssn_...
520
33.733333
75
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/mobilenet_v2.py
import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import ConvModule, constant_init, kaiming_init from mmcv.runner import load_checkpoint from torch.nn.modules.batchnorm import _BatchNorm from ...utils import get_root_logger from ..builder import BACKBONES def make_divisible(value, divisor, min_...
10,933
35.691275
79
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/c3d.py
import torch.nn as nn from mmcv.cnn import ConvModule, constant_init, kaiming_init, normal_init from mmcv.runner import load_checkpoint from mmcv.utils import _BatchNorm from ...utils import get_root_logger from ..builder import BACKBONES @BACKBONES.register_module() class C3D(nn.Module): """C3D backbone. A...
4,771
33.085714
79
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/checkpoint.py
# Copyright (c) OpenMMLab. All rights reserved. import io import os import os.path as osp import pkgutil import re import time import warnings from collections import OrderedDict from importlib import import_module from tempfile import TemporaryDirectory import torch import torchvision from torch.optim import Optimize...
24,129
34.021771
79
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/resnet3d_slowonly.py
from ..builder import BACKBONES from .resnet3d_slowfast import ResNet3dPathway try: from mmdet.models.builder import BACKBONES as MMDET_BACKBONES mmdet_imported = True except (ImportError, ModuleNotFoundError): mmdet_imported = False @BACKBONES.register_module() class ResNet3dSlowOnly(ResNet3dPathway): ...
1,643
30.018868
74
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/resnet3d_csn.py
import torch.nn as nn from mmcv.cnn import ConvModule from mmcv.utils import _BatchNorm from ..builder import BACKBONES from .resnet3d import Bottleneck3d, ResNet3d class CSNBottleneck3d(Bottleneck3d): """Channel-Separated Bottleneck Block. This module is proposed in "Video Classification with Channel-S...
6,234
40.845638
79
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/swin_transformer.py
import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as checkpoint import numpy as np from timm.models.layers import DropPath, trunc_normal_ # from mmcv.runner import load_checkpoint from .checkpoint import load_checkpoint from mmaction.utils import get_root_logger from ..bu...
30,486
40.032301
156
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/resnet.py
import torch.nn as nn from mmcv.cnn import ConvModule, constant_init, kaiming_init from mmcv.runner import _load_checkpoint, load_checkpoint from mmcv.utils import _BatchNorm from torch.utils import checkpoint as cp from ...utils import get_root_logger from ..builder import BACKBONES class BasicBlock(nn.Module): ...
21,448
35.292724
79
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/resnet_audio.py
import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import ConvModule, constant_init, kaiming_init from mmcv.runner import load_checkpoint from torch.nn.modules.batchnorm import _BatchNorm from torch.nn.modules.utils import _ntuple from ...utils import get_root_logger from ..builder import BACKBONE...
13,252
34.435829
79
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/topk.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np import einops from einops import rearrange from math import sqrt class PredictorLG(nn.Module): """ Image to Patch Embedding """ def __init__(self, embed_dim=384): super().__init__() self.in_conv = nn.Seque...
8,524
33.375
124
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/resnet3d.py
import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import (ConvModule, NonLocal3d, build_activation_layer, constant_init, kaiming_init) from mmcv.runner import _load_checkpoint, load_checkpoint from mmcv.utils import _BatchNorm from torch.nn.modules.utils import _ntuple, _trip...
40,219
38.277344
79
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/resnet3d_slowfast.py
import torch import torch.nn as nn from mmcv.cnn import ConvModule, kaiming_init from mmcv.runner import _load_checkpoint, load_checkpoint from mmcv.utils import print_log from ...utils import get_root_logger from ..builder import BACKBONES from .resnet3d import ResNet3d try: from mmdet.models import BACKBONES as...
21,060
39.424184
79
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/resnet2plus1d.py
from ..builder import BACKBONES from .resnet3d import ResNet3d @BACKBONES.register_module() class ResNet2Plus1d(ResNet3d): """ResNet (2+1)d backbone. This model is proposed in `A Closer Look at Spatiotemporal Convolutions for Action Recognition <https://arxiv.org/abs/1711.11248>`_ """ def __init...
1,482
28.66
79
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/mobilenet_v2_tsm.py
from ..builder import BACKBONES from .mobilenet_v2 import InvertedResidual, MobileNetV2 from .resnet_tsm import TemporalShift @BACKBONES.register_module() class MobileNetV2TSM(MobileNetV2): """MobileNetV2 backbone for TSM. Args: num_segments (int): Number of frame segments. Default: 8. is_shi...
1,416
33.560976
77
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/resnet_tsm.py
import torch import torch.nn as nn from mmcv.cnn import NonLocal3d from torch.nn.modules.utils import _ntuple from ..builder import BACKBONES from .resnet import ResNet class NL3DWrapper(nn.Module): """3D Non-local wrapper for ResNet50. Wrap ResNet layers with 3D NonLocal modules. Args: block (...
10,742
35.416949
79
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/resnet_tin.py
import torch import torch.nn as nn from mmaction.utils import import_module_error_func from ..builder import BACKBONES from .resnet_tsm import ResNetTSM try: from mmcv.ops import tin_shift except (ImportError, ModuleNotFoundError): @import_module_error_func('mmcv-full') def tin_shift(*args, **kwargs): ...
13,132
33.651715
79
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/__init__.py
from .c3d import C3D from .mobilenet_v2 import MobileNetV2 from .mobilenet_v2_tsm import MobileNetV2TSM from .resnet import ResNet from .resnet2plus1d import ResNet2Plus1d from .resnet3d import ResNet3d, ResNet3dLayer from .resnet3d_csn import ResNet3dCSN from .resnet3d_slowfast import ResNet3dSlowFast from .resnet3d_s...
807
35.727273
97
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/tanet.py
from copy import deepcopy import torch.nn as nn from torch.utils import checkpoint as cp from ..builder import BACKBONES from ..common import TAM from .resnet import Bottleneck, ResNet class TABlock(nn.Module): """Temporal Adaptive Block (TA-Block) for TANet. This block is proposed in `TAM: TEMPORAL ADAPTI...
3,690
31.095652
79
py
STTS
STTS-main/VideoSwin/mmaction/models/backbones/x3d.py
import math import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import (ConvModule, Swish, build_activation_layer, constant_init, kaiming_init) from mmcv.runner import load_checkpoint from mmcv.utils import _BatchNorm from ...utils import get_root_logger from ..builder import...
19,116
35.482824
79
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/base.py
from abc import ABCMeta, abstractmethod import torch import torch.nn as nn from ...core import top_k_accuracy from ..builder import build_loss class AvgConsensus(nn.Module): """Average consensus module. Args: dim (int): Decide which dim consensus function to apply. Default: 1. """ ...
3,854
34.045455
79
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/fbo_head.py
import copy import torch import torch.nn as nn from mmcv.cnn import ConvModule, constant_init, kaiming_init from mmcv.runner import load_checkpoint from mmcv.utils import _BatchNorm from mmaction.models.common import LFB from mmaction.utils import get_root_logger try: from mmdet.models.builder import SHARED_HEAD...
14,120
34.390977
79
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/ssn_head.py
import torch import torch.nn as nn from mmcv.cnn import normal_init from ..builder import HEADS def parse_stage_config(stage_cfg): """Parse config of STPP for three stages. Args: stage_cfg (int | tuple[int]): Config of structured temporal pyramid pooling. Returns: tuple[tupl...
16,778
39.627119
79
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/audio_tsn_head.py
import torch.nn as nn from mmcv.cnn import normal_init from ..builder import HEADS from .base import BaseHead @HEADS.register_module() class AudioTSNHead(BaseHead): """Classification head for TSN on audio. Args: num_classes (int): Number of classes to be classified. in_channels (int): Number...
2,421
31.72973
79
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/trn_head.py
import itertools import numpy as np import torch import torch.nn as nn from mmcv.cnn import normal_init from ..builder import HEADS from .base import BaseHead class RelationModule(nn.Module): """Relation Module of TRN. Args: hidden_dim (int): The dimension of hidden layer of MLP in relation ...
7,868
36.293839
79
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/tsm_head.py
import torch import torch.nn as nn from mmcv.cnn import normal_init from ..builder import HEADS from .base import AvgConsensus, BaseHead @HEADS.register_module() class TSMHead(BaseHead): """Class head for TSM. Args: num_classes (int): Number of classes to be classified. in_channels (int): Nu...
4,170
36.241071
78
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/bbox_head.py
import torch import torch.nn as nn import torch.nn.functional as F from mmaction.core.bbox import bbox_target try: from mmdet.models.builder import HEADS as MMDET_HEADS mmdet_imported = True except (ImportError, ModuleNotFoundError): mmdet_imported = False class BBoxHeadAVA(nn.Module): """Simplest R...
8,768
34.358871
79
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/misc_head.py
import torch import torch.nn as nn from mmcv.cnn import ConvModule, constant_init, kaiming_init from mmcv.utils import _BatchNorm try: from mmdet.models.builder import SHARED_HEADS as MMDET_SHARED_HEADS mmdet_imported = True except (ImportError, ModuleNotFoundError): mmdet_imported = False # Note: All the...
4,040
29.613636
76
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/tpn_head.py
import torch.nn as nn from ..builder import HEADS from .tsn_head import TSNHead @HEADS.register_module() class TPNHead(TSNHead): """Class head for TPN. Args: num_classes (int): Number of classes to be classified. in_channels (int): Number of channels in input feature. loss_cls (dict)...
3,306
35.340659
78
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/x3d_head.py
import torch.nn as nn from mmcv.cnn import normal_init from ..builder import HEADS from .base import BaseHead @HEADS.register_module() class X3DHead(BaseHead): """Classification head for I3D. Args: num_classes (int): Number of classes to be classified. in_channels (int): Number of channels i...
2,837
30.533333
78
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/slowfast_head.py
import torch import torch.nn as nn from mmcv.cnn import normal_init from ..builder import HEADS from .base import BaseHead @HEADS.register_module() class SlowFastHead(BaseHead): """The classification head for SlowFast. Args: num_classes (int): Number of classes to be classified. in_channels ...
2,542
30.7875
78
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/tsn_head.py
import torch.nn as nn from mmcv.cnn import normal_init from ..builder import HEADS from .base import AvgConsensus, BaseHead @HEADS.register_module() class TSNHead(BaseHead): """Class head for TSN. Args: num_classes (int): Number of classes to be classified. in_channels (int): Number of chann...
3,148
33.228261
79
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/__init__.py
from .audio_tsn_head import AudioTSNHead from .base import BaseHead from .bbox_head import BBoxHeadAVA from .fbo_head import FBOHead from .i3d_head import I3DHead from .lfb_infer_head import LFBInferHead from .misc_head import ACRNHead from .roi_head import AVARoIHead from .slowfast_head import SlowFastHead from .ssn_h...
704
31.045455
75
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/lfb_infer_head.py
import os.path as osp import mmcv import torch import torch.distributed as dist import torch.nn as nn from mmcv.runner import get_dist_info try: from mmdet.models.builder import SHARED_HEADS as MMDET_SHARED_HEADS mmdet_imported = True except (ImportError, ModuleNotFoundError): mmdet_imported = False cla...
5,150
34.280822
79
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/i3d_head.py
import torch.nn as nn from mmcv.cnn import normal_init from ..builder import HEADS from .base import BaseHead @HEADS.register_module() class I3DHead(BaseHead): """Classification head for I3D. Args: num_classes (int): Number of classes to be classified. in_channels (int): Number of channels i...
2,446
32.067568
78
py
STTS
STTS-main/VideoSwin/mmaction/models/heads/roi_head.py
import numpy as np from mmaction.core.bbox import bbox2result from mmaction.utils import import_module_error_class try: from mmdet.core.bbox import bbox2roi from mmdet.models import HEADS as MMDET_HEADS from mmdet.models.roi_heads import StandardRoIHead mmdet_imported = True except (ImportError, Modul...
4,487
35.487805
79
py
STTS
STTS-main/VideoSwin/mmaction/localization/bsn_utils.py
import os.path as osp import numpy as np from .proposal_utils import temporal_iop, temporal_iou def generate_candidate_proposals(video_list, video_infos, tem_results_dir, temporal_scale, ...
11,496
41.899254
79
py
STTS
STTS-main/VideoSwin/mmaction/localization/proposal_utils.py
import numpy as np def temporal_iou(proposal_min, proposal_max, gt_min, gt_max): """Compute IoU score between a groundtruth bbox and the proposals. Args: proposal_min (list[float]): List of temporal anchor min. proposal_max (list[float]): List of temporal anchor max. gt_min (float): G...
3,450
35.326316
77
py
STTS
STTS-main/VideoSwin/mmaction/localization/__init__.py
from .bsn_utils import generate_bsp_feature, generate_candidate_proposals from .proposal_utils import soft_nms, temporal_iop, temporal_iou from .ssn_utils import (eval_ap, load_localize_proposal_file, perform_regression, temporal_nms) __all__ = [ 'generate_candidate_proposals', 'generate_bs...
465
41.363636
75
py
STTS
STTS-main/VideoSwin/mmaction/localization/ssn_utils.py
from itertools import groupby import numpy as np from ..core import average_precision_at_temporal_iou from . import temporal_iou def load_localize_proposal_file(filename): """Load the proposal file and split it into many parts which contain one video's information separately. Args: filename(str...
4,902
28.011834
76
py
STTS
STTS-main/VideoSwin/mmaction/datasets/base.py
import copy import os.path as osp import warnings from abc import ABCMeta, abstractmethod from collections import OrderedDict, defaultdict import mmcv import numpy as np import torch from mmcv.utils import print_log from torch.utils.data import Dataset from ..core import (mean_average_precision, mean_class_accuracy, ...
11,612
39.322917
105
py
STTS
STTS-main/VideoSwin/mmaction/datasets/rawvideo_dataset.py
import copy import os.path as osp import random import mmcv from .base import BaseDataset from .builder import DATASETS @DATASETS.register_module() class RawVideoDataset(BaseDataset): """RawVideo dataset for action recognition, used in the Project OmniSource. The dataset loads clips of raw videos and apply...
5,635
37.340136
79
py
STTS
STTS-main/VideoSwin/mmaction/datasets/audio_visual_dataset.py
import os.path as osp from .builder import DATASETS from .rawframe_dataset import RawframeDataset @DATASETS.register_module() class AudioVisualDataset(RawframeDataset): """Dataset that reads both audio and visual data, supporting both rawframes and videos. The annotation file is same as that of the rawframe ...
3,073
38.922078
79
py