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/datasets/pose_dataset.py | import os.path as osp
import mmcv
import numpy as np
from ..utils import get_root_logger
from .base import BaseDataset
from .builder import DATASETS
@DATASETS.register_module()
class PoseDataset(BaseDataset):
"""Pose dataset for action recognition.
The dataset loads pose and apply specified transforms to r... | 3,757 | 36.959596 | 79 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/audio_dataset.py | import os.path as osp
import torch
from .base import BaseDataset
from .builder import DATASETS
@DATASETS.register_module()
class AudioDataset(BaseDataset):
"""Audio dataset for video recognition. Extracts the audio feature on-the-
fly. Annotation file can be that of the rawframe dataset, or:
.. code-bl... | 2,555 | 35.514286 | 78 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/image_dataset.py | from .builder import DATASETS
from .video_dataset import VideoDataset
@DATASETS.register_module()
class ImageDataset(VideoDataset):
"""Image dataset for action recognition, used in the Project OmniSource.
The dataset loads image list and apply specified transforms to return a
dict containing the image te... | 1,420 | 29.891304 | 76 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/audio_feature_dataset.py | import os.path as osp
import torch
from .base import BaseDataset
from .builder import DATASETS
@DATASETS.register_module()
class AudioFeatureDataset(BaseDataset):
"""Audio feature dataset for video recognition. Reads the features
extracted off-line. Annotation file can be that of the rawframe dataset,
o... | 2,581 | 35.366197 | 76 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/ava_dataset.py | import copy
import os
import os.path as osp
from collections import defaultdict
from datetime import datetime
import mmcv
import numpy as np
from mmcv.utils import print_log
from ..core.evaluation.ava_utils import ava_eval, read_labelmap, results2csv
from ..utils import get_root_logger
from .base import BaseDataset
f... | 15,430 | 39.289817 | 79 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/blending_utils.py | from abc import ABCMeta, abstractmethod
import torch
import torch.nn.functional as F
from torch.distributions.beta import Beta
from .builder import BLENDINGS
__all__ = ['BaseMiniBatchBlending', 'MixupBlending', 'CutmixBlending', 'LabelSmoothing']
def one_hot(x, num_classes, on_value=1., off_value=0., device='cuda')... | 5,741 | 36.529412 | 139 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/rawframe_dataset.py | import copy
import os.path as osp
import torch
from .base import BaseDataset
from .builder import DATASETS
@DATASETS.register_module()
class RawframeDataset(BaseDataset):
"""Rawframe dataset for action recognition.
The dataset loads raw frames and apply specified transforms to return a
dict containing ... | 6,689 | 35.358696 | 78 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/dataset_wrappers.py | from .builder import DATASETS
@DATASETS.register_module()
class RepeatDataset:
"""A wrapper of repeated dataset.
The length of repeated dataset will be ``times`` larger than the original
dataset. This is useful when the data loading time is long but the dataset
is small. Using RepeatDataset can reduc... | 833 | 25.903226 | 78 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/video_dataset.py | import os.path as osp
from .base import BaseDataset
from .builder import DATASETS
@DATASETS.register_module()
class VideoDataset(BaseDataset):
"""Video dataset for action recognition.
The dataset loads raw videos and apply specified transforms to return a
dict containing the frame tensors and other info... | 2,323 | 35.3125 | 79 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/hvu_dataset.py | import copy
import os.path as osp
from collections import OrderedDict
import mmcv
import numpy as np
from mmcv.utils import print_log
from ..core import mean_average_precision
from .base import BaseDataset
from .builder import DATASETS
@DATASETS.register_module()
class HVUDataset(BaseDataset):
"""HVU dataset, w... | 7,052 | 35.734375 | 79 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/ssn_dataset.py | import copy
import os.path as osp
import warnings
from collections import OrderedDict
import mmcv
import numpy as np
from torch.nn.modules.utils import _pair
from ..core import softmax
from ..localization import (eval_ap, load_localize_proposal_file,
perform_regression, temporal_iou, tempo... | 37,498 | 41.515873 | 120 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/__init__.py | from .activitynet_dataset import ActivityNetDataset
from .audio_dataset import AudioDataset
from .audio_feature_dataset import AudioFeatureDataset
from .audio_visual_dataset import AudioVisualDataset
from .ava_dataset import AVADataset
from .base import BaseDataset
from .blending_utils import (BaseMiniBatchBlending, Cu... | 1,262 | 44.107143 | 93 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/builder.py | import platform
import random
from functools import partial
import numpy as np
from mmcv.parallel import collate
from mmcv.runner import get_dist_info
from mmcv.utils import Registry, build_from_cfg
from torch.utils.data import DataLoader
from .samplers import ClassSpecificDistributedSampler, DistributedSampler
if p... | 4,449 | 32.458647 | 79 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/activitynet_dataset.py | import copy
import os
import os.path as osp
import warnings
from collections import OrderedDict
import mmcv
import numpy as np
from ..core import average_recall_at_avg_proposals
from .base import BaseDataset
from .builder import DATASETS
@DATASETS.register_module()
class ActivityNetDataset(BaseDataset):
"""Acti... | 10,279 | 37.074074 | 105 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/samplers/distributed_sampler.py | import math
from collections import defaultdict
import torch
from torch.utils.data import DistributedSampler as _DistributedSampler
class DistributedSampler(_DistributedSampler):
"""DistributedSampler inheriting from
``torch.utils.data.DistributedSampler``.
In pytorch of lower versions, there is no ``sh... | 4,908 | 35.362963 | 78 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/samplers/__init__.py | from .distributed_sampler import (ClassSpecificDistributedSampler,
DistributedSampler)
__all__ = ['DistributedSampler', 'ClassSpecificDistributedSampler']
| 190 | 37.2 | 67 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/pipelines/loading.py | import io
import os
import os.path as osp
import shutil
import warnings
import mmcv
import numpy as np
import torch
from mmcv.fileio import FileClient
from torch.nn.modules.utils import _pair
from ...utils import get_random_string, get_shm_dir, get_thread_id
from ..builder import PIPELINES
import random
@PIPELINES.... | 60,896 | 35.334726 | 143 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/pipelines/compose.py | from collections.abc import Sequence
from mmcv.utils import build_from_cfg
from ..builder import PIPELINES
@PIPELINES.register_module()
class Compose:
"""Compose a data pipeline with a sequence of transforms.
Args:
transforms (list[dict | callable]):
Either config dicts of transforms or... | 1,537 | 28.018868 | 73 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/pipelines/pose_loading.py | import copy as cp
import pickle
import numpy as np
from mmcv.fileio import FileClient
from scipy.stats import mode
from ..builder import PIPELINES
from .augmentations import Flip
@PIPELINES.register_module()
class UniformSampleFrames:
"""Uniformly sample frames from the video.
To sample an n-frame clip fro... | 23,181 | 35.73851 | 79 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/pipelines/augmentations.py | import random
import warnings
from collections.abc import Sequence
import mmcv
import numpy as np
from torch.nn.modules.utils import _pair
import timm.data as tdata
import torch
from ..builder import PIPELINES
def _combine_quadruple(a, b):
return (a[0] + a[2] * b[0], a[1] + a[3] * b[1], a[2] * b[2], a[3] * b[3]... | 79,509 | 37.207593 | 104 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/pipelines/formating.py | from collections.abc import Sequence
import mmcv
import numpy as np
import torch
from mmcv.parallel import DataContainer as DC
from ..builder import PIPELINES
def to_tensor(data):
"""Convert objects of various python types to :obj:`torch.Tensor`.
Supported types are: :class:`numpy.ndarray`, :class:`torch.T... | 12,741 | 33.160858 | 79 | py |
STTS | STTS-main/VideoSwin/mmaction/datasets/pipelines/__init__.py | from .augmentations import (AudioAmplify, CenterCrop, ColorJitter,
EntityBoxCrop, EntityBoxFlip, EntityBoxRescale,
Flip, Fuse, Imgaug, MelSpectrogram, MultiGroupCrop,
MultiScaleCrop, Normalize, RandomCrop, RandomErasing,
... | 2,452 | 61.897436 | 89 | py |
STTS | STTS-main/VideoSwin/mmaction/utils/gradcam_utils.py | import torch
import torch.nn.functional as F
class GradCAM:
"""GradCAM class helps create visualization results.
Visualization results are blended by heatmaps and input images.
This class is modified from
https://github.com/facebookresearch/SlowFast/blob/master/slowfast/visualization/gradcam_utils.py... | 9,645 | 40.577586 | 107 | py |
STTS | STTS-main/VideoSwin/mmaction/utils/misc.py | import ctypes
import random
import string
def get_random_string(length=15):
"""Get random string with letters and digits.
Args:
length (int): Length of random string. Default: 15.
"""
return ''.join(
random.choice(string.ascii_letters + string.digits)
for _ in range(length))
... | 570 | 20.148148 | 59 | py |
STTS | STTS-main/VideoSwin/mmaction/utils/logger.py | import logging
from mmcv.utils import get_logger
def get_root_logger(log_file=None, log_level=logging.INFO):
"""Use ``get_logger`` method in mmcv to get the root logger.
The logger will be initialized if it has not been initialized. By default a
StreamHandler will be added. If ``log_file`` is specified,... | 917 | 35.72 | 79 | py |
STTS | STTS-main/VideoSwin/mmaction/utils/precise_bn.py | # Adapted from https://github.com/facebookresearch/fvcore/blob/master/fvcore/nn/precise_bn.py # noqa: E501
# Original licence: Copyright (c) 2019 Facebook, Inc under the Apache License 2.0 # noqa: E501
import logging
import time
import mmcv
import torch
from mmcv.parallel import MMDistributedDataParallel
from mmcv.... | 5,826 | 36.352564 | 107 | py |
STTS | STTS-main/VideoSwin/mmaction/utils/collect_env.py | from mmcv.utils import collect_env as collect_basic_env
from mmcv.utils import get_git_hash
import mmaction
def collect_env():
env_info = collect_basic_env()
env_info['MMAction2'] = (
mmaction.__version__ + '+' + get_git_hash(digits=7))
return env_info
if __name__ == '__main__':
for name, v... | 381 | 21.470588 | 60 | py |
STTS | STTS-main/VideoSwin/mmaction/utils/module_hooks.py | import torch
from mmcv.utils import Registry, build_from_cfg
MODULE_HOOKS = Registry('module_hooks')
def register_module_hooks(Module, module_hooks_list):
handles = []
for module_hook_cfg in module_hooks_list:
hooked_module_name = module_hook_cfg.pop('hooked_module', 'backbone')
if not hasatt... | 3,371 | 37.318182 | 77 | py |
STTS | STTS-main/VideoSwin/mmaction/utils/__init__.py | from .collect_env import collect_env
from .decorators import import_module_error_class, import_module_error_func
from .gradcam_utils import GradCAM
from .logger import get_root_logger
from .misc import get_random_string, get_shm_dir, get_thread_id
from .module_hooks import register_module_hooks
from .precise_bn import ... | 620 | 37.8125 | 76 | py |
STTS | STTS-main/VideoSwin/mmaction/utils/decorators.py | from types import MethodType
def import_module_error_func(module_name):
"""When a function is imported incorrectly due to a missing module, raise
an import error when the function is called."""
def decorate(func):
def new_func(*args, **kwargs):
raise ImportError(
f'Pl... | 870 | 25.393939 | 77 | py |
STTS | STTS-main/VideoSwin/mmaction/utils/optimizer.py | from mmcv.runner import OptimizerHook, HOOKS
try:
import apex
except:
print('apex is not installed')
@HOOKS.register_module()
class DistOptimizerHook(OptimizerHook):
"""Optimizer hook for distributed training."""
def __init__(self, update_interval=1, grad_clip=None, coalesce=True, bucket_size_mb=-1, ... | 1,158 | 33.088235 | 108 | py |
STTS | STTS-main/VideoSwin/tests/test_runtime/test_train.py | import copy
import tempfile
from collections import OrderedDict
import pytest
import torch
import torch.nn as nn
from mmcv import Config
from torch.utils.data import Dataset
from mmaction.apis import train_model
from mmaction.datasets import DATASETS
@DATASETS.register_module()
class ExampleDataset(Dataset):
d... | 4,059 | 29.298507 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_runtime/test_optimizer.py | import torch
import torch.nn as nn
from mmcv.runner import build_optimizer_constructor
class SubModel(nn.Module):
def __init__(self):
super().__init__()
self.conv1 = nn.Conv2d(2, 2, kernel_size=1, groups=2)
self.gn = nn.GroupNorm(2, 2)
self.fc = nn.Linear(2, 2)
self.param1... | 7,742 | 35.182243 | 76 | py |
STTS | STTS-main/VideoSwin/tests/test_runtime/test_config.py | import glob
import os
import os.path as osp
import mmcv
import torch.nn as nn
from mmaction.models import build_localizer, build_recognizer
def _get_config_path():
"""Find the predefined recognizer config path."""
repo_dir = osp.dirname(osp.dirname(osp.dirname(__file__)))
config_dpath = osp.join(repo_di... | 2,887 | 38.027027 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_runtime/test_eval_hook.py | import os.path as osp
import tempfile
import unittest.mock as mock
import warnings
from collections import OrderedDict
from unittest.mock import MagicMock, patch
import pytest
import torch
import torch.nn as nn
from mmcv.runner import EpochBasedRunner, IterBasedRunner
from mmcv.utils import get_logger
from torch.utils... | 12,595 | 35.616279 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_runtime/test_precise_bn.py | import copy
import numpy as np
import pytest
import torch
import torch.nn as nn
from mmcv.parallel import MMDistributedDataParallel
from mmcv.runner import EpochBasedRunner, build_optimizer
from mmcv.utils import get_logger
from torch.utils.data import DataLoader, Dataset
from mmaction.utils import PreciseBNHook
cl... | 6,456 | 30.497561 | 78 | py |
STTS | STTS-main/VideoSwin/tests/test_runtime/test_inference.py | import mmcv
import numpy as np
import pytest
import torch
import torch.nn as nn
from mmaction.apis import inference_recognizer, init_recognizer
video_config_file = 'configs/recognition/tsn/tsn_r50_video_inference_1x1x3_100e_kinetics400_rgb.py' # noqa: E501
frame_config_file = 'configs/recognition/tsn/tsn_r50_inferen... | 6,972 | 37.313187 | 119 | py |
STTS | STTS-main/VideoSwin/tests/test_runtime/test_lr.py | import logging
import shutil
import sys
import tempfile
from unittest.mock import MagicMock, call
import torch
import torch.nn as nn
from mmcv.runner import IterTimerHook, PaviLoggerHook, build_runner
from torch.utils.data import DataLoader
def test_tin_lr_updater_hook():
sys.modules['pavi'] = MagicMock()
lo... | 3,291 | 26.898305 | 75 | py |
STTS | STTS-main/VideoSwin/tests/test_runtime/test_apis_test.py | import sys
import warnings
from unittest.mock import MagicMock, Mock, patch
import pytest
import torch
import torch.nn as nn
from torch.utils.data import DataLoader, Dataset
# TODO import test functions from mmcv and delete them from mmaction2
try:
from mmcv.engine import (collect_results_cpu, multi_gpu_test,
... | 3,346 | 27.12605 | 74 | py |
STTS | STTS-main/VideoSwin/tests/test_models/base.py | import os.path as osp
import mmcv
import numpy as np
import torch
from mmcv.utils import _BatchNorm
def check_norm_state(modules, train_state):
"""Check if norm layer is in correct train state."""
for mod in modules:
if isinstance(mod, _BatchNorm):
if mod.training != train_state:
... | 4,723 | 27.981595 | 78 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_roi_extractor.py | import torch
from mmaction.models import SingleRoIExtractor3D
def test_single_roi_extractor3d():
roi_extractor = SingleRoIExtractor3D(
roi_layer_type='RoIAlign',
featmap_stride=16,
output_size=8,
sampling_ratio=0,
pool_mode='avg',
aligned=True,
with_tempora... | 1,945 | 32.551724 | 78 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_common.py | import os.path as osp
import pytest
import torch
from mmaction.models.common import LFB, TAM, Conv2plus1d, ConvAudio
def test_conv2plus1d():
with pytest.raises(AssertionError):
# Length of kernel size, stride and padding must be the same
Conv2plus1d(3, 8, (2, 2))
conv_2plus1d = Conv2plus1d(... | 2,754 | 26.55 | 77 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_backbones.py | import copy
import pytest
import torch
import torch.nn as nn
from mmcv.utils import _BatchNorm
from mmaction.models import (C3D, X3D, MobileNetV2TSM, ResNet2Plus1d,
ResNet3dCSN, ResNet3dSlowFast, ResNet3dSlowOnly,
ResNetAudio, ResNetTIN, ResNetTSM, TANet)
from... | 25,467 | 34.971751 | 100 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_neck.py | import copy
import pytest
import torch
from mmaction.models import TPN
from .base import generate_backbone_demo_inputs
def test_tpn():
"""Test TPN backbone."""
tpn_cfg = dict(
in_channels=(1024, 2048),
out_channels=1024,
spatial_modulation_cfg=dict(
in_channels=(1024, 20... | 2,850 | 31.770115 | 73 | py |
STTS | STTS-main/VideoSwin/tests/test_models/__init__.py | from .base import (check_norm_state, generate_backbone_demo_inputs,
generate_detector_demo_inputs, generate_gradcam_inputs,
generate_recognizer_demo_inputs, get_audio_recognizer_cfg,
get_cfg, get_detector_cfg, get_localizer_cfg,
get_recognizer_... | 605 | 45.615385 | 77 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_gradcam.py | import pytest
import torch
from mmaction.models import build_recognizer
from mmaction.utils.gradcam_utils import GradCAM
from .base import generate_gradcam_inputs, get_recognizer_cfg
def _get_target_shapes(input_shape, num_classes=400, model_type='2D'):
if model_type not in ['2D', '3D']:
raise ValueError... | 8,364 | 35.369565 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_head.py | import os.path as osp
import tempfile
from unittest.mock import Mock, patch
import numpy as np
import pytest
import torch
import torch.nn as nn
import mmaction
from mmaction.models import (ACRNHead, AudioTSNHead, BBoxHeadAVA, FBOHead,
I3DHead, LFBInferHead, SlowFastHead, TPNHead,
... | 17,583 | 34.097804 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_localizers/test_bmn.py | import numpy as np
import torch
from mmaction.models import build_localizer
from ..base import get_localizer_cfg
def test_bmn():
model_cfg = get_localizer_cfg(
'bmn/bmn_400x100_2x8_9e_activitynet_feature.py')
if torch.cuda.is_available():
localizer_bmn = build_localizer(model_cfg.model).cuda... | 1,758 | 30.410714 | 66 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_localizers/test_ssn.py | import copy
import mmcv
import pytest
import torch
from mmaction.models import build_localizer
def test_ssn_train():
train_cfg = mmcv.ConfigDict(
dict(
ssn=dict(
assigner=dict(
positive_iou_threshold=0.7,
background_iou_threshold=0.01,
... | 7,989 | 38.359606 | 78 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_localizers/test_pem.py | import torch
from mmaction.models import build_localizer
from ..base import get_localizer_cfg
def test_pem():
model_cfg = get_localizer_cfg(
'bsn/bsn_pem_400x100_1x16_20e_activitynet_feature.py')
localizer_pem = build_localizer(model_cfg.model)
bsp_feature = torch.rand(8, 100, 32)
reference_... | 1,294 | 27.777778 | 65 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_localizers/test_localizers.py | import numpy as np
from mmaction.models.localizers.utils import post_processing
def test_post_processing():
# test with multiple results
result = np.array([[0., 1., 1., 1., 0.5, 0.5], [0., 0.4, 1., 1., 0.4, 0.4],
[0., 0.95, 1., 1., 0.6, 0.6]])
video_info = dict(
video_name=... | 1,221 | 34.941176 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_localizers/__init__.py | 0 | 0 | 0 | py | |
STTS | STTS-main/VideoSwin/tests/test_models/test_localizers/test_tem.py | import torch
from mmaction.models import build_localizer
from ..base import get_localizer_cfg
def test_tem():
model_cfg = get_localizer_cfg(
'bsn/bsn_tem_400x100_1x16_20e_activitynet_feature.py')
localizer_tem = build_localizer(model_cfg.model)
raw_feature = torch.rand(8, 400, 100)
gt_bbox =... | 759 | 30.666667 | 74 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_recognizers/test_recognizer2d.py | import torch
from mmaction.models import build_recognizer
from ..base import generate_recognizer_demo_inputs, get_recognizer_cfg
def test_tsn():
config = get_recognizer_cfg('tsn/tsn_r50_1x1x3_100e_kinetics400_rgb.py')
config.model['backbone']['pretrained'] = None
recognizer = build_recognizer(config.mod... | 8,541 | 29.29078 | 76 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_recognizers/test_recognizer3d.py | import torch
from mmaction.models import build_recognizer
from ..base import generate_recognizer_demo_inputs, get_recognizer_cfg
def test_i3d():
config = get_recognizer_cfg('i3d/i3d_r50_32x2x1_100e_kinetics400_rgb.py')
config.model['backbone']['pretrained2d'] = False
config.model['backbone']['pretrained'... | 9,327 | 31.84507 | 77 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_recognizers/__init__.py | 0 | 0 | 0 | py | |
STTS | STTS-main/VideoSwin/tests/test_models/test_recognizers/test_audio_recognizer.py | import torch
from mmaction.models import build_recognizer
from ..base import generate_recognizer_demo_inputs, get_audio_recognizer_cfg
def test_audio_recognizer():
config = get_audio_recognizer_cfg(
'resnet/tsn_r18_64x1x1_100e_kinetics400_audio_feature.py')
config.model['backbone']['pretrained'] = No... | 866 | 28.896552 | 76 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_common_modules/test_resnet.py | import pytest
import torch
import torch.nn as nn
from mmcv.utils import _BatchNorm
from mmaction.models import ResNet
from ..base import check_norm_state, generate_backbone_demo_inputs
def test_resnet_backbone():
"""Test resnet backbone."""
with pytest.raises(KeyError):
# ResNet depth should be in [1... | 4,319 | 32.75 | 70 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_common_modules/test_mobilenet_v2.py | import pytest
import torch
from mmcv.utils import _BatchNorm
from mmaction.models import MobileNetV2
from ..base import check_norm_state, generate_backbone_demo_inputs
def test_mobilenetv2_backbone():
"""Test MobileNetV2.
Modified from mmclassification.
"""
from torch.nn.modules import GroupNorm
... | 7,014 | 33.219512 | 77 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_common_modules/test_resnet3d.py | import pytest
import torch
import torch.nn as nn
from mmcv.utils import _BatchNorm
from mmaction.models import ResNet3d, ResNet3dLayer
from ..base import check_norm_state, generate_backbone_demo_inputs
def test_resnet3d_backbone():
"""Test resnet3d backbone."""
with pytest.raises(AssertionError):
# I... | 13,070 | 38.01791 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_common_modules/test_base_head.py | import torch
import torch.nn.functional as F
from mmcv.utils import assert_dict_has_keys
from mmaction.models import BaseHead
class ExampleHead(BaseHead):
# use an ExampleHead to test BaseHead
def init_weights(self):
pass
def forward(self, x):
pass
def test_base_head():
head = Exam... | 2,538 | 33.780822 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_common_modules/__init__.py | 0 | 0 | 0 | py | |
STTS | STTS-main/VideoSwin/tests/test_models/test_common_modules/test_base_recognizers.py | import pytest
import torch
import torch.nn.functional as F
from mmaction.models import BaseRecognizer
class ExampleRecognizer(BaseRecognizer):
def __init__(self, train_cfg, test_cfg):
super(BaseRecognizer, self).__init__()
# reconstruct `__init__()` method in BaseRecognizer to avoid building
... | 2,178 | 32.015152 | 77 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_detectors/test_detectors.py | import pytest
import torch
from ..base import generate_detector_demo_inputs, get_detector_cfg
try:
from mmaction.models import build_detector
mmdet_imported = True
except (ImportError, ModuleNotFoundError):
mmdet_imported = False
@pytest.mark.skipif(not mmdet_imported, reason='requires mmdet')
def test_... | 1,425 | 32.952381 | 69 | py |
STTS | STTS-main/VideoSwin/tests/test_models/test_detectors/__init__.py | 0 | 0 | 0 | py | |
STTS | STTS-main/VideoSwin/tests/test_data/test_formating.py | import numpy as np
import pytest
import torch
from mmcv.parallel import DataContainer as DC
from mmcv.utils import assert_dict_has_keys
from mmaction.datasets.pipelines import (Collect, FormatAudioShape,
FormatShape, ImageToTensor, Rename,
... | 6,791 | 33.830769 | 78 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_sampler.py | from torch.utils.data import DataLoader, Dataset
from mmaction.datasets.samplers import (ClassSpecificDistributedSampler,
DistributedSampler)
class MyDataset(Dataset):
def __init__(self, class_prob={i: 1 for i in range(10)}):
super().__init__()
self.class_... | 3,148 | 31.802083 | 72 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_blending.py | import torch
from mmaction.datasets import CutmixBlending, MixupBlending
def test_mixup():
alpha = 0.2
num_classes = 10
label = torch.randint(0, num_classes, (4, ))
mixup = MixupBlending(num_classes, alpha)
# NCHW imgs
imgs = torch.randn(4, 4, 3, 32, 32)
mixed_imgs, mixed_label = mixup(i... | 1,306 | 30.119048 | 63 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_compose.py | import numpy as np
import pytest
from mmcv.utils import assert_keys_equal
from mmaction.datasets.pipelines import Compose, ImageToTensor
def test_compose():
with pytest.raises(TypeError):
# transform must be callable or a dict
Compose('LoadImage')
target_keys = ['img', 'img_metas']
# te... | 1,226 | 31.289474 | 74 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/test_video_dataset.py | import os.path as osp
import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from mmaction.datasets import VideoDataset
from .base import BaseTestDataset
class TestVideoDataset(BaseTestDataset):
def test_video_dataset(self):
video_dataset = VideoDataset(
self.video_ann... | 3,490 | 33.91 | 75 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/base.py | import os.path as osp
from mmcv import ConfigDict
class BaseTestDataset:
@classmethod
def setup_class(cls):
# prefix path
cls.data_prefix = osp.normpath(
osp.join(osp.dirname(__file__), '../../data'))
cls.ann_file_prefix = osp.join(cls.data_prefix, 'annotations')
... | 5,987 | 38.92 | 77 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/test_audio_visual_dataset.py | import os.path as osp
from mmaction.datasets import AudioVisualDataset
from .base import BaseTestDataset
class TestAudioVisualDataset(BaseTestDataset):
def test_audio_visual_dataset(self):
test_dataset = AudioVisualDataset(
self.frame_ann_file,
self.frame_pipeline,
se... | 920 | 30.758621 | 59 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/test_rawframe_dataset.py | import os.path as osp
import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from mmaction.datasets import RawframeDataset
from .base import BaseTestDataset
class TestRawframDataset(BaseTestDataset):
def test_rawframe_dataset(self):
rawframe_dataset = RawframeDataset(self.frame_an... | 6,071 | 35.8 | 75 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/test_audio_feature_dataset.py | import os.path as osp
import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from mmaction.datasets import AudioFeatureDataset
from .base import BaseTestDataset
class TestAudioFeatureDataset(BaseTestDataset):
def test_audio_feature_dataset(self):
audio_dataset = AudioFeatureDatase... | 2,753 | 34.307692 | 75 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/test_pose_dataset.py | import numpy as np
import pytest
from mmaction.datasets import PoseDataset
from .base import BaseTestDataset
class TestPoseDataset(BaseTestDataset):
def test_pose_dataset(self):
ann_file = self.pose_ann_file
data_prefix = 'root'
dataset = PoseDataset(
ann_file=ann_file,
... | 1,919 | 29.967742 | 70 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/test_ssn_dataset.py | import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from mmaction.datasets import SSNDataset
from .base import BaseTestDataset
class TestSSNDataset(BaseTestDataset):
def test_proposal_pipeline(self):
target_keys = [
'frame_dir', 'video_id', 'total_frames', 'gts', 'pr... | 6,680 | 36.960227 | 76 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/test_rawvideo_dataset.py | import os.path as osp
from mmaction.datasets import RawVideoDataset
from .base import BaseTestDataset
class TestRawVideoDataset(BaseTestDataset):
def test_rawvideo_dataset(self):
# Try to load txt file
rawvideo_dataset = RawVideoDataset(
ann_file=self.rawvideo_test_anno_txt,
... | 1,006 | 32.566667 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/test_hvu_dataset.py | import os.path as osp
import numpy as np
from numpy.testing import assert_array_almost_equal
from mmaction.datasets import HVUDataset
from .base import BaseTestDataset
class TestHVUDataset(BaseTestDataset):
def test_hvu_dataset(self):
hvu_frame_dataset = HVUDataset(
ann_file=self.hvu_frame_... | 3,023 | 35.878049 | 76 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/test_audio_dataset.py | import os.path as osp
import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from mmaction.datasets import AudioDataset
from .base import BaseTestDataset
class TestAudioDataset(BaseTestDataset):
def test_audio_dataset(self):
audio_dataset = AudioDataset(
self.audio_ann... | 2,606 | 32.423077 | 77 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/__init__.py | from .base import BaseTestDataset
__all__ = ['BaseTestDataset']
| 65 | 15.5 | 33 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/test_activitynet_dataset.py | import os
import os.path as osp
import tempfile
import mmcv
import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from numpy.testing import assert_array_equal
from mmaction.datasets import ActivityNetDataset
from .base import BaseTestDataset
class TestActivitynetDataset(BaseTestDataset):
... | 6,311 | 34.863636 | 78 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/test_repeat_dataset.py | import numpy as np
from mmaction.datasets import RawframeDataset, RepeatDataset
from .base import BaseTestDataset
class TestRepeatDataset(BaseTestDataset):
def test_repeat_dataset(self):
rawframe_dataset = RawframeDataset(self.frame_ann_file,
self.frame_pipelin... | 1,016 | 36.666667 | 68 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_datasets/test_ava_dataset.py | import os.path as osp
import mmcv
import numpy as np
from mmcv.utils import assert_dict_has_keys
from numpy.testing import assert_array_almost_equal, assert_array_equal
from mmaction.datasets import AVADataset
class TestAVADataset:
@classmethod
def setup_class(cls):
cls.data_prefix = osp.normpath(
... | 9,151 | 40.411765 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_augmentations/base.py | import numpy as np
from numpy.testing import assert_array_almost_equal
def check_crop(origin_imgs, result_imgs, result_bbox, num_crops=1):
"""Check if the result_bbox is in correspond to result_imgs."""
def check_single_crop(origin_imgs, result_imgs, result_bbox):
result_img_shape = result_imgs[0].sh... | 2,707 | 37.685714 | 130 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_augmentations/test_normalization.py | import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from mmaction.datasets.pipelines import Normalize
from .base import check_normalize
class TestNormalization:
@staticmethod
def test_normalize():
with pytest.raises(TypeError):
# mean must be list, tuple or np.nd... | 2,892 | 39.746479 | 78 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_augmentations/test_transform.py | import copy
import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from numpy.testing import assert_array_almost_equal
from mmaction.datasets.pipelines import RandomRescale, RandomScale, Resize
from mmaction.datasets.pipelines.augmentations import PoseCompact
class TestTransform:
@staticm... | 7,393 | 37.113402 | 78 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_augmentations/test_misc.py | from mmaction.datasets.pipelines.augmentations import (_combine_quadruple,
_flip_quadruple)
class TestQuadrupleOps:
@staticmethod
def test_combine_quadruple():
a = (0.1, 0.1, 0.5, 0.5)
b = (0.3, 0.3, 0.7, 0.7)
res = _combine_quadr... | 537 | 27.315789 | 74 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_augmentations/test_imgaug.py | import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from numpy.testing import assert_array_almost_equal
from mmaction.datasets.pipelines import CenterCrop, Imgaug
from .base import check_flip
class TestAugumentations:
@staticmethod
def test_imgaug():
with pytest.raises(Valu... | 4,067 | 39.277228 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_augmentations/test_lazy.py | import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from mmaction.datasets.pipelines import (CenterCrop, Flip, Fuse,
MultiScaleCrop, RandomCrop,
RandomResizedCrop, Resize)
from .base import check_crop, check_flip... | 16,650 | 42.703412 | 78 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_augmentations/__init__.py | from .base import check_crop, check_flip, check_normalize
__all__ = ['check_crop', 'check_flip', 'check_normalize']
| 117 | 28.5 | 57 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_augmentations/test_flip.py | import copy
import mmcv
import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from numpy.testing import assert_array_almost_equal
from mmaction.datasets.pipelines import Flip
from .base import check_flip
class TestFlip:
@staticmethod
def test_flip():
with pytest.raises(ValueE... | 5,562 | 39.904412 | 76 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_augmentations/test_color.py | import numpy as np
from mmcv.utils import assert_dict_has_keys
from numpy.testing import assert_array_equal
from mmaction.datasets.pipelines import ColorJitter
class TestColor:
@staticmethod
def test_color_jitter():
imgs = list(
np.random.randint(0, 255, size=(3, 112, 112, 3), dtype=np.u... | 2,886 | 43.415385 | 78 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_augmentations/test_audio.py | import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from mmaction.datasets.pipelines import AudioAmplify, MelSpectrogram
class TestAudio:
@staticmethod
def test_audio_amplify():
target_keys = ['audios', 'amplify_ratio']
with pytest.raises(TypeError):
# ra... | 1,866 | 33.574074 | 68 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_augmentations/test_crop.py | import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from mmaction.datasets.pipelines import (CenterCrop, MultiGroupCrop,
MultiScaleCrop, RandomCrop,
RandomResizedCrop, TenCrop, ThreeCrop)
from .base import check_... | 14,358 | 40.143266 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_loadings/test_decode.py | import copy
import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from mmaction.datasets.pipelines import (AudioDecode, AudioDecodeInit,
DecordDecode, DecordInit,
FrameSelector, OpenCVDecode,
... | 21,562 | 46.495595 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_loadings/base.py | import os.path as osp
import mmcv
import numpy as np
class BaseTestLoading:
@classmethod
def setup_class(cls):
cls.data_prefix = osp.normpath(
osp.join(osp.dirname(__file__), '../../../data'))
cls.img_path = osp.join(cls.data_prefix, 'test.jpg')
cls.video_path = osp.join(... | 3,440 | 36 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_loadings/test_sampling.py | import copy
import numpy as np
import pytest
from mmcv.utils import assert_dict_has_keys
from numpy.testing import assert_array_equal
from mmaction.datasets.pipelines import (AudioFeatureSelector,
DenseSampleFrames, SampleAVAFrames,
Sam... | 35,091 | 45.914439 | 78 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_loadings/test_pose_loading.py | import copy as cp
from collections import defaultdict
import numpy as np
import pytest
from mmcv import dump
from numpy.testing import assert_array_almost_equal, assert_array_equal
from mmaction.datasets.pipelines import (GeneratePoseTarget, LoadKineticsPose,
PoseDecode, Unifo... | 14,911 | 41.243626 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_loadings/test_load.py | import copy
import numpy as np
import pytest
import torch
from mmcv.utils import assert_dict_has_keys
from numpy.testing import assert_array_almost_equal
from mmaction.datasets.pipelines import (LoadAudioFeature, LoadHVULabel,
LoadLocalizationFeature,
... | 6,171 | 39.605263 | 79 | py |
STTS | STTS-main/VideoSwin/tests/test_data/test_pipelines/test_loadings/test_localization.py | import copy
import numpy as np
from mmcv.utils import assert_dict_has_keys
from numpy.testing import assert_array_almost_equal
from mmaction.datasets.pipelines import GenerateLocalizationLabels
from .base import BaseTestLoading
class TestLocalization(BaseTestLoading):
def test_generate_localization_label(self)... | 940 | 32.607143 | 77 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.