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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/losses/dice_loss.py
"""Modified from https://github.com/LikeLy-Journey/SegmenTron/blob/master/ segmentron/solver/loss.py (Apache-2.0 License)""" import torch import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import get_class_weight, weighted_loss @weighted_loss def dice_loss(pred, ...
4,239
34.333333
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/losses/lovasz_loss.py
"""Modified from https://github.com/bermanmaxim/LovaszSoftmax/blob/master/pytor ch/lovasz_losses.py Lovasz-Softmax and Jaccard hinge loss in PyTorch Maxim Berman 2018 ESAT-PSI KU Leuven (MIT License)""" import annotator.uniformer.mmcv as mmcv import torch import torch.nn as nn import torch.nn.functional as F from ..b...
11,419
36.565789
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/losses/utils.py
import functools import annotator.uniformer.mmcv as mmcv import numpy as np import torch.nn.functional as F def get_class_weight(class_weight): """Get class weight for loss function. Args: class_weight (list[float] | str | None): If class_weight is a str, take it as a file name and read ...
3,718
29.483607
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/losses/accuracy.py
import torch.nn as nn def accuracy(pred, target, topk=1, thresh=None): """Calculate accuracy according to the prediction and target. Args: pred (torch.Tensor): The model prediction, shape (N, num_class, ...) target (torch.Tensor): The target of each prediction, shape (N, , ...) topk (...
2,970
36.607595
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/losses/cross_entropy_loss.py
import torch import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import get_class_weight, weight_reduce_loss def cross_entropy(pred, label, weight=None, class_weight=None, reduction='mean', ...
7,437
36.376884
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/backbones/hrnet.py
import torch.nn as nn from annotator.uniformer.mmcv.cnn import (build_conv_layer, build_norm_layer, constant_init, kaiming_init) from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmcv.utils.parrots_wrapper import _BatchNorm from annotator.uniformer.mmseg.ops imp...
21,226
37.178058
92
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/backbones/mobilenet_v2.py
import logging import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule, constant_init, kaiming_init from annotator.uniformer.mmcv.runner import load_checkpoint from torch.nn.modules.batchnorm import _BatchNorm from ..builder import BACKBONES from ..utils import InvertedResidual, make_divisible @BA...
6,981
37.574586
80
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/backbones/fast_scnn.py
import torch import torch.nn as nn from annotator.uniformer.mmcv.cnn import (ConvModule, DepthwiseSeparableConvModule, constant_init, kaiming_init) from torch.nn.modules.batchnorm import _BatchNorm from annotator.uniformer.mmseg.models.decode_heads.psp_head import PPM from annotator.uniformer.mms...
14,436
37.396277
98
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/backbones/resnet.py
import torch.nn as nn import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import (build_conv_layer, build_norm_layer, build_plugin_layer, constant_init, kaiming_init) from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmcv.utils.parrots_wrapper i...
24,310
34.28447
97
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/backbones/cgnet.py
import torch import torch.nn as nn import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import (ConvModule, build_conv_layer, build_norm_layer, constant_init, kaiming_init) from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmcv.utils.parrots_wrap...
13,183
34.826087
89
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/backbones/vit.py
"""Modified from https://github.com/rwightman/pytorch-image- models/blob/master/timm/models/vision_transformer.py.""" import math import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import (Conv2d, Linear, build_activation_layer, bui...
18,085
38.317391
128
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/backbones/resnext.py
import math from annotator.uniformer.mmcv.cnn import build_conv_layer, build_norm_layer from ..builder import BACKBONES from ..utils import ResLayer from .resnet import Bottleneck as _Bottleneck from .resnet import ResNet class Bottleneck(_Bottleneck): """Bottleneck block for ResNeXt. If style is "pytorch"...
5,161
34.356164
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/backbones/mobilenet_v3.py
import logging import annotator.uniformer.mmcv as mmcv import torch.nn as nn from annotator.uniformer.mmcv.cnn import ConvModule, constant_init, kaiming_init from annotator.uniformer.mmcv.cnn.bricks import Conv2dAdaptivePadding from annotator.uniformer.mmcv.runner import load_checkpoint from torch.nn.modules.batchnorm...
10,390
39.589844
80
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/backbones/unet.py
import torch.nn as nn import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import (UPSAMPLE_LAYERS, ConvModule, build_activation_layer, build_norm_layer, constant_init, kaiming_init) from annotator.uniformer.mmcv.runner import load_checkpoint from annotator.uniformer.mmcv.utils.pa...
18,269
41.488372
94
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/backbones/resnest.py
import math import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as cp from annotator.uniformer.mmcv.cnn import build_conv_layer, build_norm_layer from ..builder import BACKBONES from ..utils import ResLayer from .resnet import Bottleneck as _Bottleneck from .resnet import ...
10,110
31.098413
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/models/backbones/uniformer.py
# -------------------------------------------------------- # UniFormer # Copyright (c) 2022 SenseTime X-Lab # Licensed under The MIT License [see LICENSE for details] # Written by Kunchang Li # -------------------------------------------------------- from collections import OrderedDict import math from functools impo...
18,476
42.680851
145
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/datasets/custom.py
import os import os.path as osp from collections import OrderedDict from functools import reduce import annotator.uniformer.mmcv as mmcv import numpy as np from annotator.uniformer.mmcv.utils import print_log from prettytable import PrettyTable from torch.utils.data import Dataset from annotator.uniformer.mmseg.core ...
14,716
35.700748
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/datasets/dataset_wrappers.py
from torch.utils.data.dataset import ConcatDataset as _ConcatDataset from .builder import DATASETS @DATASETS.register_module() class ConcatDataset(_ConcatDataset): """A wrapper of concatenated dataset. Same as :obj:`torch.utils.data.dataset.ConcatDataset`, but concat the group flag for image aspect rati...
1,499
28.411765
78
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/datasets/builder.py
import copy import platform import random from functools import partial import numpy as np from annotator.uniformer.mmcv.parallel import collate from annotator.uniformer.mmcv.runner import get_dist_info from annotator.uniformer.mmcv.utils import Registry, build_from_cfg from annotator.uniformer.mmcv.utils.parrots_wrap...
5,951
34.011765
85
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/datasets/pipelines/formating.py
from collections.abc import Sequence import annotator.uniformer.mmcv as mmcv import numpy as np import torch from annotator.uniformer.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 ty...
9,276
31.100346
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/ops/wrappers.py
import warnings import torch.nn as nn import torch.nn.functional as F def resize(input, size=None, scale_factor=None, mode='nearest', align_corners=None, warning=True): if warning: if size is not None and align_corners: input_h, input_w =...
1,827
34.843137
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmseg/ops/encoding.py
import torch from torch import nn from torch.nn import functional as F class Encoding(nn.Module): """Encoding Layer: a learnable residual encoder. Input is of shape (batch_size, channels, height, width). Output is of shape (batch_size, num_codes, channels). Args: channels: dimension of the ...
2,788
36.186667
78
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/ccnet_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,258
26.977778
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/ann_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,346
27.659574
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/gcnet_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,326
27.234043
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/encnet_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,435
28.306122
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/danet_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,261
27.044444
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/dnl_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,316
27.021277
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/pspnet_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,271
27.266667
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/upernet_r50.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 1, 1), strides=...
1,301
27.933333
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/apcnet_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,302
27.955556
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/psanet_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,406
27.14
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/deeplabv3plus_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,343
27.595745
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/emanet_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,329
26.708333
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/dmnet_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,302
27.955556
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/fpn_r50.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 1, 1), strides=...
1,056
27.567568
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/deeplabv3_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,273
27.311111
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/pointrend_r50.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='CascadeEncoderDecoder', num_stages=2, pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1...
1,704
28.912281
78
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/ocrnet_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='CascadeEncoderDecoder', num_stages=2, pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1...
1,385
27.875
78
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/nonlocal_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,315
27
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/configs/_base_/models/fcn_r50-d8.py
# model settings norm_cfg = dict(type='SyncBN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=...
1,285
26.956522
74
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/image/misc.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import annotator.uniformer.mmcv as mmcv try: import torch except ImportError: torch = None def tensor2imgs(tensor, mean=(0, 0, 0), std=(1, 1, 1), to_rgb=True): """Convert tensor to 3-channel images. Args: tensor (torch.Tenso...
1,410
30.355556
77
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/cnn/resnet.py
# Copyright (c) OpenMMLab. All rights reserved. import logging import torch.nn as nn import torch.utils.checkpoint as cp from .utils import constant_init, kaiming_init def conv3x3(in_planes, out_planes, stride=1, dilation=1): """3x3 convolution with padding.""" return nn.Conv2d( in_planes, o...
9,955
30.40694
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/cnn/vgg.py
# Copyright (c) OpenMMLab. All rights reserved. import logging import torch.nn as nn from .utils import constant_init, kaiming_init, normal_init def conv3x3(in_planes, out_planes, dilation=1): """3x3 convolution with padding.""" return nn.Conv2d( in_planes, out_planes, kernel_size=3,...
6,053
33.397727
77
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/cnn/__init__.py
# Copyright (c) OpenMMLab. All rights reserved. from .alexnet import AlexNet # yapf: disable from .bricks import (ACTIVATION_LAYERS, CONV_LAYERS, NORM_LAYERS, PADDING_LAYERS, PLUGIN_LAYERS, UPSAMPLE_LAYERS, ContextBlock, Conv2d, Conv3d, ConvAWS2d, ConvModule, ...
2,438
57.071429
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 annotator.uniformer.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...
2,508
25.978495
87
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/cnn/bricks/hsigmoid.py
# Copyright (c) OpenMMLab. All rights reserved. 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_value) Default...
1,097
30.371429
76
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/cnn/bricks/norm.py
# Copyright (c) OpenMMLab. All rights reserved. import inspect import torch.nn as nn from annotator.uniformer.mmcv.utils import is_tuple_of from annotator.uniformer.mmcv.utils.parrots_wrapper import SyncBatchNorm, _BatchNorm, _InstanceNorm from .registry import NORM_LAYERS NORM_LAYERS.register_module('BN', module=nn...
5,154
34.551724
99
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/cnn/bricks/conv_module.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn from annotator.uniformer.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_laye...
8,760
41.323671
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/cnn/bricks/hswish.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from .registry import ACTIVATION_LAYERS @ACTIVATION_LAYERS.register_module() class HSwish(nn.Module): """Hard Swish Module. This module applies the hard swish function: .. math:: Hswish(x) = x * ReLU6(x + 3) / 6 Args: ...
651
20.733333
65
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/cnn/bricks/transformer.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import warnings import torch import torch.nn as nn from annotator.uniformer.mmcv import ConfigDict, deprecated_api_warning from annotator.uniformer.mmcv.cnn import Linear, build_activation_layer, build_norm_layer from annotator.uniformer.mmcv.runner.base_mod...
24,637
40.338926
129
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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,446
31.155556
78
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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,880
32.894118
76
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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,999
37.74092
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/cnn/bricks/drop.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from annotator.uniformer.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...
2,172
31.924242
140
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/cnn/utils/sync_bn.py
import torch import annotator.uniformer.mmcv as 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 only difference bet...
2,327
37.8
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 annotator.uniformer.mmcv.utils import Registry, build_from_cfg, get_logger, print_log INITIALIZERS = Registry('initializer') def update_init_in...
26,006
36.966423
99
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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,104
35.841667
128
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 ...
3,912
42.477778
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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,830
34.3875
76
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/parallel/registry.py
# Copyright (c) OpenMMLab. All rights reserved. from torch.nn.parallel import DataParallel, DistributedDataParallel from annotator.uniformer.mmcv.utils import Registry MODULE_WRAPPERS = Registry('module wrapper') MODULE_WRAPPERS.register_module(module=DataParallel) MODULE_WRAPPERS.register_module(module=DistributedDa...
332
36
67
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 annotator.uniformer.mmcv.utils import TORCH_VERSION, digit_version from .registry...
2,837
38.971831
78
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/parallel/distributed.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from torch.nn.parallel.distributed import (DistributedDataParallel, _find_tensors) from annotator.uniformer.mmcv import print_log from annotator.uniformer.mmcv.utils import TORCH_VERSION, digit_version from .scatter...
4,857
41.99115
78
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 annotator.uniformer.mmcv as mmcv from annotator.uniformer.mmcv.runner import get_dist_info def single_gpu_test(model, data_loader): "...
7,196
34.453202
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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,136
34.504237
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 annotator.uniformer.mmcv as mmcv def get_host_info(): """Get hostname and username. Return empty s...
2,936
30.244681
77
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 annotator.uniformer.mmcv as mmcv from .base_runner import BaseRunner from .builder import RUNNERS from .checkpoint import save_checkpoin...
11,062
39.375912
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 annotator.uniformer.mmcv as mmcv from ..parallel import is_module_wrapper from .checkpoint import load_checkpoi...
20,846
37.392265
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 annotator.uniformer.mmcv.utils import TORCH_VERSION, digit_version from .dist_utils import allreduce_grads as _allr...
15,784
37.406326
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 annotator.uniformer.mmcv.runner.dist_utils import master_only from annotator.uniformer.mmcv.utils.logging import get_logger...
7,502
37.280612
92
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 annotator.uniformer.mmcv as mmcv from .base_runner import BaseRunner from .builder import RUNNERS from .checkpoint import save_checkpoint from .utils import get_host_info...
7,565
39.244681
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/runner/hooks/lr_updater.py
# Copyright (c) OpenMMLab. All rights reserved. import numbers from math import cos, pi import annotator.uniformer.mmcv as 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 u...
26,034
37.800298
108
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 annotator.uniformer.mmcv.fileio import FileClient from annotator.uniformer.mmcv.uti...
22,448
43.017647
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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,041
43.430939
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/runner/hooks/optimizer.py
# Copyright (c) OpenMMLab. All rights reserved. import copy from collections import defaultdict from itertools import chain from torch.nn.utils import clip_grad from annotator.uniformer.mmcv.utils import TORCH_VERSION, _BatchNorm, digit_version from ..dist_utils import allreduce_grads from ..fp16_utils import LossSca...
21,652
41.540275
83
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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). ignore_last (bo...
5,451
31.646707
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 annotator.uniformer.mmcv as mmcv from ....parallel.utils import is_module_wrapper from ...dist_utils import master_only from ..hook import HOOKS from .base import LoggerHook @HOOKS.register_mo...
4,378
36.110169
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/runner/hooks/logger/mlflow.py
# Copyright (c) OpenMMLab. All rights reserved. from ...dist_utils import master_only from ..hook import HOOKS from .base import LoggerHook @HOOKS.register_module() class MlflowLoggerHook(LoggerHook): def __init__(self, exp_name=None, tags=None, log_model=True, ...
2,838
34.936709
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/runner/hooks/logger/tensorboard.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp from annotator.uniformer.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): def __init__...
2,077
34.827586
77
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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 annotator.uniformer.mmcv as mmcv from annotator.uniformer.mmcv.fileio.file_client import FileClient from annotator.uniformer.mmcv.uti...
10,684
40.575875
79
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/mmcv/runner/optimizer/default_constructor.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch from torch.nn import GroupNorm, LayerNorm from annotator.uniformer.mmcv.utils import _BatchNorm, _InstanceNorm, build_from_cfg, is_list_of from annotator.uniformer.mmcv.utils.ext_loader import check_ops_exist from .builder import OPTIMIZER_B...
11,803
46.216
96
py
Text2Video-Zero
Text2Video-Zero-main/annotator/uniformer/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