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
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/alexnet.py
# Copyright (c) OpenMMLab. All rights reserved. import logging import torch.nn as nn class AlexNet(nn.Module): """AlexNet backbone. Args: num_classes (int): number of classes for classification. """ def __init__(self, num_classes=-1): super(AlexNet, self).__init__() self.num...
1,990
31.112903
74
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/activation.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from mmcv.utils import TORCH_VERSION, build_from_cfg, digit_version from .registry import ACTIVATION_LAYERS for module in [ nn.ReLU, nn.LeakyReLU, nn.PReLU, nn.RReLU, nn.ReLU6, nn.ELU, nn...
2,489
25.489362
75
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/hsigmoid.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn from .registry import ACTIVATION_LAYERS @ACTIVATION_LAYERS.register_module() class HSigmoid(nn.Module): """Hard Sigmoid Module. Apply the hard sigmoid function: Hsigmoid(x) = min(max((x + bias) / divisor, min_value), max_v...
1,546
31.914894
77
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/depthwise_separable_conv_module.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from .conv_module import ConvModule class DepthwiseSeparableConvModule(nn.Module): """Depthwise separable convolution module. See https://arxiv.org/pdf/1704.04861.pdf for details. This module can replace a ConvModule with the conv bl...
4,142
41.71134
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/non_local.py
# Copyright (c) OpenMMLab. All rights reserved. from abc import ABCMeta import torch import torch.nn as nn from ..utils import constant_init, normal_init from .conv_module import ConvModule from .registry import PLUGIN_LAYERS class _NonLocalNd(nn.Module, metaclass=ABCMeta): """Basic Non-local module. This ...
11,012
34.872964
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/norm.py
# Copyright (c) OpenMMLab. All rights reserved. import inspect import torch.nn as nn from mmcv.utils import is_tuple_of from mmcv.utils.parrots_wrapper import SyncBatchNorm, _BatchNorm, _InstanceNorm from .registry import NORM_LAYERS NORM_LAYERS.register_module('BN', module=nn.BatchNorm2d) NORM_LAYERS.register_modul...
5,111
34.255172
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/conv2d_adaptive_padding.py
# Copyright (c) OpenMMLab. All rights reserved. import math from torch import nn from torch.nn import functional as F from .registry import CONV_LAYERS @CONV_LAYERS.register_module() class Conv2dAdaptivePadding(nn.Conv2d): """Implementation of 2D convolution in tensorflow with `padding` as "same", which app...
2,514
38.920635
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/scale.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn class Scale(nn.Module): """A learnable scale parameter. This layer scales the input by a learnable factor. It multiplies a learnable scale parameter of shape (1,) with input of any shape. Args: scale (float): ...
577
25.272727
73
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/conv_ws.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from .registry import CONV_LAYERS def conv_ws_2d(input, weight, bias=None, stride=1, padding=0, dilation=1, grou...
5,417
35.362416
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/conv_module.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn from mmcv.utils import _BatchNorm, _InstanceNorm from ..utils import constant_init, kaiming_init from .activation import build_activation_layer from .conv import build_conv_layer from .norm import build_norm_layer from .padding impo...
8,740
41.227053
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/context_block.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch import nn from ..utils import constant_init, kaiming_init from .registry import PLUGIN_LAYERS def last_zero_init(m): if isinstance(m, nn.Sequential): constant_init(m[-1], val=0) else: constant_init(m, val=0) @PLUGIN_LAY...
4,681
36.15873
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/hswish.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.utils import TORCH_VERSION, digit_version from .registry import ACTIVATION_LAYERS class HSwish(nn.Module): """Hard Swish Module. This module applies the hard swish function: .. math:: Hswish(x) = x * ReLU6(x + 3) / ...
1,019
25.153846
73
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/wrappers.py
# Copyright (c) OpenMMLab. All rights reserved. r"""Modified from https://github.com/facebookresearch/detectron2/blob/master/detectron2/layers/wrappers.py # noqa: E501 Wrap some nn modules to support empty tensor input. Currently, these wrappers are mainly used in mask heads like fcn_mask_head and maskiou_heads since...
6,961
37.464088
120
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/transformer.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import math import warnings from typing import Sequence import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import (Linear, build_activation_layer, build_conv_layer, build_norm_layer) from mmcv.runner.base_m...
37,155
38.318519
109
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/swish.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from .registry import ACTIVATION_LAYERS @ACTIVATION_LAYERS.register_module() class Swish(nn.Module): """Swish Module. This module applies the swish function: .. math:: Swish(x) = x * Sigmoid(x) Returns: ...
485
17.692308
47
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/conv.py
# Copyright (c) OpenMMLab. All rights reserved. from torch import nn from .registry import CONV_LAYERS CONV_LAYERS.register_module('Conv1d', module=nn.Conv1d) CONV_LAYERS.register_module('Conv2d', module=nn.Conv2d) CONV_LAYERS.register_module('Conv3d', module=nn.Conv3d) CONV_LAYERS.register_module('Conv', module=nn.C...
1,447
31.177778
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/upsample.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn import torch.nn.functional as F from ..utils import xavier_init from .registry import UPSAMPLE_LAYERS UPSAMPLE_LAYERS.register_module('nearest', module=nn.Upsample) UPSAMPLE_LAYERS.register_module('bilinear', module=nn.Upsample) @UPSAMPLE_LAYERS....
2,878
32.870588
76
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/generalized_attention.py
# Copyright (c) OpenMMLab. All rights reserved. import math import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from ..utils import kaiming_init from .registry import PLUGIN_LAYERS @PLUGIN_LAYERS.register_module() class GeneralizedAttention(nn.Module): """GeneralizedAttention m...
15,998
37.738499
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/padding.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from .registry import PADDING_LAYERS PADDING_LAYERS.register_module('zero', module=nn.ZeroPad2d) PADDING_LAYERS.register_module('reflect', module=nn.ReflectionPad2d) PADDING_LAYERS.register_module('replicate', module=nn.ReplicationPad2d) def buil...
1,127
29.486486
75
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/bricks/drop.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from mmcv import build_from_cfg from .registry import DROPOUT_LAYERS def drop_path(x, drop_prob=0., training=False): """Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks). We follow th...
2,152
31.621212
140
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/utils/sync_bn.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import mmcv class _BatchNormXd(torch.nn.modules.batchnorm._BatchNorm): """A general BatchNorm layer without input dimension check. Reproduced from @kapily's work: (https://github.com/pytorch/pytorch/issues/41081#issuecomment-783961547) The...
2,347
37.491803
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/utils/weight_init.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import math import warnings import numpy as np import torch import torch.nn as nn from torch import Tensor from mmcv.utils import Registry, build_from_cfg, get_logger, print_log INITIALIZERS = Registry('initializer') def update_init_info(module, init_info...
25,968
36.855685
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/utils/fuse_conv_bn.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn def _fuse_conv_bn(conv, bn): """Fuse conv and bn into one module. Args: conv (nn.Module): Conv to be fused. bn (nn.Module): BN to be fused. Returns: nn.Module: Fused module. """ conv_w = co...
1,881
30.366667
77
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/utils/flops_counter.py
# Modified from flops-counter.pytorch by Vladislav Sovrasov # original repo: https://github.com/sovrasov/flops-counter.pytorch # MIT License # Copyright (c) 2018 Vladislav Sovrasov # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (th...
22,078
35.798333
128
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/cnn/utils/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .flops_counter import get_model_complexity_info from .fuse_conv_bn import fuse_conv_bn from .sync_bn import revert_sync_batchnorm from .weight_init import (INITIALIZERS, Caffe2XavierInit, ConstantInit, KaimingInit, NormalInit, PretrainedInit...
1,023
50.2
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/parallel/data_parallel.py
# Copyright (c) OpenMMLab. All rights reserved. from itertools import chain from torch.nn.parallel import DataParallel from .scatter_gather import scatter_kwargs class MMDataParallel(DataParallel): """The DataParallel module that supports DataContainer. MMDataParallel has two main differences with PyTorch ...
4,306
42.94898
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/parallel/_functions.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch.nn.parallel._functions import _get_stream def scatter(input, devices, streams=None): """Scatters tensor across multiple GPUs.""" if streams is None: streams = [None] * len(devices) if isinstance(input, list): chunk_si...
2,699
34.064935
76
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/parallel/registry.py
# Copyright (c) OpenMMLab. All rights reserved. from torch.nn.parallel import DataParallel, DistributedDataParallel from mmcv.utils import Registry MODULE_WRAPPERS = Registry('module wrapper') MODULE_WRAPPERS.register_module(module=DataParallel) MODULE_WRAPPERS.register_module(module=DistributedDataParallel)
312
33.777778
67
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/parallel/data_container.py
# Copyright (c) OpenMMLab. All rights reserved. import functools import torch def assert_tensor_type(func): @functools.wraps(func) def wrapper(*args, **kwargs): if not isinstance(args[0].data, torch.Tensor): raise AttributeError( f'{args[0].__class__.__name__} has no attr...
2,365
25.288889
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/parallel/distributed_deprecated.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.distributed as dist import torch.nn as nn from torch._utils import (_flatten_dense_tensors, _take_tensors, _unflatten_dense_tensors) from mmcv.utils import TORCH_VERSION, digit_version from .registry import MODULE_WRAPP...
2,817
38.690141
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/parallel/scatter_gather.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch.nn.parallel._functions import Scatter as OrigScatter from ._functions import Scatter from .data_container import DataContainer def scatter(inputs, target_gpus, dim=0): """Scatter inputs to target gpus. The only difference from original ...
2,307
37.466667
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/parallel/distributed.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch.nn.parallel.distributed import (DistributedDataParallel, _find_tensors) from mmcv import print_log from mmcv.utils import TORCH_VERSION, digit_version from .scatter_gather import scatter_kwargs class MM...
4,817
41.637168
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/parallel/collate.py
# Copyright (c) OpenMMLab. All rights reserved. from collections.abc import Mapping, Sequence import torch import torch.nn.functional as F from torch.utils.data.dataloader import default_collate from .data_container import DataContainer def collate(batch, samples_per_gpu=1): """Puts each data field into a tenso...
3,665
42.129412
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/tensorrt/tensorrt_utils.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import onnx import tensorrt as trt import torch from .preprocess import preprocess_onnx def onnx2trt(onnx_model, opt_shape_dict, log_level=trt.Logger.ERROR, fp16_mode=False, max_workspace_size=0, ...
10,315
34.572414
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/onnx/symbolic.py
# Copyright (c) OpenMMLab. All rights reserved. """Modified from https://github.com/pytorch/pytorch.""" import os import warnings import numpy as np import torch from torch.nn.modules.utils import _pair, _single, _triple from torch.onnx.symbolic_helper import parse_args from torch.onnx.symbolic_registry import registe...
19,660
37.55098
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/onnx/info.py
# Copyright (c) OpenMMLab. All rights reserved. import os import warnings import torch def is_custom_op_loaded(): # Following strings of text style are from colorama package bright_style, reset_style = '\x1b[1m', '\x1b[0m' red_text, blue_text = '\x1b[31m', '\x1b[34m' white_background = '\x1b[107m' ...
1,127
30.333333
77
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/onnx/onnx_utils/symbolic_helper.py
# Copyright (c) OpenMMLab. All rights reserved. """Modified from https://github.com/pytorch/pytorch.""" import warnings from functools import wraps from sys import maxsize import torch import torch.onnx # This import monkey-patches graph manipulation methods on Graph, used for the # ONNX symbolics import torch.onnx.ut...
11,172
32.653614
138
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/engine/test.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import pickle import shutil import tempfile import time import torch import torch.distributed as dist import mmcv from mmcv.runner import get_dist_info def single_gpu_test(model, data_loader): """Test model with a single gpu. This method...
7,148
34.216749
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/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...
25,726
34.682386
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/dist_utils.py
# Copyright (c) OpenMMLab. All rights reserved. import functools import os import subprocess from collections import OrderedDict import torch import torch.multiprocessing as mp from torch import distributed as dist from torch._utils import (_flatten_dense_tensors, _take_tensors, _unflatten_de...
5,395
31.70303
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/utils.py
# Copyright (c) OpenMMLab. All rights reserved. import os import random import sys import time import warnings from getpass import getuser from socket import gethostname import numpy as np import torch import mmcv def get_host_info(): """Get hostname and username. Return empty string if exception raised, e...
2,908
29.946809
77
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/iter_based_runner.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import platform import shutil import time import warnings import torch from torch.optim import Optimizer import mmcv from .base_runner import BaseRunner from .builder import RUNNERS from .checkpoint import save_checkpoint from .hooks import IterTim...
11,034
39.273723
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/base_runner.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import logging import os.path as osp import warnings from abc import ABCMeta, abstractmethod import torch from torch.optim import Optimizer import mmcv from ..parallel import is_module_wrapper from .checkpoint import load_checkpoint from .dist_utils import g...
20,844
37.247706
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/fp16_utils.py
# Copyright (c) OpenMMLab. All rights reserved. import functools import warnings from collections import abc from inspect import getfullargspec import numpy as np import torch import torch.nn as nn from mmcv.utils import TORCH_VERSION, digit_version from .dist_utils import allreduce_grads as _allreduce_grads try: ...
16,443
37.874704
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/base_module.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import warnings from abc import ABCMeta from collections import defaultdict from logging import FileHandler import torch.nn as nn from mmcv.runner.dist_utils import master_only from mmcv.utils.logging import get_logger, logger_initialized, print_log class ...
7,874
36.679426
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/epoch_based_runner.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import platform import shutil import time import warnings import torch import mmcv from .base_runner import BaseRunner from .builder import RUNNERS from .checkpoint import save_checkpoint from .utils import get_host_info @RUNNERS.register_module(...
7,569
39.05291
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/hooks/memory.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from .hook import HOOKS, Hook @HOOKS.register_module() class EmptyCacheHook(Hook): def __init__(self, before_epoch=False, after_epoch=True, after_iter=False): self._before_epoch = before_epoch self._after_epoch = after_epoch se...
657
24.307692
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/hooks/sampler_seed.py
# Copyright (c) OpenMMLab. All rights reserved. from .hook import HOOKS, Hook @HOOKS.register_module() class DistSamplerSeedHook(Hook): """Data-loading sampler for distributed training. When distributed training, it is only useful in conjunction with :obj:`EpochBasedRunner`, while :obj:`IterBasedRunner` ...
847
39.380952
76
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/hooks/lr_updater.py
# Copyright (c) OpenMMLab. All rights reserved. import numbers from math import cos, pi import mmcv from .hook import HOOKS, Hook class LrUpdaterHook(Hook): """LR Scheduler in MMCV. Args: by_epoch (bool): LR changes epoch by epoch warmup (string): Type of warmup used. It can be None(use no w...
27,112
38.237337
108
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/hooks/evaluation.py
# Copyright (c) OpenMMLab. All rights reserved. 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 from mmcv.fileio import FileClient from mmcv.utils import is_seq_of from .hook import Ho...
22,413
42.777344
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/hooks/profiler.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings from typing import Callable, List, Optional, Union import torch from ..dist_utils import master_only from .hook import HOOKS, Hook @HOOKS.register_module() class ProfilerHook(Hook): """Profiler to analyze performance during training. PyTorch P...
8,059
43.530387
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/hooks/optimizer.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import logging from collections import defaultdict from itertools import chain from torch.nn.utils import clip_grad from mmcv.utils import TORCH_VERSION, _BatchNorm, digit_version from ..dist_utils import allreduce_grads from ..fp16_utils import LossScaler, ...
23,496
41.184919
82
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/hooks/logger/base.py
# Copyright (c) OpenMMLab. All rights reserved. import numbers from abc import ABCMeta, abstractmethod import numpy as np import torch from ..hook import Hook class LoggerHook(Hook): """Base class for logger hooks. Args: interval (int): Logging interval (every k iterations). Default 10. ign...
5,518
31.85119
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/hooks/logger/pavi.py
# Copyright (c) OpenMMLab. All rights reserved. import json import os import os.path as osp import torch import yaml import mmcv from ....parallel.utils import is_module_wrapper from ...dist_utils import master_only from ..hook import HOOKS from .base import LoggerHook @HOOKS.register_module() class PaviLoggerHook(...
5,124
37.533835
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/hooks/logger/mlflow.py
# Copyright (c) OpenMMLab. All rights reserved. from mmcv.utils import TORCH_VERSION from ...dist_utils import master_only from ..hook import HOOKS from .base import LoggerHook @HOOKS.register_module() class MlflowLoggerHook(LoggerHook): """Class to log metrics and (optionally) a trained model to MLflow. It ...
2,907
34.901235
76
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/hooks/logger/tensorboard.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp from mmcv.utils import TORCH_VERSION, digit_version from ...dist_utils import master_only from ..hook import HOOKS from .base import LoggerHook @HOOKS.register_module() class TensorboardLoggerHook(LoggerHook): """Class to log metrics to Tensor...
2,662
37.042857
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/hooks/logger/text.py
# Copyright (c) OpenMMLab. All rights reserved. import datetime import os import os.path as osp from collections import OrderedDict import torch import torch.distributed as dist import mmcv from mmcv.fileio.file_client import FileClient from mmcv.utils import is_tuple_of, scandir from ..hook import HOOKS from .base i...
10,622
40.33463
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/optimizer/default_constructor.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch from torch.nn import GroupNorm, LayerNorm from mmcv.utils import _BatchNorm, _InstanceNorm, build_from_cfg, is_list_of from mmcv.utils.ext_loader import check_ops_exist from .builder import OPTIMIZER_BUILDERS, OPTIMIZERS @OPTIMIZER_BUILDER...
11,704
45.633466
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/runner/optimizer/builder.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import inspect import torch from ...utils import Registry, build_from_cfg OPTIMIZERS = Registry('optimizer') OPTIMIZER_BUILDERS = Registry('optimizer builder') def register_torch_optimizers(): torch_optimizers = [] for module_name in dir(torch.opt...
1,346
28.933333
73
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/utils/parrots_wrapper.py
# Copyright (c) OpenMMLab. All rights reserved. from functools import partial import torch TORCH_VERSION = torch.__version__ def is_rocm_pytorch() -> bool: is_rocm = False if TORCH_VERSION != 'parrots': try: from torch.utils.cpp_extension import ROCM_HOME is_rocm = True if ((...
3,536
31.75
77
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/utils/seed.py
# Copyright (c) OpenMMLab. All rights reserved. import random import numpy as np import torch def worker_init_fn(worker_id: int, num_workers: int, rank: int, seed: int): """Function to initialize each worker. The seed of each worker equals to ``num_worker * rank + worker_id + user_seed``. Args: ...
651
26.166667
75
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/utils/logging.py
# Copyright (c) OpenMMLab. All rights reserved. import logging import torch.distributed as dist logger_initialized = {} def get_logger(name, log_file=None, log_level=logging.INFO, file_mode='w'): """Initialize and get a logger by name. If the logger has not been initialized, this method will initialize the...
3,986
34.918919
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/utils/hub.py
# Copyright (c) OpenMMLab. All rights reserved. # The 1.6 release of PyTorch switched torch.save to use a new zipfile-based # file format. It will cause RuntimeError when a checkpoint was saved in # torch >= 1.6.0 but loaded in torch < 1.7.0. # More details at https://github.com/open-mmlab/mmpose/issues/904 from .parro...
6,087
45.121212
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/utils/testing.py
# Copyright (c) Open-MMLab. import sys from collections.abc import Iterable from runpy import run_path from shlex import split from typing import Any, Dict, List from unittest.mock import patch def check_python_script(cmd): """Run the python cmd script with `__main__`. The difference between `os.system` is th...
4,290
29.21831
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/utils/ext_loader.py
# Copyright (c) OpenMMLab. All rights reserved. import importlib import os import pkgutil import warnings from collections import namedtuple import torch if torch.__version__ != 'parrots': def load_ext(name, funcs): ext = importlib.import_module('mmcv.' + name) for fun in funcs: asser...
2,021
27.083333
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/utils/__init__.py
# flake8: noqa # Copyright (c) OpenMMLab. All rights reserved. from .config import Config, ConfigDict, DictAction from .misc import (check_prerequisites, concat_list, deprecated_api_warning, has_method, import_modules_from_strings, is_list_of, is_method_overridden, is_seq_of, is_st...
4,222
54.565789
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/utils/trace.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch from mmcv.utils import digit_version def is_jit_tracing() -> bool: if (torch.__version__ != 'parrots' and digit_version(torch.__version__) >= digit_version('1.6.0')): on_trace = torch.jit.is_tracing() # In P...
823
31.96
76
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/utils/env.py
# Copyright (c) OpenMMLab. All rights reserved. """This file holding some environment constant for sharing by other files.""" import os.path as osp import subprocess import sys from collections import defaultdict import cv2 import torch import mmcv from .parrots_wrapper import get_build_config def collect_env(): ...
3,299
33.375
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/deform_roi_pool.py
# Copyright (c) OpenMMLab. All rights reserved. from torch import nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['deform_roi_pool_forward', 'deform_roi...
7,410
35.15122
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/nms.py
import os import numpy as np import torch from mmcv.utils import deprecated_api_warning from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['nms', 'softnms', 'nms_match', 'nms_rotated']) # This function is modified from: https://github.com/pytorch/vision/ class NMSop(torch.autograd.Functi...
17,208
37.412946
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/ball_query.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch.autograd import Function from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', ['ball_query_forward']) class BallQuery(Function): """Find nearby points in spherical space.""" @staticmethod def forward(ctx, min_rad...
1,719
29.175439
77
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/roiaware_pool3d.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch import nn as nn from torch.autograd import Function import mmcv from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['roiaware_pool3d_forward', 'roiaware_pool3d_backward']) class RoIAwarePool3d(nn.Module): """Encode...
4,235
33.16129
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/cc_attention.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import PLUGIN_LAYERS, Scale def NEG_INF_DIAG(n, device): """Returns a diagonal matrix of size [n, n]. The diagonal are all "-inf". This is for avoiding calculating the overlap...
3,046
34.847059
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/deform_conv.py
# Copyright (c) OpenMMLab. All rights reserved. from typing import Tuple, Union import torch import torch.nn as nn import torch.nn.functional as F from torch import Tensor from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair, _single from...
15,594
37.41133
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/knn.py
import torch from torch.autograd import Function from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', ['knn_forward']) class KNN(Function): r"""KNN (CUDA) based on heap data structure. Modified from `PAConv <https://github.com/CVMI-Lab/PAConv/tree/main/ scene_seg/lib/pointops/src/knn...
2,614
32.101266
77
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/correlation.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch import Tensor, nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['correlation_forw...
6,697
33
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/roi_pool.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', ...
2,517
27.942529
75
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/roi_align.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.utils import _pair from ..utils import deprecated_api_warning, ext_loader ext_module = ext_loader.load_ext('_ext', ...
8,520
36.871111
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/sync_bn.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.distributed as dist import torch.nn.functional as F from torch.autograd import Function from torch.autograd.function import once_differentiable from torch.nn.modules.module import Module from torch.nn.parameter import Parameter from mmcv.cnn imp...
11,247
39.171429
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/min_area_polygons.py
# Copyright (c) OpenMMLab. All rights reserved. from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', ['min_area_polygons']) def min_area_polygons(pointsets): """Find the smallest polygons that surrounds all points in the point sets. Args: pointsets (Tensor): point sets with shape ...
555
28.263158
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/roipoint_pool3d.py
from torch import nn as nn from torch.autograd import Function from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', ['roipoint_pool3d_forward']) class RoIPointPool3d(nn.Module): """Encode the geometry-specific features of each 3D proposal. Please refer to `Paper of PartA2 <https://arxiv....
3,008
37.576923
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/saconv.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import CONV_LAYERS, ConvAWS2d, constant_init from mmcv.ops.deform_conv import deform_conv2d from mmcv.utils import TORCH_VERSION, digit_version @CONV_LAYERS.register_module(name='SAC') cla...
5,824
38.62585
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/point_sample.py
# Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend # noqa from os import path as osp import torch import torch.nn as nn import torch.nn.functional as F from torch.nn.modules.utils import _pair from torch.onnx.operators import shape_as_tensor def bilinear_grid_sample(im, g...
12,437
34.84438
101
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/upfirdn2d.py
# modified from https://github.com/rosinality/stylegan2-pytorch/blob/master/op/upfirdn2d.py # noqa:E501 # Copyright (c) 2021, NVIDIA Corporation. All rights reserved. # NVIDIA Source Code License for StyleGAN2 with Adaptive Discriminator # Augmentation (ADA) # =========================================================...
11,798
34.646526
104
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/fused_bias_leakyrelu.py
# modified from https://github.com/rosinality/stylegan2-pytorch/blob/master/op/fused_act.py # noqa:E501 # Copyright (c) 2021, NVIDIA Corporation. All rights reserved. # NVIDIA Source Code License for StyleGAN2 with Adaptive Discriminator # Augmentation (ADA) # ==========================================================...
10,111
36.313653
103
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/group_points.py
# Copyright (c) OpenMMLab. All rights reserved. from typing import Tuple import torch from torch import nn as nn from torch.autograd import Function from ..utils import ext_loader from .ball_query import ball_query from .knn import knn ext_module = ext_loader.load_ext( '_ext', ['group_points_forward', 'group_poi...
8,376
33.615702
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/iou3d.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', [ 'iou3d_boxes_iou_bev_forward', 'iou3d_nms_forward', 'iou3d_nms_normal_forward' ]) def boxes_iou_bev(boxes_a, boxes_b): """Calculate boxes IoU in the Bird's Eye View. ...
3,138
33.877778
77
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/convex_iou.py
# Copyright (c) OpenMMLab. All rights reserved. from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', ['convex_iou', 'convex_giou']) def convex_giou(pointsets, polygons): """Return generalized intersection-over-union (Jaccard index) between point sets and polygons. Args: points...
1,673
34.617021
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/active_rotated_filter.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch.autograd import Function from torch.autograd.function import once_differentiable from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['active_rotated_filter_forward', 'active_rotated_filter_backward']) class ActiveR...
2,101
32.903226
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/border_align.py
# Copyright (c) OpenMMLab. All rights reserved. # modified from # https://github.com/Megvii-BaseDetection/cvpods/blob/master/cvpods/layers/border_align.py import torch import torch.nn as nn from torch.autograd import Function from torch.autograd.function import once_differentiable from ..utils import ext_loader ext_...
3,703
32.672727
90
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/carafe.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from torch.autograd import Function from torch.nn.modules.module import Module from ..cnn import UPSAMPLE_LAYERS, normal_init, xavier_init from ..utils import ext_loader ext_module = ext_loader.load_ext(...
9,899
33.256055
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/points_in_boxes.py
import torch from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', [ 'points_in_boxes_part_forward', 'points_in_boxes_cpu_forward', 'points_in_boxes_all_forward' ]) def points_in_boxes_part(points, boxes): """Find the box in which each point is (CUDA). Args: points (torch....
5,367
38.182482
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/sparse_ops.py
# Copyright 2019 Yan Yan # # 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 applicable law or agreed to in writing, soft...
6,830
38.034286
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/box_iou_rotated.py
# Copyright (c) OpenMMLab. All rights reserved. from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', ['box_iou_rotated']) def box_iou_rotated(bboxes1, bboxes2, mode='iou', aligned=False, clockwise=True): """Return ...
5,173
34.197279
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/three_interpolate.py
from typing import Tuple import torch from torch.autograd import Function from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['three_interpolate_forward', 'three_interpolate_backward']) class ThreeInterpolate(Function): """Performs weighted linear interpolation on 3 features. Ple...
2,246
31.1
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/corner_pool.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch import nn from torch.autograd import Function from ..utils import ext_loader ext_module = ext_loader.load_ext('_ext', [ 'top_pool_forward', 'top_pool_backward', 'bottom_pool_forward', 'bottom_pool_backward', 'left_pool_forward', 'left_poo...
4,757
28.012195
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/tin_shift.py
# Copyright (c) OpenMMLab. All rights reserved. # Code reference from "Temporal Interlacing Network" # https://github.com/deepcs233/TIN/blob/master/cuda_shift/rtc_wrap.py # Hao Shao, Shengju Qian, Yu Liu # shaoh19@mails.tsinghua.edu.cn, sjqian@cse.cuhk.edu.hk, yuliu@ee.cuhk.edu.hk import torch import torch.nn as nn fr...
2,208
29.680556
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/rotated_feature_align.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch.autograd import Function from torch.autograd.function import once_differentiable from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['rotated_feature_align_forward', 'rotated_feature_align_backward']) class Rotated...
2,912
34.096386
78
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/sparse_modules.py
# Copyright 2019 Yan Yan # # 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 applicable law or agreed to in writing, soft...
7,040
33.856436
79
py
DDQ
DDQ-main/mmcv-1.4.7/mmcv/ops/assign_score_withk.py
from torch.autograd import Function from ..utils import ext_loader ext_module = ext_loader.load_ext( '_ext', ['assign_score_withk_forward', 'assign_score_withk_backward']) class AssignScoreWithK(Function): r"""Perform weighted sum to generate output features according to scores. Modified from `PAConv <h...
4,552
34.850394
79
py