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/mmdet/models/roi_heads/htc_roi_head.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch import torch.nn.functional as F from mmdet.core import (bbox2result, bbox2roi, bbox_mapping, merge_aug_bboxes, merge_aug_masks, multiclass_nms) from ..builder import HEADS, build_head, build_roi_extractor from ..uti...
27,630
42.928458
79
py
DDQ
DDQ-main/mmdet/models/roi_heads/test_mixins.py
# Copyright (c) OpenMMLab. All rights reserved. import sys import warnings import numpy as np import torch from mmdet.core import (bbox2roi, bbox_mapping, merge_aug_bboxes, merge_aug_masks, multiclass_nms) if sys.version_info >= (3, 7): from mmdet.utils.contextmanagers import completed ...
13,557
42.455128
79
py
DDQ
DDQ-main/mmdet/models/roi_heads/roi_extractors/base_roi_extractor.py
# Copyright (c) OpenMMLab. All rights reserved. from abc import ABCMeta, abstractmethod import torch import torch.nn as nn from mmcv import ops from mmcv.runner import BaseModule class BaseRoIExtractor(BaseModule, metaclass=ABCMeta): """Base class for RoI extractor. Args: roi_layer (dict): Specify R...
3,002
32.741573
78
py
DDQ
DDQ-main/mmdet/models/roi_heads/roi_extractors/single_level_roi_extractor.py
# Copyright (c) OpenMMLab. All rights reserved. import torch from mmcv.runner import force_fp32 from mmdet.models.builder import ROI_EXTRACTORS from .base_roi_extractor import BaseRoIExtractor @ROI_EXTRACTORS.register_module() class SingleRoIExtractor(BaseRoIExtractor): """Extract RoI features from a single leve...
4,829
40.637931
79
py
DDQ
DDQ-main/mmdet/models/roi_heads/bbox_heads/bbox_head.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from mmcv.runner import BaseModule, auto_fp16, force_fp32 from torch.nn.modules.utils import _pair from mmdet.core import build_bbox_coder, multi_apply, multiclass_nms from mmdet.models.builder import HEA...
25,657
42.122689
79
py
DDQ
DDQ-main/mmdet/models/roi_heads/bbox_heads/sabl_head.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule from mmcv.runner import BaseModule, force_fp32 from mmdet.core import build_bbox_coder, multi_apply, multiclass_nms from mmdet.models.builder import HEAD...
25,392
41.534338
79
py
DDQ
DDQ-main/mmdet/models/roi_heads/bbox_heads/dii_head.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from mmcv.cnn import (bias_init_with_prob, build_activation_layer, build_norm_layer) from mmcv.cnn.bricks.transformer import FFN, MultiheadAttention from mmcv.runner import auto_fp16, force_fp32 from mmdet.core imp...
19,199
43.964871
79
py
DDQ
DDQ-main/mmdet/models/roi_heads/bbox_heads/convfc_bbox_head.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.cnn import ConvModule from mmdet.models.builder import HEADS from mmdet.models.utils import build_linear_layer from .bbox_head import BBoxHead @HEADS.register_module() class ConvFCBBoxHead(BBoxHead): r"""More general bbox head, with ...
8,364
35.369565
79
py
DDQ
DDQ-main/mmdet/models/roi_heads/bbox_heads/double_bbox_head.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.cnn import ConvModule from mmcv.runner import BaseModule, ModuleList from mmdet.models.backbones.resnet import Bottleneck from mmdet.models.builder import HEADS from .bbox_head import BBoxHead class BasicResBlock(BaseModule): """Basi...
5,733
31.03352
79
py
DDQ
DDQ-main/mmdet/models/roi_heads/shared_heads/res_layer.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn from mmcv.runner import BaseModule, auto_fp16 from mmdet.models.backbones import ResNet from mmdet.models.builder import SHARED_HEADS from mmdet.models.utils import ResLayer as _ResLayer @SHARED_HEADS.register_module() class ResLa...
2,587
30.950617
76
py
DDQ
DDQ-main/mmdet/models/roi_heads/mask_heads/grid_head.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule from mmcv.runner import BaseModule from mmdet.models.builder import HEADS, build_loss @HEADS.register_module() class GridHead(BaseModule): def __i...
15,579
41.802198
79
py
DDQ
DDQ-main/mmdet/models/roi_heads/mask_heads/dynamic_mask_head.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from mmcv.runner import auto_fp16, force_fp32 from mmdet.core import mask_target from mmdet.models.builder import HEADS from mmdet.models.dense_heads.atss_head import reduce_mean from mmdet.models.utils import build_transformer from .fc...
5,665
37.283784
79
py
DDQ
DDQ-main/mmdet/models/roi_heads/mask_heads/maskiou_head.py
# Copyright (c) OpenMMLab. All rights reserved. import numpy as np import torch import torch.nn as nn from mmcv.cnn import Conv2d, Linear, MaxPool2d from mmcv.runner import BaseModule, force_fp32 from torch.nn.modules.utils import _pair from mmdet.models.builder import HEADS, build_loss @HEADS.register_module() clas...
7,382
39.125
79
py
DDQ
DDQ-main/mmdet/models/roi_heads/mask_heads/feature_relay_head.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.runner import BaseModule, auto_fp16 from mmdet.models.builder import HEADS @HEADS.register_module() class FeatureRelayHead(BaseModule): """Feature Relay Head used in `SCNet <https://arxiv.org/abs/2012.10150>`_. Args: in_...
1,930
34.759259
78
py
DDQ
DDQ-main/mmdet/models/roi_heads/mask_heads/global_context_head.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn from mmcv.cnn import ConvModule from mmcv.runner import BaseModule, auto_fp16, force_fp32 from mmdet.models.builder import HEADS from mmdet.models.utils import ResLayer, SimplifiedBasicBlock @HEADS.register_module() class GlobalContextHead(BaseMod...
3,774
36.009804
79
py
DDQ
DDQ-main/mmdet/models/roi_heads/mask_heads/fcn_mask_head.py
# Copyright (c) OpenMMLab. All rights reserved. from warnings import warn import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule, build_conv_layer, build_upsample_layer from mmcv.ops.carafe import CARAFEPack from mmcv.runner import BaseModule, ModuleList, ...
17,449
41.251816
85
py
DDQ
DDQ-main/mmdet/models/roi_heads/mask_heads/fused_semantic_head.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule from mmcv.runner import BaseModule, auto_fp16, force_fp32 from mmdet.models.builder import HEADS, build_loss @HEADS.register_module() class FusedSemanticHead(BaseModu...
4,150
34.177966
79
py
DDQ
DDQ-main/mmdet/models/roi_heads/mask_heads/mask_point_head.py
# Copyright (c) OpenMMLab. All rights reserved. # Modified from https://github.com/facebookresearch/detectron2/tree/master/projects/PointRend/point_head/point_head.py # noqa import torch import torch.nn as nn from mmcv.cnn import ConvModule from mmcv.ops import point_sample, rel_roi_point_to_rel_img_point from mmcv.r...
13,455
42.830619
126
py
DDQ
DDQ-main/mmdet/models/losses/ghm_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import weight_reduce_loss def _expand_onehot_labels(labels, label_weights, label_channels): bin_labels = labels.new_full((labels.size(0), label_channels), 0)...
7,923
36.028037
79
py
DDQ
DDQ-main/mmdet/models/losses/mse_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import weighted_loss @weighted_loss def mse_loss(pred, target): """Warpper of mse loss.""" return F.mse_loss(pred, target, reduction='none') @LOSSES.register_module...
1,905
31.862069
78
py
DDQ
DDQ-main/mmdet/models/losses/dice_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn from ..builder import LOSSES from .utils import weight_reduce_loss def dice_loss(pred, target, weight=None, eps=1e-3, reduction='mean', naive_dice=False, ...
5,324
35.22449
78
py
DDQ
DDQ-main/mmdet/models/losses/pisa_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import torch from mmdet.core import bbox_overlaps @mmcv.jit(derivate=True, coderize=True) def isr_p(cls_score, bbox_pred, bbox_targets, rois, sampling_results, loss_cls, bbox_coder, k=2, ...
7,216
38.010811
79
py
DDQ
DDQ-main/mmdet/models/losses/balanced_l1_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import numpy as np import torch import torch.nn as nn from ..builder import LOSSES from .utils import weighted_loss @mmcv.jit(derivate=True, coderize=True) @weighted_loss def balanced_l1_loss(pred, target, beta=1.0,...
4,252
33.024
79
py
DDQ
DDQ-main/mmdet/models/losses/iou_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import math import warnings import mmcv import torch import torch.nn as nn from mmdet.core import bbox_overlaps from ..builder import LOSSES from .utils import weighted_loss @mmcv.jit(derivate=True, coderize=True) @weighted_loss def iou_loss(pred, target, linear=False...
15,714
32.084211
79
py
DDQ
DDQ-main/mmdet/models/losses/smooth_l1_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import torch import torch.nn as nn from ..builder import LOSSES from .utils import weighted_loss @mmcv.jit(derivate=True, coderize=True) @weighted_loss def smooth_l1_loss(pred, target, beta=1.0): """Smooth L1 loss. Args: pred (torch.Tensor)...
4,635
30.537415
78
py
DDQ
DDQ-main/mmdet/models/losses/gfocal_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import weighted_loss @mmcv.jit(derivate=True, coderize=True) @weighted_loss def quality_focal_loss(pred, target, beta=2.0): r"""Quality Focal Loss (QFL) is fr...
9,834
38.979675
79
py
DDQ
DDQ-main/mmdet/models/losses/varifocal_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import weight_reduce_loss @mmcv.jit(derivate=True, coderize=True) def varifocal_loss(pred, target, weight=None, ...
5,365
38.748148
79
py
DDQ
DDQ-main/mmdet/models/losses/utils.py
# Copyright (c) OpenMMLab. All rights reserved. import functools import mmcv import torch.nn.functional as F def reduce_loss(loss, reduction): """Reduce loss as specified. Args: loss (Tensor): Elementwise loss tensor. reduction (str): Options are "none", "mean" and "sum". Return: ...
3,103
29.431373
79
py
DDQ
DDQ-main/mmdet/models/losses/seesaw_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .accuracy import accuracy from .cross_entropy_loss import cross_entropy from .utils import weight_reduce_loss def seesaw_ce_loss(cls_score, labels, ...
10,136
37.543726
79
py
DDQ
DDQ-main/mmdet/models/losses/ae_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import torch import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES @mmcv.jit(derivate=True, coderize=True) def ae_loss_per_image(tl_preds, br_preds, match): """Associative Embedding Loss in one image. Associative Embedd...
3,857
36.096154
143
py
DDQ
DDQ-main/mmdet/models/losses/accuracy.py
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import torch.nn as nn @mmcv.jit(coderize=True) 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) targe...
2,990
36.3875
79
py
DDQ
DDQ-main/mmdet/models/losses/focal_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from mmcv.ops import sigmoid_focal_loss as _sigmoid_focal_loss from ..builder import LOSSES from .utils import weight_reduce_loss # This method is only for debugging def py_sigmoid_focal_loss(pred, ...
10,420
41.534694
79
py
DDQ
DDQ-main/mmdet/models/losses/cross_entropy_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import weight_reduce_loss def cross_entropy(pred, label, weight=None, reduction='mean', a...
9,696
37.480159
79
py
DDQ
DDQ-main/mmdet/models/losses/gaussian_focal_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import torch.nn as nn from ..builder import LOSSES from .utils import weighted_loss @mmcv.jit(derivate=True, coderize=True) @weighted_loss def gaussian_focal_loss(pred, gaussian_target, alpha=2.0, gamma=4.0): """`Focal Loss <https://arxiv.org/abs/1708.0...
3,312
34.623656
108
py
DDQ
DDQ-main/mmdet/models/losses/kd_loss.py
# Copyright (c) OpenMMLab. All rights reserved. import mmcv import torch.nn as nn import torch.nn.functional as F from ..builder import LOSSES from .utils import weighted_loss @mmcv.jit(derivate=True, coderize=True) @weighted_loss def knowledge_distillation_kl_div_loss(pred, so...
2,912
31.730337
78
py
DDQ
DDQ-main/mmdet/models/backbones/pvt.py
# Copyright (c) OpenMMLab. All rights reserved. import math import warnings import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import (Conv2d, build_activation_layer, build_norm_layer, constant_init, normal_init, trunc_normal_init) from mmcv.cnn.br...
23,217
38.219595
89
py
DDQ
DDQ-main/mmdet/models/backbones/hrnet.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn from mmcv.cnn import build_conv_layer, build_norm_layer from mmcv.runner import BaseModule, ModuleList, Sequential from torch.nn.modules.batchnorm import _BatchNorm from ..builder import BACKBONES from .resnet import BasicBlock, Bot...
23,106
38.164407
79
py
DDQ
DDQ-main/mmdet/models/backbones/regnet.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import numpy as np import torch.nn as nn from mmcv.cnn import build_conv_layer, build_norm_layer from ..builder import BACKBONES from .resnet import ResNet from .resnext import Bottleneck @BACKBONES.register_module() class RegNet(ResNet): """RegNet...
13,605
37.112045
79
py
DDQ
DDQ-main/mmdet/models/backbones/mobilenet_v2.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn from mmcv.cnn import ConvModule from mmcv.runner import BaseModule from torch.nn.modules.batchnorm import _BatchNorm from ..builder import BACKBONES from ..utils import InvertedResidual, make_divisible @BACKBONES.register_module()...
7,599
37.383838
78
py
DDQ
DDQ-main/mmdet/models/backbones/swin.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings from collections import OrderedDict from copy import deepcopy import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as cp from mmcv.cnn import build_norm_layer, constant_init, trunc_normal_init from mmcv.cnn.bric...
30,138
38.448953
79
py
DDQ
DDQ-main/mmdet/models/backbones/trident_resnet.py
# Copyright (c) OpenMMLab. All rights reserved. import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as cp from mmcv.cnn import build_conv_layer, build_norm_layer from mmcv.runner import BaseModule from torch.nn.modules.utils import _pair from mmdet.models.backbones.resnet i...
11,129
36.22408
79
py
DDQ
DDQ-main/mmdet/models/backbones/detectors_resnext.py
# Copyright (c) OpenMMLab. All rights reserved. import math from mmcv.cnn import build_conv_layer, build_norm_layer from ..builder import BACKBONES from .detectors_resnet import Bottleneck as _Bottleneck from .detectors_resnet import DetectoRS_ResNet class Bottleneck(_Bottleneck): expansion = 4 def __init_...
3,920
30.620968
77
py
DDQ
DDQ-main/mmdet/models/backbones/resnet.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import build_conv_layer, build_norm_layer, build_plugin_layer from mmcv.runner import BaseModule from torch.nn.modules.batchnorm import _BatchNorm from ..builder import BACKBONES fro...
23,838
34.421991
79
py
DDQ
DDQ-main/mmdet/models/backbones/detectors_resnet.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import (build_conv_layer, build_norm_layer, constant_init, kaiming_init) from mmcv.runner import Sequential, load_checkpoint from torch.nn.modules.batchnorm import _BatchNorm fr...
12,736
34.980226
79
py
DDQ
DDQ-main/mmdet/models/backbones/ssd_vgg.py
# Copyright (c) OpenMMLab. All rights reserved. import warnings import torch.nn as nn from mmcv.cnn import VGG from mmcv.runner import BaseModule from ..builder import BACKBONES from ..necks import ssd_neck @BACKBONES.register_module() class SSDVGG(VGG, BaseModule): """VGG Backbone network for single-shot-detec...
4,705
35.48062
79
py
DDQ
DDQ-main/mmdet/models/backbones/resnext.py
# Copyright (c) OpenMMLab. All rights reserved. import math from 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): expansion = 4 def __init__...
5,712
35.858065
79
py
DDQ
DDQ-main/mmdet/models/backbones/resnest.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch import torch.nn as nn import torch.nn.functional as F import torch.utils.checkpoint as cp from mmcv.cnn import build_conv_layer, build_norm_layer from mmcv.runner import BaseModule from ..builder import BACKBONES from ..utils import ResLayer fro...
10,579
31.755418
79
py
DDQ
DDQ-main/mmdet/models/backbones/csp_darknet.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch import torch.nn as nn from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule from mmcv.runner import BaseModule from torch.nn.modules.batchnorm import _BatchNorm from ..builder import BACKBONES from ..utils import CSPLayer class Focus(n...
10,543
35.996491
77
py
DDQ
DDQ-main/mmdet/models/backbones/hourglass.py
# Copyright (c) OpenMMLab. All rights reserved. import torch.nn as nn import torch.nn.functional as F from mmcv.cnn import ConvModule from mmcv.runner import BaseModule from ..builder import BACKBONES from ..utils import ResLayer from .resnet import BasicBlock class HourglassModule(BaseModule): """Hourglass Modu...
7,494
32.609865
79
py
DDQ
DDQ-main/mmdet/models/backbones/res2net.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch import torch.nn as nn import torch.utils.checkpoint as cp from mmcv.cnn import build_conv_layer, build_norm_layer from mmcv.runner import Sequential from ..builder import BACKBONES from .resnet import Bottleneck as _Bottleneck from .resnet impor...
11,659
34.54878
79
py
DDQ
DDQ-main/mmdet/models/backbones/darknet.py
# Copyright (c) OpenMMLab. All rights reserved. # Copyright (c) 2019 Western Digital Corporation or its affiliates. import warnings import torch.nn as nn from mmcv.cnn import ConvModule from mmcv.runner import BaseModule from torch.nn.modules.batchnorm import _BatchNorm from ..builder import BACKBONES class ResBlo...
8,233
37.476636
79
py
DDQ
DDQ-main/mmdet/datasets/custom.py
# Copyright (c) OpenMMLab. All rights reserved. import os.path as osp import warnings from collections import OrderedDict import mmcv import numpy as np from mmcv.utils import print_log from terminaltables import AsciiTable from torch.utils.data import Dataset from mmdet.core import eval_map, eval_recalls from .build...
14,698
36.497449
79
py
DDQ
DDQ-main/mmdet/datasets/openimages.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import csv import json import os.path as osp import warnings from collections import OrderedDict, defaultdict import mmcv import numpy as np import torch.distributed as dist from mmcv.runner import get_dist_info from mmcv.utils import print_log from mmdet.co...
33,089
38.299287
79
py
DDQ
DDQ-main/mmdet/datasets/dataset_wrappers.py
# Copyright (c) OpenMMLab. All rights reserved. import bisect import collections import copy import math from collections import defaultdict import numpy as np from mmcv.utils import build_from_cfg, print_log from torch.utils.data.dataset import ConcatDataset as _ConcatDataset from .builder import DATASETS, PIPELINES...
16,284
36.872093
167
py
DDQ
DDQ-main/mmdet/datasets/builder.py
# Copyright (c) OpenMMLab. All rights reserved. import copy import platform import random import warnings from functools import partial import numpy as np from mmcv.parallel import collate from mmcv.runner import get_dist_info from mmcv.utils import TORCH_VERSION, Registry, build_from_cfg, digit_version from torch.uti...
7,707
37.54
79
py
DDQ
DDQ-main/mmdet/datasets/samplers/group_sampler.py
# Copyright (c) OpenMMLab. All rights reserved. import math import numpy as np import torch from mmcv.runner import get_dist_info from torch.utils.data import Sampler class GroupSampler(Sampler): def __init__(self, dataset, samples_per_gpu=1): assert hasattr(dataset, 'flag') self.dataset = datas...
5,384
35.14094
78
py
DDQ
DDQ-main/mmdet/datasets/samplers/infinite_sampler.py
# Copyright (c) OpenMMLab. All rights reserved. import itertools import numpy as np import torch from mmcv.runner import get_dist_info from torch.utils.data.sampler import Sampler class InfiniteGroupBatchSampler(Sampler): """Similar to `BatchSampler` warping a `GroupSampler. It is designed for iteration-base...
6,267
35.231214
110
py
DDQ
DDQ-main/mmdet/datasets/samplers/distributed_sampler.py
# Copyright (c) OpenMMLab. All rights reserved. import math import torch from torch.utils.data import DistributedSampler as _DistributedSampler class DistributedSampler(_DistributedSampler): def __init__(self, dataset, num_replicas=None, rank=None, ...
1,358
32.146341
79
py
DDQ
DDQ-main/mmdet/datasets/pipelines/formatting.py
# Copyright (c) OpenMMLab. All rights reserved. from collections.abc import Sequence import mmcv import numpy as np import torch from mmcv.parallel import DataContainer as DC from ..builder import PIPELINES def to_tensor(data): """Convert objects of various python types to :obj:`torch.Tensor`. Supported ty...
13,291
32.821883
79
py
DDQ
DDQ-main/mmdet/utils/contextmanagers.py
# Copyright (c) OpenMMLab. All rights reserved. import asyncio import contextlib import logging import os import time from typing import List import torch logger = logging.getLogger(__name__) DEBUG_COMPLETED_TIME = bool(os.environ.get('DEBUG_COMPLETED_TIME', False)) @contextlib.asynccontextmanager async def comple...
4,125
32.544715
79
py
DDQ
DDQ-main/mmdet/utils/profiling.py
# Copyright (c) OpenMMLab. All rights reserved. import contextlib import sys import time import torch if sys.version_info >= (3, 7): @contextlib.contextmanager def profile_time(trace_name, name, enabled=True, stream=None, end...
1,336
31.609756
73
py
DDQ
DDQ-main/mmdet/utils/setup_env.py
# Copyright (c) OpenMMLab. All rights reserved. import os import platform import warnings import cv2 import torch.multiprocessing as mp def setup_multi_processes(cfg): """Setup multi-processing environment variables.""" # set multi-process start method as `fork` to speed up the training if platform.syste...
2,219
45.25
112
py
wanli
wanli-main/classification/run_nli.py
""" Finetuning the library models for sequence classification on GLUE.""" """https://github.com/huggingface/transformers/blob/v4.9.0/examples/pytorch/text-classification/run_glue.py""" import logging import os import random import sys from dataclasses import dataclass, field from typing import Optional import dataset...
11,706
39.092466
119
py
wanli
wanli-main/cartography/compute_training_dynamics.py
import click from transformers import AutoModelForSequenceClassification, AutoTokenizer import os, glob import pandas as pd import torch from utils.utils import ensure_dir from tqdm import tqdm import numpy as np import json from pathlib import Path def evaluate( model_path: Path, evaluation_file: str, d...
7,214
38.642857
132
py
wanli
wanli-main/representations/embed_examples.py
""" create a npy file containing [CLS] token embeddings for a given dataset of examples """ import pandas as pd from transformers import RobertaTokenizer, RobertaForSequenceClassification from sklearn.decomposition import PCA import matplotlib.pyplot as plt import seaborn as sns from tqdm import tqdm import numpy as n...
2,667
36.577465
105
py
FakeCLR
FakeCLR-main/legacy.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
16,829
49.845921
154
py
FakeCLR
FakeCLR-main/style_mixing.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
4,891
40.109244
132
py
FakeCLR
FakeCLR-main/projector.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
8,990
41.211268
136
py
FakeCLR
FakeCLR-main/generate.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
5,338
40.069231
132
py
FakeCLR
FakeCLR-main/train.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
26,578
44.356655
192
py
FakeCLR
FakeCLR-main/calc_metrics.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
8,336
42.649215
142
py
FakeCLR
FakeCLR-main/training/contrastive_head.py
# Code are mainly borrowed from the official implementation of MoCo (https://github.com/facebookresearch/moco) import numpy as np import torch import torch.nn as nn from torch_utils import misc from torch_utils import persistence #---------------------------------------------------------------------------- # Contras...
7,231
34.45098
110
py
FakeCLR
FakeCLR-main/training/contrastive_loss.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
10,820
55.067358
194
py
FakeCLR
FakeCLR-main/training/loss.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
7,307
53.537313
160
py
FakeCLR
FakeCLR-main/training/augment.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
26,373
60.050926
366
py
FakeCLR
FakeCLR-main/training/dataset.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
8,551
35.084388
158
py
FakeCLR
FakeCLR-main/training/networks.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
37,527
49.98913
164
py
FakeCLR
FakeCLR-main/training/contrastive_head_iteration.py
# Code are mainly borrowed from the official implementation of MoCo (https://github.com/facebookresearch/moco) import numpy as np import torch import torch.nn as nn from torch_utils import misc from torch_utils import persistence import torch.nn.functional as F #--------------------------------------------------------...
7,795
34.761468
111
py
FakeCLR
FakeCLR-main/training/training_loop.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
24,651
51.118393
239
py
FakeCLR
FakeCLR-main/torch_utils/custom_ops.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
5,644
43.448819
146
py
FakeCLR
FakeCLR-main/torch_utils/training_stats.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
10,707
38.806691
118
py
FakeCLR
FakeCLR-main/torch_utils/persistence.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
9,708
37.527778
144
py
FakeCLR
FakeCLR-main/torch_utils/misc.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
11,049
40.698113
133
py
FakeCLR
FakeCLR-main/torch_utils/ops/bias_act.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
10,047
46.173709
185
py
FakeCLR
FakeCLR-main/torch_utils/ops/grid_sample_gradfix.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
3,299
38.285714
138
py
FakeCLR
FakeCLR-main/torch_utils/ops/conv2d_gradfix.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
7,677
43.900585
197
py
FakeCLR
FakeCLR-main/torch_utils/ops/upfirdn2d.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
16,287
41.306494
157
py
FakeCLR
FakeCLR-main/torch_utils/ops/conv2d_resample.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
7,591
47.356688
130
py
FakeCLR
FakeCLR-main/torch_utils/ops/fma.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and rel...
2,034
32.360656
105
py
FakeCLR
FakeCLR-main/metrics/metric_utils.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
11,806
41.778986
167
py
FakeCLR
FakeCLR-main/metrics/kernel_inception_distance.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
2,302
48
118
py
FakeCLR
FakeCLR-main/metrics/frechet_inception_distance.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
2,040
47.595238
118
py
FakeCLR
FakeCLR-main/metrics/perceptual_path_length.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
5,538
40.962121
131
py
FakeCLR
FakeCLR-main/metrics/inception_score.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
1,874
47.076923
126
py
FakeCLR
FakeCLR-main/metrics/metric_main.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
5,715
36.359477
147
py
FakeCLR
FakeCLR-main/metrics/precision_recall.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # NVIDIA CORPORATION and its licensors retain all intellectual property # and proprietary rights in and to this software, related documentation # and any modifications thereto. Any use, reproduction, disclosure or # distribution of this software and re...
3,617
56.428571
159
py
qcsbm
qcsbm-master/gaussian_example/main.py
"""Entrance file""" import run_lib from absl import app from absl import flags from ml_collections.config_flags import config_flags import tensorflow as tf import os import numpy as np import torch import random # set_deterministic def set_deterministic(config): # Pytorch torch.manual_seed(config.seed) # Numpy ...
1,296
30.634146
97
py
qcsbm
qcsbm-master/gaussian_example/run_lib.py
import logging import os import numpy as np import matplotlib.pyplot as plt from matplotlib.pyplot import figure import tensorflow as tf import torch from torch.autograd import Variable def mixture_gaussian(points, num=10, r=3, sigma=1): l = [2*np.pi*(i/num) for i in range(num)] prob = torch.zeros(points.shape[0])...
6,680
44.44898
171
py
qcsbm
qcsbm-master/gaussian_example/configs/gaussian_config.py
import ml_collections import torch def get_config(): config = ml_collections.ConfigDict() config.sampling = sampling = ml_collections.ConfigDict() sampling.width = 3 sampling.height = 3 sampling.density = 20 sampling.shape = (1000, 2) sampling.steps = 300 sampling.num_traj = 10 sampling.init_variance...
534
24.47619
94
py
qcsbm
qcsbm-master/autoencoder_example/main.py
"""Entrance file""" import run_lib from absl import app from absl import flags from ml_collections.config_flags import config_flags import tensorflow as tf import os import torch import random # set_deterministic def set_deterministic(config): # Pytorch torch.manual_seed(config.seed) # Numpy np.random.seed(con...
1,138
28.973684
92
py