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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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', avg_factor=None): """Cal...
4,340
34.008065
78
py
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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,679
36.641026
79
py
DSLA-DSLA
DSLA-DSLA/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,052
36.683099
167
py
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/mmdet/datasets/pipelines/formating.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
DSLA-DSLA
DSLA-DSLA/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
DSLA-DSLA
DSLA-DSLA/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
BS-Net
BS-Net-main/loaddata.py
import pandas as pd import numpy as np from torch.utils.data import Dataset, DataLoader from torchvision import transforms, utils from PIL import Image import random from nyu_transform import * import pdb from scipy import io class depthDataset(Dataset): """Face Landmarks dataset.""" def __init__(self, csv_fil...
6,915
42.772152
115
py
BS-Net
BS-Net-main/sobel.py
import torch import torch.nn as nn import numpy as np print(19//5) class Sobel(nn.Module): def __init__(self): super(Sobel, self).__init__() self.edge_conv=nn.Conv2d(1, 2, kernel_size=3, stride=1, padding=1, bias=False) # edge_kx = np.array([[1, 0, -1], [2, 0, -2], [1, 0, -1]]) edge_...
815
29.222222
86
py
BS-Net
BS-Net-main/test_iBims1.py
import warnings warnings.filterwarnings("ignore") import torch import numpy as np import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.optim import loaddata import sobel import os import argparse from models import modules as modules, net as net, dilation_resnet as resnet from util import comput...
11,843
41
140
py
BS-Net
BS-Net-main/util.py
import torch from PIL import Image,ImageDraw,ImageFont import matplotlib.pyplot as plt import torch.nn as nn import numpy as np from skimage import feature from scipy import ndimage from sklearn.decomposition import PCA import math cmap = plt.cm.viridis def lg10(x): return torch.div(torch.log(x), math.log(10)) de...
14,525
34.257282
120
py
BS-Net
BS-Net-main/nyu_transform.py
import torch import numpy as np from PIL import Image import collections try: import accimage except ImportError: accimage = None import random import scipy.ndimage as ndimage def _is_pil_image(img): if accimage is not None: return isinstance(img, (Image.Image, accimage.Image)) else: ...
23,434
38.058333
137
py
BS-Net
BS-Net-main/metrics.py
import torch import math import numpy as np def log10(x): """Convert a new tensor with the base-10 logarithm of the elements of x. """ return torch.log(x) / math.log(10) class Result(object): def __init__(self): self.irmse, self.imae = 0, 0 self.mse, self.rmse, self.mae = 0, 0, 0 ...
4,037
37.09434
109
py
BS-Net
BS-Net-main/train.py
# -*- coding: UTF-8 -*- import warnings warnings.filterwarnings("ignore") import argparse import time import os import torch import torch.nn as nn import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.optim import loaddata import random import numpy as np import util from models import modules as m...
6,175
35.544379
93
py
BS-Net
BS-Net-main/test_NYUDv2.py
import warnings warnings.filterwarnings("ignore") import time import torch import torch.nn.parallel import torch.backends.cudnn as cudnn import torch.optim import loaddata import numpy as np from metrics import AverageMeter, Result from models import modules as modules, net as net, dilation_resnet as resnet import torc...
6,987
35.395833
133
py
BS-Net
BS-Net-main/models/dilation_resnet.py
"""Dilated ResNet""" import math import torch import torch.utils.model_zoo as model_zoo import torch.nn as nn __all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101', 'resnet152', 'BasicBlock', 'Bottleneck'] model_urls = { 'resnet18': 'https://download.pytorch.org/models/resnet18-5c106cde....
11,689
37.837209
162
py
BS-Net
BS-Net-main/models/modules.py
import torch import torch.nn.functional as F import torch.nn as nn class _UpProjection(nn.Sequential): def __init__(self, num_input_features, num_output_features): super(_UpProjection, self).__init__() self.conv1 = nn.Conv2d(num_input_features, num_output_features, k...
10,669
38.227941
125
py
BS-Net
BS-Net-main/models/net.py
import torch.nn as nn import models.modules as modules class model(nn.Module): def __init__(self, Encoder, num_features, block_channel): super(model, self).__init__() self.E = Encoder #(2048,8,10) self.DCE = modules.DCE(num_features,num_features//2, sizes=(1, 2, 3, 6)) self.BUBF = ...
763
35.380952
80
py
correlate
correlate-master/setup.py
""" Install tigramite """ from __future__ import print_function import pathlib import os from setuptools import setup, Extension from setuptools.command.build_ext import build_ext # Handle building against numpy headers before installing numpy class UseNumpyHeadersBuildExt(build_ext): """ Subclassed build_ex...
4,316
34.677686
114
py
correlate
correlate-master/prediction/fully_connected.py
import math import numpy as np import torch import torch.utils.data as data_utils from sklearn.preprocessing import MinMaxScaler from torch import nn from torch.utils.tensorboard import SummaryWriter from config import target_label, fully_connected_nn_prediction_on writer = SummaryWriter() epochs = 4115 lr = 0.0001...
4,817
32.227586
108
py
DeepOnto
DeepOnto-main/src/deeponto/subs/bertsubs/pipeline_inter.py
# Copyright 2023 Jiaoyan Chen. All rights reserved. # 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 ag...
16,303
50.432177
152
py
DeepOnto
DeepOnto-main/src/deeponto/subs/bertsubs/pipeline_intra.py
# Copyright 2023 Jiaoyan Chen. All rights reserved. # 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 ag...
17,435
44.76378
120
py
DeepOnto
DeepOnto-main/src/deeponto/utils/logging.py
# Copyright 2021 Yuan He. All rights reserved. # 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 ...
2,609
34.27027
119
py
DeepOnto
DeepOnto-main/src/deeponto/align/bertmap/mapping_prediction.py
# Copyright 2021 Yuan He. All rights reserved. # 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 ...
15,548
49.980328
161
py
DeepOnto
DeepOnto-main/src/deeponto/align/bertmap/bert_classifier.py
# Copyright 2021 Yuan He. All rights reserved. # 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 ...
10,098
44.084821
150
py
ACE
ACE-main/example.py
import torch import torch.nn.functional as F import timm from PIL import Image from timm.data import resolve_data_config from timm.data.transforms_factory import create_transform from ace import attack_confidence_estimation def attack_example(file_name, true_label, transform, normalization): image = Image.open(f'....
1,864
57.28125
149
py
ACE
ACE-main/ace.py
import torch def softmax_response(logits): return torch.nn.functional.softmax(logits, dim=1) def attack_confidence_estimation(model, input, label, normalization, proxy=None, epsilon=0.005, epsilon_decay=0.5, max_iterations=15, confidence_score_function=softmax_response, device='cuda'): input = input.to(devic...
2,151
42.04
193
py
Fengshenbang-LM
Fengshenbang-LM-main/setup.py
from setuptools import setup, find_packages setup( name="fengshen", version="0.0.1", description="fengshen", long_description="fengshen", license="MIT Licence", url="https://idea.edu.cn", author="gaoxinyu", author_email="gaoxinyu@idea.edu.cn", packages=find_packages(), include_...
733
21.9375
69
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/strategies/megatron_deepspeed.py
# Copyright The Lightning AI team. # # 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 wri...
18,750
45.8775
120
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/pretrain_t5/pretrain_t5.py
import time from builtins import print import sys import os import torch import argparse import json import pytorch_lightning as pl from transformers import MT5Config, MT5Tokenizer from pytorch_lightning import Trainer, loggers from transformers import MT5ForConditionalGeneration from pytorch_lightning.callbacks import...
8,139
45.25
110
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/pretrain_t5/convert_ckpt_to_bin.py
import time from builtins import print import argparse import torch # os.environ["CUDA_VISIBLE_DEVICES"] = '3' def get_time_str(): return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) def main(): total_parser = argparse.ArgumentParser("Pretrain Unsupervise.") total_parser.add_argument('--ckpt_pa...
1,071
27.210526
68
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/pretrain_t5/finetune_t5.py
import time from builtins import print import sys import os import torch import argparse import pytorch_lightning as pl from pytorch_lightning import Trainer, loggers from transformers import MT5ForConditionalGeneration from pytorch_lightning.callbacks import LearningRateMonitor # os.environ["CUDA_VISIBLE_DEVICES"] = '...
6,184
41.655172
110
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/stable_diffusion_dreambooth/train.py
# -*- encoding: utf-8 -*- ''' Copyright 2022 The International Digital Economy Academy (IDEA). CCNL team. All rights reserved. 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.o...
11,678
41.162455
118
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/zen2_finetune/fengshen_token_level_ft_task.py
# coding=utf-8 # Copyright 2021 The IDEA Authors. All rights reserved. # 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 a...
28,463
40.920471
163
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/zen2_finetune/fengshen_sequence_level_ft_task.py
# coding=utf-8 # Copyright 2021 The IDEA Authors. All rights reserved. # 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 a...
27,189
40.830769
130
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/classification/finetune_classification.py
# coding=utf-8 # Copyright 2021 The IDEA Authors. All rights reserved. # 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 a...
15,787
39.482051
117
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/DAVAE/generate.py
# -*- encoding: utf-8 -*- ''' Copyright 2022 The International Digital Economy Academy (IDEA). CCNL team. All rights reserved. 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.o...
1,595
42.135135
157
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/disco_project/disco.py
import os import sys # sys.path.insert(0, f'{PROJECT_DIR}/guided-diffusion') # 加在前面,不再读取库文件的东西。 import subprocess import io import torch.nn as nn from torch.nn import functional as F import torch import torchvision.transforms.functional as TF import torchvision.transforms as T import math import requests import cv2 f...
29,225
38.709239
150
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/disco_project/guided_diffusion/guided_diffusion/resample.py
from abc import ABC, abstractmethod import numpy as np import torch as th import torch.distributed as dist def create_named_schedule_sampler(name, diffusion): """ Create a ScheduleSampler from a library of pre-defined samplers. :param name: the name of the sampler. :param diffusion: the diffusion ob...
5,689
35.709677
87
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/disco_project/guided_diffusion/guided_diffusion/losses.py
""" Helpers for various likelihood-based losses. These are ported from the original Ho et al. diffusion models codebase: https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/utils.py """ import numpy as np import torch as th def normal_kl(mean1, logvar1, mean2, logvar...
2,502
32.824324
109
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/disco_project/guided_diffusion/guided_diffusion/nn.py
""" Various utilities for neural networks. """ import math import torch as th import torch.nn as nn # PyTorch 1.7 has SiLU, but we support PyTorch 1.5. class SiLU(nn.Module): def forward(self, x): return x * th.sigmoid(x) class GroupNorm32(nn.GroupNorm): def forward(self, x): return super(...
5,835
29.554974
99
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/disco_project/guided_diffusion/guided_diffusion/fp16_util.py
""" Helpers to train with 16-bit precision. """ import numpy as np import torch as th import torch.nn as nn from torch._utils import _flatten_dense_tensors, _unflatten_dense_tensors from . import logger INITIAL_LOG_LOSS_SCALE = 20.0 def convert_module_to_f16(ll): """ Convert primitive modules to float16. ...
7,955
32.56962
114
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/disco_project/guided_diffusion/guided_diffusion/unet.py
from abc import abstractmethod import math import numpy as np import torch as th import torch.nn as nn import torch.nn.functional as F from .fp16_util import convert_module_to_f16, convert_module_to_f32 from .nn import ( checkpoint, conv_nd, linear, avg_pool_nd, zero_module, normalization, ...
34,109
33.94877
124
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/disco_project/guided_diffusion/guided_diffusion/gaussian_diffusion.py
""" This code started out as a PyTorch port of Ho et al's diffusion models: https://github.com/hojonathanho/diffusion/blob/1e0dceb3b3495bbe19116a5e1b3596cd0706c543/diffusion_tf/diffusion_utils_2.py Docstrings have been added, as well as DDIM sampling and a new collection of beta schedules. """ import enum import math...
50,680
37.482156
185
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/disco_project/guided_diffusion/guided_diffusion/respace.py
import numpy as np import torch as th from .gaussian_diffusion import GaussianDiffusion def space_timesteps(num_timesteps, section_counts): """ Create a list of timesteps to use from an original diffusion process, given the number of timesteps we want to take from equally-sized portions of the origin...
5,192
39.255814
85
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/pretrain_erlangshen_deberta_v2/pretrain_deberta.py
from dataclasses import dataclass from transformers import ( DebertaV2Config, DebertaV2ForMaskedLM, AutoTokenizer, ) from pytorch_lightning import ( LightningModule, Trainer, ) from pytorch_lightning.callbacks import ( LearningRateMonitor, ) import argparse import torch import os import numpy as...
8,886
37.97807
119
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/tcbert/example.py
import argparse from fengshen.pipelines.tcbert import TCBertPipelines from pytorch_lightning import seed_everything def main(): seed_everything(123) total_parser = argparse.ArgumentParser("Topic Classification") total_parser = TCBertPipelines.piplines_args(total_parser) args = total_parser.parse_args()...
3,693
41.45977
94
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/ziya_inference/hf_quantizatin_inference.py
""" 这是基于hugging face社区开源的框架accelerate制定的基础量化推理方案 该框架主要实现了int8、int4量化,以及cpu或者disk offload 实现了用低存储,小设备运行大模型 具体可以见wiki:http://wiki.team.idea.edu.cn/pages/viewpage.action?pageId=31464125 """ import time from transformers import AutoModelForCausalLM, AutoTokenizer import bitsandbytes as bnb from bitsandbytes.nn import Linea...
2,638
35.652778
114
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/qa_t5/finetune_t5_cmrc.py
# -*- encoding: utf-8 -*- ''' Copyright 2022 The International Digital Economy Academy (IDEA). CCNL team. All rights reserved. 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.o...
17,183
37.101996
100
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/qa_t5/qa_dataset.py
# -*- encoding: utf-8 -*- ''' Copyright 2022 The International Digital Economy Academy (IDEA). CCNL team. All rights reserved. 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.o...
6,086
31.37766
96
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/hubert/pretrain_hubert.py
import fengshen.data.hubert.hubert_dataset as datasets from fengshen.data.universal_datamodule import UniversalDataModule from transformers import HubertConfig, HubertModel # from transformers.models.hubert.modeling_hubert import _compute_mask_indices import argparse from fairseq.data import Dictionary from pytorch_lig...
11,643
39.430556
109
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/pretrain_erlangshen_bert/pretrain_erlangshen.py
from dataclasses import dataclass from transformers import ( MegatronBertConfig, MegatronBertForPreTraining, AutoTokenizer, ) from pytorch_lightning import ( LightningModule, Trainer, ) from pytorch_lightning.callbacks import ( LearningRateMonitor, ) import argparse import torch import os import...
9,575
39.235294
120
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/wenzhong_qa/finetune_medicalQA.py
from transformers import GPT2LMHeadModel from data.task_dataloader.medicalQADataset import GPT2QADataModel from transformers.optimization import get_linear_schedule_with_warmup from pytorch_lightning import Trainer, loggers from pytorch_lightning.callbacks import ModelCheckpoint import pytorch_lightning as pl import ar...
7,423
40.943503
110
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/wenzhong_qa/finetune_wenzhong.py
# sys.path.append('./') import os import torch import argparse import pytorch_lightning as pl from pytorch_lightning.callbacks import ModelCheckpoint from pytorch_lightning import Trainer, loggers from transformers.optimization import get_linear_schedule_with_warmup from transformers import GPT2LMHeadModel from fengshe...
6,611
41.935065
114
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/finetune_bart_qg/utils.py
# -*- encoding: utf-8 -*- ''' Copyright 2022 The International Digital Economy Academy (IDEA). CCNL team. All rights reserved. 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.o...
2,208
30.112676
96
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/finetune_bart_qg/finetune_bart.py
# -*- encoding: utf-8 -*- ''' Copyright 2022 The International Digital Economy Academy (IDEA). CCNL team. All rights reserved. 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.o...
17,301
39.237209
141
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/zen1_finetune/fengshen_token_level_ft_task.py
# coding=utf-8 # Copyright 2021 The IDEA Authors. All rights reserved. # 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 a...
26,317
39.614198
163
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/zen1_finetune/fengshen_sequence_level_ft_task.py
# coding=utf-8 # Copyright 2021 The IDEA Authors. All rights reserved. # 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 a...
24,857
39.684124
130
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/pretrain_taiyi_clip/pretrain.py
from pytorch_lightning import ( LightningModule, Trainer, ) from pytorch_lightning.callbacks import ( LearningRateMonitor, ) from fengshen.models.clip import ( TaiyiCLIPModel, TaiyiCLIPProcessor, ) from fengshen.models.model_utils import ( add_module_args, configure_optimizers, get_total...
12,711
40.139159
113
py
Fengshenbang-LM
Fengshenbang-LM-main/fengshen/examples/pretrain_taiyi_clip/test.py
from pytorch_lightning import ( Trainer, ) from fengshen.models.model_utils import ( add_module_args, ) import argparse from fengshen.data.universal_datamodule import UniversalDataModule from fengshen.utils.universal_checkpoint import UniversalCheckpoint from fengshen.examples.pretrain_taiyi_clip.pretrain impor...
1,404
36.972973
97
py