repo stringlengths 1 99 | file stringlengths 13 215 | code stringlengths 12 59.2M | file_length int64 12 59.2M | avg_line_length float64 3.82 1.48M | max_line_length int64 12 2.51M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
mmaction | mmaction-master/mmaction/apis/train.py | from __future__ import division
from collections import OrderedDict
import torch
from mmcv.runner import EpochBasedRunner, DistSamplerSeedHook, build_optimizer
from mmcv.parallel import MMDataParallel
from mmcv.parallel.distributed import MMDistributedDataParallel
from mmaction.core import (DistOptimizerHook, DistEv... | 4,240 | 32.132813 | 78 | py |
mmaction | mmaction-master/mmaction/apis/env.py | import logging
import os
import random
import numpy as np
import torch
import torch.distributed as dist
import torch.multiprocessing as mp
from mmcv.runner import get_dist_info
def init_dist(launcher, backend='nccl', **kwargs):
if mp.get_start_method(allow_none=True) is None:
mp.set_start_method('spawn')... | 1,514 | 25.12069 | 70 | py |
mmaction | mmaction-master/mmaction/core/evaluation/eval_hooks.py | import os
import os.path as osp
import logging
import mmcv
import time
import torch
import numpy as np
import torch.distributed as dist
from mmcv.runner import Hook, obj_from_dict
from mmcv.parallel import scatter, collate
from torch.utils.data import Dataset
from mmaction import datasets
from .accuracy import top_k_a... | 6,784 | 36.486188 | 79 | py |
mmaction | mmaction-master/mmaction/core/post_processing/merge_augs.py | import torch
import numpy as np
from mmaction.ops import nms
from ..bbox2d import bbox_mapping_back
def merge_aug_proposals(aug_proposals, img_metas, rpn_test_cfg):
"""Merge augmented proposals (multiscale, flip, etc.)
Args:
aug_proposals (list[Tensor]): proposals from different testing
... | 2,617 | 34.378378 | 78 | py |
mmaction | mmaction-master/mmaction/core/post_processing/bbox_nms.py | import torch
from mmaction.ops.nms import nms_wrapper
def multiclass_nms(multi_bboxes, multi_scores, score_thr, nms_cfg, max_num=-1):
"""NMS for multi-class bboxes.
Args:
multi_bboxes (Tensor): shape (n, #class*4) or (n, 4)
multi_scores (Tensor): shape (n, #class)
score_thr (float): ... | 3,756 | 34.11215 | 79 | py |
mmaction | mmaction-master/mmaction/core/anchor2d/anchor_target.py | import torch
from ..bbox2d import assign_and_sample, build_assigner, PseudoSampler, bbox2delta
from mmaction.utils.misc import multi_apply
def anchor_target(anchor_list,
valid_flag_list,
gt_bboxes_list,
img_metas,
target_means,
... | 7,211 | 37.774194 | 81 | py |
mmaction | mmaction-master/mmaction/core/anchor2d/anchor_generator.py | import torch
class AnchorGenerator(object):
def __init__(self, base_size, scales, ratios, scale_major=True, ctr=None):
self.base_size = base_size
self.scales = torch.Tensor(scales)
self.ratios = torch.Tensor(ratios)
self.scale_major = scale_major
self.ctr = ctr
sel... | 3,117 | 35.682353 | 78 | py |
mmaction | mmaction-master/mmaction/core/utils/dist_utils.py | from collections import OrderedDict
import torch.distributed as dist
from torch._utils import (_flatten_dense_tensors, _unflatten_dense_tensors,
_take_tensors)
from mmcv.runner import OptimizerHook
def _allreduce_coalesced(tensors, world_size, bucket_size_mb=-1):
if bucket_size_mb > 0:
... | 1,941 | 32.482759 | 75 | py |
mmaction | mmaction-master/mmaction/core/bbox2d/bbox_target.py | import torch
from .transforms import bbox2delta
from mmaction.utils.misc import multi_apply
def bbox_target(pos_bboxes_list,
neg_bboxes_list,
pos_gt_bboxes_list,
pos_gt_labels_list,
cfg,
reg_classes=1,
target_means=[.0, .... | 3,471 | 38.011236 | 78 | py |
mmaction | mmaction-master/mmaction/core/bbox2d/geometry.py | import torch
def bbox_overlaps(bboxes1, bboxes2, mode='iou', is_aligned=False):
"""Calculate overlap between two set of bboxes.
If ``is_aligned`` is ``False``, then calculate the ious between each bbox
of bboxes1 and bboxes2, otherwise the ious between each aligned pair of
bboxes1 and bboxes2.
A... | 2,163 | 32.8125 | 79 | py |
mmaction | mmaction-master/mmaction/core/bbox2d/transforms.py | import mmcv
import numpy as np
import torch
def bbox2delta(proposals, gt, means=[0, 0, 0, 0], stds=[1, 1, 1, 1]):
assert proposals.size() == gt.size()
proposals = proposals.float()
gt = gt.float()
px = (proposals[..., 0] + proposals[..., 2]) * 0.5
py = (proposals[..., 1] + proposals[..., 3]) * 0.... | 5,614 | 32.422619 | 78 | py |
mmaction | mmaction-master/mmaction/core/bbox2d/assigners/assign_result.py | import torch
class AssignResult(object):
def __init__(self, num_gts, gt_inds, max_overlaps, labels=None):
self.num_gts = num_gts
self.gt_inds = gt_inds
self.max_overlaps = max_overlaps
self.labels = labels
def add_gt_(self, gt_labels):
self_inds = torch.arange(
... | 664 | 32.25 | 77 | py |
mmaction | mmaction-master/mmaction/core/bbox2d/assigners/max_iou_assigner.py | import torch
from .base_assigner import BaseAssigner
from .assign_result import AssignResult
from ..geometry import bbox_overlaps
class MaxIoUAssigner(BaseAssigner):
"""Assign a corresponding gt bbox or background to each bbox.
Each proposals will be assigned with `-1`, `0`, or a positive integer
indica... | 6,684 | 41.310127 | 79 | py |
mmaction | mmaction-master/mmaction/core/bbox2d/samplers/base_sampler.py | from abc import ABCMeta, abstractmethod
import torch
from .sampling_result import SamplingResult
class BaseSampler(metaclass=ABCMeta):
def __init__(self,
num,
pos_fraction,
neg_pos_ub=-1,
add_gt_as_proposals=True,
**kwargs):
... | 2,750 | 35.197368 | 78 | py |
mmaction | mmaction-master/mmaction/core/bbox2d/samplers/random_sampler.py | import numpy as np
import torch
from .base_sampler import BaseSampler
class RandomSampler(BaseSampler):
def __init__(self,
num,
pos_fraction,
neg_pos_ub=-1,
add_gt_as_proposals=True,
**kwargs):
super(RandomSampler, self... | 1,857 | 34.056604 | 77 | py |
mmaction | mmaction-master/mmaction/core/bbox2d/samplers/sampling_result.py | import torch
class SamplingResult(object):
def __init__(self, pos_inds, neg_inds, bboxes, gt_bboxes, assign_result,
gt_flags):
self.pos_inds = pos_inds
self.neg_inds = neg_inds
self.pos_bboxes = bboxes[pos_inds]
self.neg_bboxes = bboxes[neg_inds]
self.pos_... | 790 | 30.64 | 76 | py |
mmaction | mmaction-master/mmaction/core/bbox2d/samplers/pseudo_sampler.py | import torch
from .base_sampler import BaseSampler
from .sampling_result import SamplingResult
class PseudoSampler(BaseSampler):
def __init__(self, **kwargs):
pass
def _sample_pos(self, **kwargs):
raise NotImplementedError
def _sample_neg(self, **kwargs):
raise NotImplementedEr... | 829 | 29.740741 | 79 | py |
mmaction | mmaction-master/mmaction/models/registry.py | import torch.nn as nn
class Registry(object):
def __init__(self, name):
self._name = name
self._module_dict = dict()
@property
def name(self):
return self._name
@property
def module_dict(self):
return self._module_dict
def _register_module(self, module_class... | 1,400 | 27.02 | 73 | py |
mmaction | mmaction-master/mmaction/models/builder.py | import mmcv
from torch import nn
from .registry import (BACKBONES, FLOWNETS, SPATIAL_TEMPORAL_MODULES,
SEGMENTAL_CONSENSUSES, HEADS,
RECOGNIZERS, DETECTORS, LOCALIZERS, ARCHITECTURES,
NECKS, ROI_EXTRACTORS)
def _build_module(cfg, registry, default_... | 2,360 | 28.148148 | 79 | py |
mmaction | mmaction-master/mmaction/models/localizers/base.py | import logging
from abc import ABCMeta, abstractmethod
import torch.nn as nn
class BaseLocalizer(nn.Module):
"""Base class for localizers"""
__metaclass__ = ABCMeta
def __init__(self):
super(BaseLocalizer, self).__init__()
@abstractmethod
def forward_train(self, num_modalities, **kwargs... | 927 | 27.121212 | 76 | py |
mmaction | mmaction-master/mmaction/models/localizers/SSN2D.py | import torch
import torch.nn as nn
from .base import BaseLocalizer
from .. import builder
from ..registry import LOCALIZERS
@LOCALIZERS.register_module
class SSN2D(BaseLocalizer):
def __init__(self,
backbone,
modality='RGB',
in_channels=3,
spati... | 7,309 | 36.106599 | 79 | py |
mmaction | mmaction-master/mmaction/models/recognizers/base.py | import logging
from abc import ABCMeta, abstractmethod
import torch.nn as nn
class BaseRecognizer(nn.Module):
"""Base class for recognizers"""
__metaclass__ = ABCMeta
def __init__(self):
super(BaseRecognizer, self).__init__()
@property
def with_tenon_list(self):
return hasattr(... | 1,158 | 26.595238 | 76 | py |
mmaction | mmaction-master/mmaction/models/recognizers/TSN2D.py | import torch.nn as nn
from .base import BaseRecognizer
from .. import builder
from ..registry import RECOGNIZERS
@RECOGNIZERS.register_module
class TSN2D(BaseRecognizer):
def __init__(self,
backbone,
modality='RGB',
in_channels=3,
spatial_tempor... | 5,346 | 33.275641 | 100 | py |
mmaction | mmaction-master/mmaction/models/recognizers/TSN3D.py | from .base import BaseRecognizer
from .. import builder
from ..registry import RECOGNIZERS
import torch
@RECOGNIZERS.register_module
class TSN3D(BaseRecognizer):
def __init__(self,
backbone,
flownet=None,
spatial_temporal_module=None,
segmental... | 13,682 | 42.300633 | 105 | py |
mmaction | mmaction-master/mmaction/models/detectors/two_stage.py | import torch.nn as nn
from .base import BaseDetector
from .test_mixins import RPNTestMixin, BBoxTestMixin
from .. import builder
from ..registry import DETECTORS
from mmaction.core.bbox2d import (bbox2roi, bbox2result,
build_assigner, build_sampler)
@DETECTORS.register_module
class ... | 8,597 | 35.278481 | 77 | py |
mmaction | mmaction-master/mmaction/models/detectors/base.py | import logging
from abc import ABCMeta, abstractmethod
import mmcv
import numpy as np
import torch.nn as nn
from mmaction.core import get_classes
from mmaction.utils.misc import tensor2video_snaps
class BaseDetector(nn.Module):
"""Base class for detectors"""
__metaclass__ = ABCMeta
def __init__(self):... | 3,917 | 31.114754 | 77 | py |
mmaction | mmaction-master/mmaction/models/tenons/flownets/motionnet.py | import logging
import torch
import torch.nn as nn
import torch.nn.functional as F
from ....ops.resample2d_package.resample2d import Resample2d
from ....losses import charbonnier_loss, SSIM_loss
from mmcv.cnn import kaiming_init
from mmcv.runner import load_checkpoint
from ...registry import FLOWNETS
def make_smooth... | 26,718 | 56.09188 | 204 | py |
mmaction | mmaction-master/mmaction/models/tenons/cls_heads/ssn_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ...registry import HEADS
from mmaction.losses import completeness_loss, classwise_regression_loss
@HEADS.register_module
class SSNHead(nn.Module):
"""SSN's classification head"""
def __init__(self,
dropout_ratio=0.8,
... | 6,192 | 45.916667 | 120 | py |
mmaction | mmaction-master/mmaction/models/tenons/cls_heads/cls_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ...registry import HEADS
@HEADS.register_module
class ClsHead(nn.Module):
"""Simplest classification head"""
def __init__(self,
with_avg_pool=True,
temporal_feature_size=1,
spatial_featur... | 2,773 | 33.246914 | 117 | py |
mmaction | mmaction-master/mmaction/models/tenons/segmental_consensuses/stpp.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ...registry import SEGMENTAL_CONSENSUSES
import numpy as np
def parse_stage_config(stage_cfg):
if isinstance(stage_cfg, int):
return (stage_cfg,), stage_cfg
elif isinstance(stage_cfg, tuple) or isinstance(stage_cfg, list):
... | 6,594 | 38.728916 | 125 | py |
mmaction | mmaction-master/mmaction/models/tenons/segmental_consensuses/simple_consensus.py | import torch
import torch.nn as nn
from ...registry import SEGMENTAL_CONSENSUSES
@SEGMENTAL_CONSENSUSES.register_module
class SimpleConsensus(nn.Module):
def __init__(self, consensus_type, dim=1):
super(SimpleConsensus, self).__init__()
assert consensus_type in ['avg']
self.consensus_type =... | 593 | 26 | 59 | py |
mmaction | mmaction-master/mmaction/models/tenons/spatial_temporal_modules/simple_spatial_temporal_module.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ...registry import SPATIAL_TEMPORAL_MODULES
@SPATIAL_TEMPORAL_MODULES.register_module
class SimpleSpatialTemporalModule(nn.Module):
def __init__(self, spatial_type='avg', spatial_size=7, temporal_size=1):
super(SimpleSpatialTemporalMo... | 1,563 | 33.755556 | 82 | py |
mmaction | mmaction-master/mmaction/models/tenons/spatial_temporal_modules/non_local.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import constant_init, kaiming_init
from ...registry import SPATIAL_TEMPORAL_MODULES
@SPATIAL_TEMPORAL_MODULES.register_module
class NonLocalModule(nn.Module):
def __init__(self, in_channels=1024, nonlocal_type="gaussian", dim=3, embe... | 4,968 | 42.587719 | 142 | py |
mmaction | mmaction-master/mmaction/models/tenons/spatial_temporal_modules/slowfast_spatial_temporal_module.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ...registry import SPATIAL_TEMPORAL_MODULES
@SPATIAL_TEMPORAL_MODULES.register_module
class SlowFastSpatialTemporalModule(nn.Module):
def __init__(self, adaptive_pool=True, spatial_type='avg', spatial_size=1, temporal_size=1):
super(S... | 1,126 | 31.2 | 111 | py |
mmaction | mmaction-master/mmaction/models/tenons/spatial_temporal_modules/simple_spatial_module.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ...registry import SPATIAL_TEMPORAL_MODULES
@SPATIAL_TEMPORAL_MODULES.register_module
class SimpleSpatialModule(nn.Module):
def __init__(self, spatial_type='avg', spatial_size=7):
super(SimpleSpatialModule, self).__init__()
a... | 722 | 27.92 | 111 | py |
mmaction | mmaction-master/mmaction/models/tenons/necks/fpn.py | import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import xavier_init
from ..utils import ConvModule
from ...registry import NECKS
@NECKS.register_module
class FPN(nn.Module):
def __init__(self,
in_channels,
out_channels,
num_outs,
... | 4,894 | 36.083333 | 79 | py |
mmaction | mmaction-master/mmaction/models/tenons/roi_extractors/single_level.py | import torch
import torch.nn as nn
from mmaction import ops
from ...registry import ROI_EXTRACTORS
@ROI_EXTRACTORS.register_module
class SingleRoIExtractor(nn.Module):
"""Extract RoI features from a single level feature map.
If there are multiple input feature levels, each RoI is mapped to a level
accor... | 3,046 | 34.022989 | 79 | py |
mmaction | mmaction-master/mmaction/models/tenons/roi_extractors/single_level_straight3d.py | import torch
import torch.nn as nn
from mmaction import ops
from ...registry import ROI_EXTRACTORS
@ROI_EXTRACTORS.register_module
class SingleRoIStraight3DExtractor(nn.Module):
"""Extract RoI features from a single level feature map.
If there are multiple input feature levels, each RoI is mapped to a level... | 3,794 | 35.84466 | 79 | py |
mmaction | mmaction-master/mmaction/models/tenons/anchor_heads/rpn_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import normal_init
from mmaction.core.bbox2d import delta2bbox
from mmaction.ops import nms
from .anchor_head import AnchorHead
from ...registry import HEADS
@HEADS.register_module
class RPNHead(AnchorHead):
def __init__(self, in_ch... | 4,061 | 38.057692 | 78 | py |
mmaction | mmaction-master/mmaction/models/tenons/anchor_heads/anchor_head.py | import numpy as np
import torch
import torch.nn as nn
from mmcv.cnn import normal_init
from mmaction.core.anchor2d import AnchorGenerator, anchor_target
from mmaction.core.bbox2d import delta2bbox
from mmaction.losses import weighted_cross_entropy, weighted_smoothl1, weighted_binary_cross_entropy
from mmaction.utils.... | 10,340 | 38.773077 | 100 | py |
mmaction | mmaction-master/mmaction/models/tenons/bbox_heads/bbox_head.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from mmaction.core.bbox2d import delta2bbox, bbox_target
from mmaction.core.post_processing import multiclass_nms, singleclass_nms
from mmaction.losses import (weighted_cross_entropy, weighted_smoothl1,
multilabel_accuracy,... | 11,255 | 40.230769 | 94 | py |
mmaction | mmaction-master/mmaction/models/tenons/shared_heads/res_i3d_layer.py | import logging
import torch.nn as nn
from mmcv.cnn import constant_init, kaiming_init
from mmcv.runner import load_checkpoint
from ..backbones import ResNet_I3D
from ..backbones.resnet_i3d import make_res_layer
from ...registry import HEADS
@HEADS.register_module
class ResI3DLayer(nn.Module):
def __init__(self... | 4,837 | 40.706897 | 148 | py |
mmaction | mmaction-master/mmaction/models/tenons/shared_heads/res_layer.py | import logging
import torch.nn as nn
from mmcv.cnn import constant_init, kaiming_init
from mmcv.runner import load_checkpoint
from ..backbones import ResNet
from ..backbones.resnet import make_res_layer
from ...registry import HEADS
from ..spatial_temporal_modules.non_local import NonLocalModule
@HEADS.register_mod... | 2,930 | 32.306818 | 79 | py |
mmaction | mmaction-master/mmaction/models/tenons/utils/resnet_r3d_utils.py | """
This file contains helper functions for building the model and for loading model parameters.
These helper functions are built to mirror those in the official TensorFlow implementation.
"""
import torch.nn as nn
import string
import itertools
def conv3d_wobias(in_planes, out_planes, kernel, stride, pad, groups=1)... | 3,741 | 38.389474 | 105 | py |
mmaction | mmaction-master/mmaction/models/tenons/utils/norm.py | import torch.nn as nn
norm_cfg = {
# format: layer_type: (abbreviation, module)
'BN': ('bn', nn.BatchNorm2d),
'SyncBN': ('bn', None),
'GN': ('gn', nn.GroupNorm),
# and potentially 'SN'
}
def build_norm_layer(cfg, num_features, postfix=''):
""" Build normalization layer
Args:
cfg ... | 1,684 | 29.636364 | 70 | py |
mmaction | mmaction-master/mmaction/models/tenons/utils/conv_module.py | import warnings
import torch.nn as nn
from mmcv.cnn import kaiming_init, constant_init
from .norm import build_norm_layer
class ConvModule(nn.Module):
def __init__(self,
in_channels,
out_channels,
kernel_size,
stride=1,
paddin... | 2,871 | 30.56044 | 79 | py |
mmaction | mmaction-master/mmaction/models/tenons/backbones/c3d.py | import logging
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import constant_init, normal_init
from mmcv.runner import load_checkpoint
from ...registry import BACKBONES
__all__ = ['C3D']
@BACKBONES.register_module
class C3D(nn.Module):
## TODO:
## Refactor it into a more... | 4,316 | 35.584746 | 132 | py |
mmaction | mmaction-master/mmaction/models/tenons/backbones/resnet_i3d.py | import logging
import torch.nn as nn
import torch.utils.checkpoint as cp
from ....utils.misc import rgetattr, rhasattr
from .resnet import ResNet
from mmcv.cnn import constant_init, kaiming_init
from mmcv.runner import load_checkpoint
from ..utils.nonlocal_block import build_nonlocal_block
from ..spatial_temporal_mo... | 18,571 | 36.368209 | 150 | py |
mmaction | mmaction-master/mmaction/models/tenons/backbones/resnet_r3d.py | import logging
import torch.nn as nn
import torch.utils.checkpoint as cp
import torch
from mmcv.cnn import constant_init, kaiming_init
from mmcv.runner import load_checkpoint
from ...registry import BACKBONES
from ..utils.resnet_r3d_utils import *
class BasicBlock(nn.Module):
def __init__(self,
i... | 13,548 | 36.952381 | 100 | py |
mmaction | mmaction-master/mmaction/models/tenons/backbones/resnet_i3d_slowfast.py | import logging
import torch
import torch.nn as nn
import torch.utils.checkpoint as cp
from ....utils.misc import rgetattr, rhasattr
from .resnet import ResNet
from mmcv.cnn import constant_init, kaiming_init
from mmcv.runner import load_checkpoint
from ..utils.nonlocal_block import build_nonlocal_block
from ..spatial... | 21,126 | 44.046908 | 146 | py |
mmaction | mmaction-master/mmaction/models/tenons/backbones/resnet.py | import logging
import torch.nn as nn
import torch.utils.checkpoint as cp
from mmcv.cnn import constant_init, kaiming_init
from mmcv.runner import load_checkpoint
from ...registry import BACKBONES
def conv3x3(in_planes, out_planes, stride=1, dilation=1):
"3x3 convolution with padding"
return nn.Conv2d(
... | 10,877 | 30.900293 | 96 | py |
mmaction | mmaction-master/mmaction/models/tenons/backbones/resnet_s3d.py | import logging
import torch
import torch.nn as nn
import torch.utils.checkpoint as cp
from ....utils.misc import rgetattr, rhasattr
from .resnet import ResNet
from mmcv.cnn import constant_init, kaiming_init
from mmcv.runner import load_checkpoint
from ....ops.trajectory_conv_package.traj_conv import TrajConv
from ... | 20,990 | 37.374771 | 151 | py |
mmaction | mmaction-master/mmaction/models/tenons/backbones/bninception.py | import logging
import torch
import torch.nn as nn
from mmcv.cnn import constant_init, kaiming_init
from mmcv.runner import load_checkpoint
from ...registry import BACKBONES
__all__ = ['BNInception']
@BACKBONES.register_module
class BNInception(nn.Module):
def __init__(self,
pretrained=None,
... | 44,305 | 85.198444 | 160 | py |
mmaction | mmaction-master/mmaction/models/tenons/backbones/inception_v1_i3d.py | import logging
import torch
import torch.nn as nn
import torch.nn.functional as F
from mmcv.cnn import constant_init, kaiming_init
from mmcv.runner import load_checkpoint
from ...registry import BACKBONES
# from mmaction.ops.reflection_pad3d import reflection_pad3d
__all__ = ['InceptionV1_I3D']
@BACKBONES.register... | 40,306 | 77.724609 | 167 | py |
mmaction | mmaction-master/mmaction/datasets/utils.py | import copy
from collections import Sequence
import torch
import numpy as np
import os
import glob
import fnmatch
import mmcv
from mmcv.runner import obj_from_dict
from .. import datasets
import csv
import random
def to_tensor(data):
"""Convert objects of various python types to :obj:`torch.Tensor`.
Supporte... | 13,981 | 33.694789 | 113 | py |
mmaction | mmaction-master/mmaction/datasets/ava_dataset.py | import mmcv
import numpy as np
import os.path as osp
from mmcv.parallel import DataContainer as DC
from torch.utils.data import Dataset
from .transforms import (GroupImageTransform, BboxTransform)
from .utils import (to_tensor, random_scale)
_TIMESTAMP_BIAS = 600
_TIMESTAMP_START = 840 # 60*14min
_TIMESTAMP_END = 18... | 22,045 | 36.944923 | 79 | py |
mmaction | mmaction-master/mmaction/datasets/video_dataset.py | import mmcv
import numpy as np
import os.path as osp
from mmcv.parallel import DataContainer as DC
from torch.utils.data import Dataset
from .transforms import (GroupImageTransform)
from .utils import to_tensor
try:
import decord
except ImportError:
pass
class RawFramesRecord(object):
def __init__(self... | 15,342 | 37.07196 | 84 | py |
mmaction | mmaction-master/mmaction/datasets/ssn_dataset.py | import mmcv
import numpy as np
import math
import os.path as osp
from mmcv.parallel import DataContainer as DC
from torch.utils.data import Dataset
from .transforms import (GroupImageTransform)
from .utils import (to_tensor, parse_directory,
process_localize_proposal_list,
load_... | 31,480 | 37.626994 | 79 | py |
mmaction | mmaction-master/mmaction/datasets/rawframes_dataset.py | import mmcv
import numpy as np
import os.path as osp
from mmcv.parallel import DataContainer as DC
from torch.utils.data import Dataset
from .transforms import (GroupImageTransform)
from .utils import to_tensor
class RawFramesRecord(object):
def __init__(self, row):
self._data = row
@property
de... | 13,882 | 37.035616 | 82 | py |
mmaction | mmaction-master/mmaction/datasets/lmdbframes_dataset.py | import mmcv
import numpy as np
import os.path as osp
from mmcv.parallel import DataContainer as DC
from torch.utils.data import Dataset
from .transforms import (GroupImageTransform)
from .utils import to_tensor
import lmdb
class RawFramesRecord(object):
def __init__(self, row):
self._data = row
@pr... | 12,217 | 35.801205 | 79 | py |
mmaction | mmaction-master/mmaction/datasets/loader/sampler.py | from __future__ import division
import math
import torch
import numpy as np
from torch.distributed import get_world_size, get_rank
from torch.utils.data.sampler import Sampler
from torch.utils.data import DistributedSampler as _DistributedSampler
class GroupSampler(Sampler):
def __init__(self, dataset, samples... | 5,661 | 34.610063 | 91 | py |
mmaction | mmaction-master/mmaction/datasets/loader/build_loader.py | from functools import partial
from mmcv.runner import get_dist_info
from mmcv.parallel import collate
from torch.utils.data import DataLoader
from .sampler import GroupSampler, DistributedGroupSampler, DistributedSampler
# https://github.com/pytorch/pytorch/issues/973
import resource
rlimit = resource.getrlimit(reso... | 1,497 | 30.208333 | 86 | py |
mmaction | mmaction-master/mmaction/ops/trajectory_conv_package/setup.py | #!/usr/bin/env python3
import os
import torch
from setuptools import setup, find_packages
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
cxx_args = ['-std=c++14']
nvcc_args = [
'-gencode', 'arch=compute_50,code=sm_50',
'-gencode', 'arch=compute_52,code=sm_52',
'-gencode', 'arch=compu... | 791 | 25.4 | 67 | py |
mmaction | mmaction-master/mmaction/ops/trajectory_conv_package/gradcheck.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import gradcheck
from traj_conv import TrajConv
num_deformable_groups = 2
N, inC, inT, inH, inW = 2, 8, 8, 4, 4
outC, outT, outH, outW = 4, 8, 4, 4
kT, kH, kW = 3, 3, 3
conv = nn.Conv3d(inC, num_deformable_groups * 3 * kT * kH *... | 975 | 32.655172 | 109 | py |
mmaction | mmaction-master/mmaction/ops/trajectory_conv_package/traj_conv.py | import torch
import torch.nn as nn
from torch.autograd import Function
from torch.nn.modules.module import Module
from torch.nn.modules.utils import _triple
import math
import traj_conv_cuda
class TrajConvFunction(Function):
@staticmethod
def forward(ctx,
input,
offset,
... | 7,276 | 39.882022 | 135 | py |
mmaction | mmaction-master/mmaction/ops/resample2d_package/setup.py | #!/usr/bin/env python3
import os
import torch
from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
cxx_args = ['-std=c++14']
nvcc_args = [
'-gencode', 'arch=compute_50,code=sm_50',
'-gencode', 'arch=compute_52,code=sm_52',
'-gencode', 'arch=compute_60,code=sm_6... | 767 | 24.6 | 67 | py |
mmaction | mmaction-master/mmaction/ops/resample2d_package/resample2d.py | from torch.nn.modules.module import Module
from torch.autograd import Function, Variable
import resample2d_cuda
class Resample2dFunction(Function):
@staticmethod
def forward(ctx, input1, input2, kernel_size=1):
assert input1.is_contiguous()
assert input2.is_contiguous()
ctx.save_for_... | 1,456 | 28.14 | 75 | py |
mmaction | mmaction-master/mmaction/ops/roi_align/setup.py | from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='roi_align_cuda',
ext_modules=[
CUDAExtension('roi_align_cuda', [
'src/roi_align_cuda.cpp',
'src/roi_align_kernel.cu',
]),
],
cmdclass={'build_ext': Build... | 332 | 24.615385 | 67 | py |
mmaction | mmaction-master/mmaction/ops/roi_align/gradcheck.py | import numpy as np
import torch
from torch.autograd import gradcheck
import os.path as osp
import sys
sys.path.append(osp.abspath(osp.join(__file__, '../../')))
from roi_align import RoIAlign # noqa: E402
feat_size = 15
spatial_scale = 1.0 / 8
img_size = feat_size / spatial_scale
num_imgs = 2
num_rois = 20
batch_in... | 866 | 27.9 | 76 | py |
mmaction | mmaction-master/mmaction/ops/roi_align/functions/roi_align.py | from torch.autograd import Function
from .. import roi_align_cuda
class RoIAlignFunction(Function):
@staticmethod
def forward(ctx, features, rois, out_size, spatial_scale, sample_num=0):
if isinstance(out_size, int):
out_h = out_size
out_w = out_size
elif isinstance(o... | 2,113 | 33.096774 | 79 | py |
mmaction | mmaction-master/mmaction/ops/roi_align/modules/roi_align.py | from torch.nn.modules.module import Module
from ..functions.roi_align import RoIAlignFunction
class RoIAlign(Module):
def __init__(self, out_size, spatial_scale, sample_num=0):
super(RoIAlign, self).__init__()
self.out_size = out_size
self.spatial_scale = float(spatial_scale)
sel... | 535 | 30.529412 | 74 | py |
mmaction | mmaction-master/mmaction/ops/roi_pool/setup.py | from setuptools import setup
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='roi_pool',
ext_modules=[
CUDAExtension('roi_pool_cuda', [
'src/roi_pool_cuda.cpp',
'src/roi_pool_kernel.cu',
])
],
cmdclass={'build_ext': BuildExtension}... | 322 | 23.846154 | 67 | py |
mmaction | mmaction-master/mmaction/ops/roi_pool/gradcheck.py | import torch
from torch.autograd import gradcheck
import os.path as osp
import sys
sys.path.append(osp.abspath(osp.join(__file__, '../../')))
from roi_pool import RoIPool # noqa: E402
feat = torch.randn(4, 16, 15, 15, requires_grad=True).cuda()
rois = torch.Tensor([[0, 0, 0, 50, 50], [0, 10, 30, 43, 55],
... | 500 | 30.3125 | 66 | py |
mmaction | mmaction-master/mmaction/ops/roi_pool/functions/roi_pool.py | import torch
from torch.autograd import Function
from .. import roi_pool_cuda
class RoIPoolFunction(Function):
@staticmethod
def forward(ctx, features, rois, out_size, spatial_scale):
if isinstance(out_size, int):
out_h = out_size
out_w = out_size
elif isinstance(out_... | 1,815 | 31.428571 | 74 | py |
mmaction | mmaction-master/mmaction/ops/roi_pool/modules/roi_pool.py | from torch.nn.modules.module import Module
from ..functions.roi_pool import roi_pool
class RoIPool(Module):
def __init__(self, out_size, spatial_scale):
super(RoIPool, self).__init__()
self.out_size = out_size
self.spatial_scale = float(spatial_scale)
def forward(self, features, roi... | 399 | 25.666667 | 74 | py |
mmaction | mmaction-master/mmaction/ops/nms/setup.py | import os.path as osp
from setuptools import setup, Extension
import numpy as np
from Cython.Build import cythonize
from Cython.Distutils import build_ext
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
ext_args = dict(
include_dirs=[np.get_include()],
language='c++',
extra_compile_arg... | 2,678 | 30.517647 | 79 | py |
mmaction | mmaction-master/mmaction/ops/nms/nms_wrapper.py | import numpy as np
import torch
from . import nms_cuda, nms_cpu
from .soft_nms_cpu import soft_nms_cpu
def nms(dets, iou_thr, device_id=None):
"""Dispatch to either CPU or GPU NMS implementations.
The input can be either a torch tensor or numpy array. GPU NMS will be used
if the input is a gpu tensor or... | 2,580 | 31.670886 | 79 | py |
mmaction | mmaction-master/mmaction/losses/losses.py | import torch
import torch.nn.functional as F
def weighted_nll_loss(pred, label, weight, avg_factor=None):
if avg_factor is None:
avg_factor = max(torch.sum(weight > 0).float().item(), 1.)
raw = F.nll_loss(pred, label, reduction='none')
return torch.sum(raw * weight)[None] / avg_factor
def weight... | 6,657 | 35.184783 | 78 | py |
mmaction | mmaction-master/mmaction/losses/flow_losses.py | import math
import torch
import torch.nn as nn
def charbonnier_loss(difference, mask, alpha=1, beta=1., epsilon=0.001):
'''
: sum( (x*beta)^2 + epsilon^2)^alpha
'''
if mask is not None:
assert difference.size(0) == mask.size(0)
assert difference.size(2) == mask.size(2)
assert d... | 1,987 | 31.590164 | 78 | py |
mmaction | mmaction-master/mmaction/losses/ssn_losses.py | import torch
import torch.nn.functional as F
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 negative mining
(OHEM).
"""
@staticmethod
def forward(ctx, pre... | 3,228 | 37.440476 | 78 | py |
mmaction | mmaction-master/configs/hmdb51/tsn_flow_bninception.py | # model settings
model = dict(
type='TSN2D',
modality='Flow',
in_channels=10,
backbone=dict(
type='BNInception',
pretrained='open-mmlab://bninception_caffe',
bn_eval=False,
partial_bn=True),
spatial_temporal_module=dict(
type='SimpleSpatialModule',
spa... | 3,464 | 26.5 | 75 | py |
mmaction | mmaction-master/configs/hmdb51/tsn_rgb_bninception.py | # model settings
model = dict(
type='TSN2D',
backbone=dict(
type='BNInception',
pretrained='open-mmlab://bninception_caffe',
bn_eval=False,
partial_bn=True),
spatial_temporal_module=dict(
type='SimpleSpatialModule',
spatial_type='avg',
spatial_size=7),... | 3,435 | 26.269841 | 73 | py |
mmaction | mmaction-master/configs/TSN/ucf101/tsn_flow_bninception.py | # model settings
model = dict(
type='TSN2D',
modality='Flow',
in_channels=10,
backbone=dict(
type='BNInception',
pretrained='open-mmlab://bninception_caffe',
bn_eval=False,
partial_bn=True),
spatial_temporal_module=dict(
type='SimpleSpatialModule',
spa... | 3,468 | 25.891473 | 75 | py |
mmaction | mmaction-master/configs/TSN/ucf101/tsn_rgb_bninception.py | # model settings
model = dict(
type='TSN2D',
backbone=dict(
type='BNInception',
pretrained='open-mmlab://bninception_caffe',
bn_eval=False,
partial_bn=True),
spatial_temporal_module=dict(
type='SimpleSpatialModule',
spatial_type='avg',
spatial_size=7),... | 3,439 | 25.666667 | 73 | py |
mmaction | mmaction-master/configs/I3D_RGB/i3d_kinetics400_3d_rgb_r50_c3d_inflate3x1x1_seg1_f32s2.py | # model settings
model = dict(
type='TSN3D',
backbone=dict(
type='ResNet_I3D',
pretrained='modelzoo://resnet50',
depth=50,
num_stages=4,
out_indices=[3],
frozen_stages=-1,
inflate_freq=((1,1,1), (1,0,1,0), (1,0,1,0,1,0), (0,1,0)),
inflate_style='3x... | 3,973 | 26.79021 | 91 | py |
mmaction | mmaction-master/configs/I3D_RGB/i3d_kinetics400_3d_rgb_r50_c3d_inflate3x1x1_seg1_f32s2_video.py | # model settings
model = dict(
type='TSN3D',
backbone=dict(
type='ResNet_I3D',
pretrained='modelzoo://resnet50',
depth=50,
num_stages=4,
out_indices=[3],
frozen_stages=-1,
inflate_freq=((1,1,1), (1,0,1,0), (1,0,1,0,1,0), (0,1,0)),
inflate_style='3x... | 4,171 | 26.629139 | 91 | py |
mmaction | mmaction-master/configs/C3D/c3d_sports1m_3d_rgb_vgg_c3d_seg1_f16s1.py | # model settings
model = dict(
type='TSN3D',
backbone=dict(
type='C3D',
pretrained='https://open-mmlab.s3.ap-northeast-2.amazonaws.com/pretrain/third_party/c3d_caffe_sports1m_pretrain-c8182401.pth'),
spatial_temporal_module=dict(
type='SimpleSpatialTemporalModule',
spatial_ty... | 3,928 | 28.103704 | 135 | py |
mmaction | mmaction-master/configs/ava/ava_fast_rcnn_nl_r50_c4_1x_kinetics_pretrain_crop.py | # model settings
model = dict(
type='FastRCNN',
backbone=dict(
type='ResNet_I3D',
pretrained='open-mmlab://kin400/nl3d_r50_f32s2_k400',
pretrained2d=False,
depth=50,
num_stages=3,
spatial_strides=(1, 2, 2),
temporal_strides=(1, 1, 1),
dilations=(1,... | 6,267 | 31.476684 | 91 | py |
mmaction | mmaction-master/configs/SlowOnly/slowonly_kinetics400_se_rgb_r50_seg1_4x16_finetune.py | model = dict(
type='TSN3D',
backbone=dict(
type='ResNet_I3D',
pretrained='modelzoo://resnet50',
depth=50,
num_stages=4,
out_indices=[3],
frozen_stages=-1,
inflate_freq=(0, 0, 1, 1),
conv1_kernel_t=1,
conv1_stride_t=1,
pool1_kernel_t... | 3,954 | 26.657343 | 82 | py |
mmaction | mmaction-master/configs/SlowOnly/slowonly_kinetics400_se_rgb_r50_seg1_8x8_finetune.py |
model = dict(
type='TSN3D',
backbone=dict(
type='ResNet_I3D',
pretrained='modelzoo://resnet50',
depth=50,
num_stages=4,
out_indices=[3],
frozen_stages=-1,
inflate_freq=(0, 0, 1, 1),
conv1_kernel_t=1,
conv1_stride_t=1,
pool1_kernel_... | 3,948 | 26.423611 | 80 | py |
mmaction | mmaction-master/configs/SlowOnly/slowonly_kinetics400_se_rgb_r50_seg1_8x8_scratch.py | model = dict(
type='TSN3D',
backbone=dict(
type='ResNet_I3D',
pretrained=None,
depth=50,
num_stages=4,
out_indices=[3],
frozen_stages=-1,
inflate_freq=(0, 0, 1, 1),
conv1_kernel_t=1,
conv1_stride_t=1,
pool1_kernel_t=1,
pool1... | 3,910 | 26.542254 | 79 | py |
mmaction | mmaction-master/configs/SlowOnly/slowonly_kinetics400_se_rgb_r50_seg1_4x16_scratch.py | model = dict(
type='TSN3D',
backbone=dict(
type='ResNet_I3D',
pretrained=None,
depth=50,
num_stages=4,
out_indices=[3],
frozen_stages=-1,
inflate_freq=(0, 0, 1, 1),
conv1_kernel_t=1,
conv1_stride_t=1,
pool1_kernel_t=1,
pool1... | 3,917 | 26.591549 | 81 | py |
mmaction | mmaction-master/configs/thumos14/ssn_thumos14_rgb_bn_inception.py | # model settings
model = dict(
type='SSN2D',
backbone=dict(
type='BNInception',
pretrained='open-mmlab://bninception_caffe',
bn_eval=False,
partial_bn=True),
spatial_temporal_module=dict(
type='SimpleSpatialModule',
spatial_type='avg',
spatial_size=7),... | 4,707 | 27.883436 | 80 | py |
mmaction | mmaction-master/test_configs/SlowFast/slowfast_kinetics400_se_rgb_r50_seg1_4x16.py | # model settings
model = dict(
type='TSN3D',
backbone=dict(
type='ResNet_I3D_SlowFast',
pretrained_slow=None,
pretrained_fast=None,
depth=50,
alpha=8,
beta_inv=8,
num_stages=4,
out_indices=[3],
frozen_stages=-1,
slow_inflate_freq=(0... | 1,894 | 26.071429 | 77 | py |
mmaction | mmaction-master/test_configs/I3D_RGB/i3d_kinetics400_3d_rgb_r50_c3d_inflate3x1x1_seg1_f32s2.py | # model settings
model = dict(
type='TSN3D',
backbone=dict(
type='ResNet_I3D',
pretrained=None,
depth=50,
num_stages=4,
out_indices=[3],
frozen_stages=-1,
inflate_freq=((1,1,1), (1,0,1,0), (1,0,1,0,1,0), (0,1,0)),
inflate_style='3x1x1',
con... | 1,875 | 26.588235 | 77 | py |
mmaction | mmaction-master/test_configs/ava/ava_fast_rcnn_nl_r50_c4_1x_kinetics_pretrain_crop.py | # model settings
model = dict(
type='FastRCNN',
backbone=dict(
type='ResNet_I3D',
pretrained=None,
pretrained2d=False,
depth=50,
num_stages=3,
spatial_strides=(1, 2, 2),
temporal_strides=(1, 1, 1),
dilations=(1, 1, 1),
out_indices=(2,),
... | 3,207 | 30.45098 | 90 | py |
mmaction | mmaction-master/test_configs/SlowOnly/slowonly_kinetics400_se_rgb_r50_seg1_4x16.py | model = dict(
type='TSN3D',
backbone=dict(
type='ResNet_I3D',
pretrained=None,
depth=50,
num_stages=4,
out_indices=[3],
frozen_stages=-1,
inflate_freq=(0, 0, 1, 1),
conv1_kernel_t=1,
conv1_stride_t=1,
pool1_kernel_t=1,
pool1... | 1,851 | 26.235294 | 77 | py |
mmaction | mmaction-master/test_configs/SlowOnly/slowonly_kinetics400_se_rgb_r101_seg1_8x8.py | model = dict(
type='TSN3D',
backbone=dict(
type='ResNet_I3D',
pretrained=None,
depth=101,
num_stages=4,
out_indices=[3],
frozen_stages=-1,
inflate_freq=(0, 0, 1, 1),
conv1_kernel_t=1,
conv1_stride_t=1,
pool1_kernel_t=1,
pool... | 1,851 | 26.235294 | 77 | py |
mmaction | mmaction-master/test_configs/SlowOnly/slowonly_kinetics400_se_rgb_r50_seg1_8x8.py | model = dict(
type='TSN3D',
backbone=dict(
type='ResNet_I3D',
pretrained=None,
depth=50,
num_stages=4,
out_indices=[3],
frozen_stages=-1,
inflate_freq=(0, 0, 1, 1),
conv1_kernel_t=1,
conv1_stride_t=1,
pool1_kernel_t=1,
pool1... | 1,850 | 26.220588 | 77 | py |
SigMaNet | SigMaNet-master/generate_synthetic_data.py | from typing import Tuple
import math
import itertools
import math
import networkx as nx
from networkx.utils import py_random_state
import numpy as np
import scipy.sparse as sp
import numpy.random as rnd
from random import randint
@py_random_state(3)
def stochastic_block_model_2(
sizes, p, nodelist=None, seed=None,... | 7,265 | 34.793103 | 153 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.