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
muisc
muisc-main/transformers/tests/test_modeling_auto.py
# coding=utf-8 # Copyright 2020 The HuggingFace 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.org/licenses/LICENSE-2.0 # # Unless requir...
12,065
42.876364
119
py
muisc
muisc-main/transformers/tests/test_modeling_funnel.py
# coding=utf-8 # Copyright 2020 HuggingFace Inc. 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...
19,285
36.741683
119
py
muisc
muisc-main/transformers/tests/test_modeling_pegasus.py
# coding=utf-8 # Copyright 2021, The HuggingFace Inc. 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.org/licenses/LICENSE-2.0 # # Unless ...
23,326
42.683521
1,802
py
muisc
muisc-main/transformers/tests/test_tokenization_fsmt.py
# coding=utf-8 # Copyright 2020 The HuggingFace 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.org/licenses/LICENSE-2.0 # # Unless requir...
6,444
37.136095
141
py
muisc
muisc-main/transformers/tests/test_modeling_albert.py
# coding=utf-8 # Copyright 2020 The HuggingFace 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.org/licenses/LICENSE-2.0 # # Unless requir...
12,943
40.620579
119
py
muisc
muisc-main/transformers/tests/deepspeed/test_deepspeed.py
# Copyright 2020 The HuggingFace 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.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
38,102
39.92696
126
py
muisc
muisc-main/transformers/tests/deepspeed/test_model_zoo.py
# Copyright 2020 The HuggingFace 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.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
7,943
29.553846
113
py
muisc
muisc-main/transformers/tests/sagemaker/conftest.py
# we define a fixture function below and it will be "used" by # referencing its name from tests import os import pytest from attr import dataclass os.environ["AWS_DEFAULT_REGION"] = "us-east-1" # defaults region @dataclass class SageMakerTestEnvironment: framework: str role = "arn:aws:iam::558105141721:...
2,183
32.090909
148
py
muisc
muisc-main/transformers/tests/sagemaker/test_single_node_gpu.py
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface import HuggingFac...
3,554
35.649485
117
py
muisc
muisc-main/transformers/tests/sagemaker/test_multi_node_data_parallel.py
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface im...
4,260
37.387387
118
py
muisc
muisc-main/transformers/tests/sagemaker/test_multi_node_model_parallel.py
import json import os import subprocess import unittest from ast import literal_eval import pytest from parameterized import parameterized, parameterized_class from . import is_sagemaker_available if is_sagemaker_available(): from sagemaker import Session, TrainingJobAnalytics from sagemaker.huggingface im...
4,521
35.176
117
py
muisc
muisc-main/transformers/tests/sagemaker/scripts/pytorch/run_ddp.py
import json import logging import os import subprocess from argparse import ArgumentParser logger = logging.getLogger(__name__) def parse_args(): parser = ArgumentParser() parsed, unknown = parser.parse_known_args() for arg in unknown: if arg.startswith(("-", "--")): parser.add_argum...
1,468
26.716981
102
py
muisc
muisc-main/transformers/tests/sagemaker/scripts/tensorflow/run_tf.py
import argparse import logging import sys import time import tensorflow as tf from datasets import load_dataset from transformers import AutoTokenizer, TFAutoModelForSequenceClassification if __name__ == "__main__": parser = argparse.ArgumentParser() # Hyperparameters sent by the client are passed as comm...
3,690
39.119565
112
py
muisc
muisc-main/transformers/tests/sagemaker/scripts/tensorflow/run_tf_dist.py
import argparse import logging import os import sys import time import tensorflow as tf from datasets import load_dataset from tqdm import tqdm from transformers import AutoTokenizer, TFAutoModelForSequenceClassification from transformers.file_utils import is_sagemaker_dp_enabled if os.environ.get("SDP_ENABLED") or...
7,331
36.6
110
py
muisc
muisc-main/transformers/tests/extended/test_trainer_ext.py
# Copyright 2020 The HuggingFace 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.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
11,054
34.892857
119
py
muisc
muisc-main/transformers/utils/tests_fetcher.py
# coding=utf-8 # Copyright 2021 The HuggingFace Inc. 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...
17,434
39.358796
118
py
muisc
muisc-main/transformers/utils/check_copies.py
# coding=utf-8 # Copyright 2020 The HuggingFace Inc. 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...
13,736
37.695775
119
py
muisc
muisc-main/transformers/utils/notification_service.py
# Copyright 2020 The HuggingFace 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.org/licenses/LICENSE-2.0 # # Unless required by applicabl...
7,977
39.090452
127
py
muisc
muisc-main/transformers/utils/check_repo.py
# coding=utf-8 # Copyright 2020 The HuggingFace Inc. 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...
23,065
39.824779
141
py
muisc
muisc-main/transformers/utils/check_dummies.py
# coding=utf-8 # Copyright 2020 The HuggingFace Inc. 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...
6,848
33.943878
118
py
muisc
muisc-main/transformers/utils/check_table.py
# coding=utf-8 # Copyright 2020 The HuggingFace Inc. 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...
7,578
39.747312
116
py
voicefixer
voicefixer-main/setup.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- # python3 setup.py sdist bdist_wheel """ @File : setup.py.py @Contact : haoheliu@gmail.com @License : (C)Copyright 2020-2100 @Modify Time @Author @Version @Desciption ------------ ------- -------- ----------- 9/6/21 5:16 PM Haohe Liu ...
4,334
27.708609
86
py
voicefixer
voicefixer-main/test/test.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- """ @File : test.py @Contact : haoheliu@gmail.com @License : (C)Copyright 2020-2100 @Modify Time @Author @Version @Desciption ------------ ------- -------- ----------- 9/14/21 11:02 AM Haohe Liu 1.0 None """ import git impor...
3,219
29.666667
88
py
voicefixer
voicefixer-main/test/streamlit.py
import os import argparse import time import librosa import soundfile import streamlit as st import torch from io import BytesIO from voicefixer import VoiceFixer @st.experimental_singleton def init_voicefixer(): return VoiceFixer() # init with global shared singleton instance voice_fixer = init_voicefixer() ...
1,581
21.927536
140
py
voicefixer
voicefixer-main/voicefixer/base.py
import librosa.display from voicefixer.tools.pytorch_util import * from voicefixer.tools.wav import * from voicefixer.restorer.model import VoiceFixer as voicefixer_fe import os EPS = 1e-8 class VoiceFixer(nn.Module): def __init__(self): super(VoiceFixer, self).__init__() self._model = voicefixer...
6,280
42.317241
166
py
voicefixer
voicefixer-main/voicefixer/__main__.py
#!/usr/bin/python3 from genericpath import exists import os.path import argparse from voicefixer import VoiceFixer import torch import os def writefile(infile, outfile, mode, append_mode, cuda, verbose=False): if append_mode is True: outbasename, outext = os.path.splitext(os.path.basename(outfile)) ...
5,899
33.502924
180
py
voicefixer
voicefixer-main/voicefixer/tools/pytorch_util.py
import torch import torch.nn as nn import numpy as np def check_cuda_availability(cuda): if cuda and not torch.cuda.is_available(): raise RuntimeError("Error: You set cuda=True but no cuda device found.") def try_tensor_cuda(tensor, cuda): if cuda and torch.cuda.is_available(): return tensor...
5,357
28.60221
84
py
voicefixer
voicefixer-main/voicefixer/tools/base.py
import math import numpy as np import torch import os import torch.fft os.environ["KMP_DUPLICATE_LIB_OK"] = "True" def get_window(window_size, window_type, square_root_window=True): """Return the window""" window = { "hamming": torch.hamming_window(window_size), "hanning": torch.hann_window(...
7,591
29.987755
105
py
voicefixer
voicefixer-main/voicefixer/tools/random_.py
import random import torch RANDOM_RESOLUTION = 2**31 def random_torch(high, to_int=True): if to_int: return int((torch.rand(1)) * high) # do not use numpy.random.random else: return (torch.rand(1)) * high # do not use numpy.random.random def shuffle_torch(list): length = len(list) ...
1,225
22.132075
76
py
voicefixer
voicefixer-main/voicefixer/tools/mel_scale.py
import torch from torch import Tensor from typing import Optional import math import warnings class MelScale(torch.nn.Module): r"""Turn a normal STFT into a mel frequency STFT, using a conversion matrix. This uses triangular filter banks. User can control which device the filter bank (`fb`) is (e.g. fb...
7,799
31.635983
113
py
voicefixer
voicefixer-main/voicefixer/tools/modules/pqmf.py
""" @File : subband_util.py @Contact : liu.8948@buckeyemail.osu.edu @License : (C)Copyright 2020-2021 @Modify Time @Author @Version @Desciption ------------ ------- -------- ----------- 2020/4/3 4:54 PM Haohe Liu 1.0 None """ import torch import torch.nn.functional as F im...
3,962
32.871795
82
py
voicefixer
voicefixer-main/voicefixer/tools/modules/fDomainHelper.py
from torchlibrosa.stft import STFT, ISTFT, magphase import torch import torch.nn as nn import numpy as np from voicefixer.tools.modules.pqmf import PQMF class FDomainHelper(nn.Module): def __init__( self, window_size=2048, hop_size=441, center=True, pad_mode="reflect", ...
8,508
35.208511
202
py
voicefixer
voicefixer-main/voicefixer/vocoder/base.py
from voicefixer.vocoder.model.generator import Generator from voicefixer.tools.wav import read_wave, save_wave from voicefixer.tools.pytorch_util import * from voicefixer.vocoder.model.util import * from voicefixer.vocoder.config import Config import os import numpy as np class Vocoder(nn.Module): def __init__(se...
3,713
41.689655
186
py
voicefixer
voicefixer-main/voicefixer/vocoder/config.py
import torch import numpy as np import os from voicefixer.tools.path import root_path class Config: @classmethod def refresh(cls, sr): if sr == 44100: Config.ckpt = os.path.join( os.path.expanduser("~"), ".cache/voicefixer/synthesis_module/44100/model.ckpt-1...
7,953
24.091483
88
py
voicefixer
voicefixer-main/voicefixer/vocoder/model/pqmf.py
import os import sys import torch import torch.nn as nn import numpy as np import scipy.io.wavfile class PQMF(nn.Module): def __init__(self, N, M, file_path="utils/pqmf_hk_4_64.dat"): super().__init__() self.N = N # nsubband self.M = M # nfilter self.ana_conv_filter = nn.Conv1d( ...
2,146
33.629032
99
py
voicefixer
voicefixer-main/voicefixer/vocoder/model/modules.py
import math import numpy as np import torch import torch.nn as nn import torch.nn.functional as F from voicefixer.vocoder.config import Config # From xin wang of nii class SineGen(torch.nn.Module): """Definition of sine generator SineGen(samp_rate, harmonic_num = 0, sine_amp = 0.1, noise_std = 0.00...
32,158
32.922996
92
py
voicefixer
voicefixer-main/voicefixer/vocoder/model/res_msd.py
import torch import torch.nn.functional as F import torch.nn as nn from torch.nn import Conv1d, ConvTranspose1d, AvgPool1d, Conv2d from torch.nn.utils import weight_norm, remove_weight_norm, spectral_norm LRELU_SLOPE = 0.1 def init_weights(m, mean=0.0, std=0.01): classname = m.__class__.__name__ if classname...
2,128
28.569444
79
py
voicefixer
voicefixer-main/voicefixer/vocoder/model/util.py
from voicefixer.vocoder.config import Config from voicefixer.tools.pytorch_util import try_tensor_cuda, check_cuda_availability import torch import librosa import numpy as np def tr_normalize(S): if Config.allow_clipping_in_normalization: if Config.symmetric_mels: return torch.clip( ...
4,034
28.669118
85
py
voicefixer
voicefixer-main/voicefixer/vocoder/model/generator.py
import torch import torch.nn as nn import numpy as np from voicefixer.vocoder.model.modules import UpsampleNet, ResStack from voicefixer.vocoder.config import Config from voicefixer.vocoder.model.pqmf import PQMF import os os.environ["KMP_DUPLICATE_LIB_OK"] = "True" class Generator(nn.Module): def __init__( ...
6,076
34.95858
87
py
voicefixer
voicefixer-main/voicefixer/restorer/modules.py
import torch.nn as nn import torch import torch.nn.functional as F import math class ConvBlockRes(nn.Module): def __init__(self, in_channels, out_channels, size, activation, momentum): super(ConvBlockRes, self).__init__() self.activation = activation if type(size) == type((3, 4)): ...
6,535
28.981651
103
py
voicefixer
voicefixer-main/voicefixer/restorer/model.py
# import pytorch_lightning as pl import torch.utils from voicefixer.tools.mel_scale import MelScale import torch.utils.data import matplotlib.pyplot as plt import librosa.display from voicefixer.vocoder.base import Vocoder from voicefixer.tools.pytorch_util import * from voicefixer.restorer.model_kqq_bn import UNetRes...
22,571
32.145374
99
py
voicefixer
voicefixer-main/voicefixer/restorer/__init__.py
#!/usr/bin/env python # -*- encoding: utf-8 -*- """ @File : __init__.py.py @Contact : haoheliu@gmail.com @License : (C)Copyright 2020-2100 @Modify Time @Author @Version @Desciption ------------ ------- -------- ----------- 9/14/21 12:31 AM Haohe Liu 1.0 None """ impor...
1,409
30.333333
132
py
voicefixer
voicefixer-main/voicefixer/restorer/model_kqq_bn.py
from voicefixer.restorer.modules import * from voicefixer.tools.pytorch_util import * class UNetResComplex_100Mb(nn.Module): def __init__(self, channels, nsrc=1): super(UNetResComplex_100Mb, self).__init__() activation = "relu" momentum = 0.01 self.nsrc = nsrc self.channe...
5,881
30.454545
88
py
dcdi
dcdi-master/main.py
# coding=utf-8 """ GraN-DAG Copyright © 2019 Sébastien Lachapelle, Philippe Brouillard, Tristan Deleu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limita...
8,288
54.630872
119
py
dcdi
dcdi-master/gies/gies.py
"""GIES algorithm. .. MIT License .. .. Copyright (c) 2018 Diviyan Kalainathan .. .. Permission is hereby granted, free of charge, to any person obtaining a copy .. of this software and associated documentation files (the "Software"), to deal .. in the Software without restriction, including without limitation the rig...
10,676
37.545126
229
py
dcdi
dcdi-master/jci/pc.py
""" Modified from: .. MIT License .. .. Copyright (c) 2018 Diviyan Kalainathan .. .. Permission is hereby granted, free of charge, to any person obtaining a copy .. of this software and associated documentation files (the "Software"), to deal .. in the Software without restriction, including without limitation the righ...
4,455
37.747826
169
py
dcdi
dcdi-master/dcdi/main.py
# coding=utf-8 """ GraN-DAG Copyright © 2019 Sébastien Lachapelle, Philippe Brouillard, Tristan Deleu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limita...
9,590
49.21466
119
py
dcdi
dcdi-master/dcdi/torchkit.py
""" Copyright Chin-Wei Huang """ import numpy as np import torch from torch.autograd import Variable from torch import nn from torch.nn import functional as F delta = 1e-6 c = - 0.5 * np.log(2 * np.pi) def log(x): return torch.log(x * 1e2) - np.log(1e2) def log_normal(x, mean, log_var, eps=0.00001): retur...
3,495
24.151079
91
py
dcdi
dcdi-master/dcdi/data.py
""" GraN-DAG Copyright © 2019 Sébastien Lachapelle, Philippe Brouillard, Tristan Deleu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights...
9,536
42.747706
118
py
dcdi
dcdi-master/dcdi/dag_optim.py
""" GraN-DAG Copyright © 2019 Sébastien Lachapelle, Philippe Brouillard, Tristan Deleu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights...
5,015
37.290076
118
py
dcdi
dcdi-master/dcdi/plot.py
# coding=utf-8 """ GraN-DAG Copyright © 2019 Sébastien Lachapelle, Philippe Brouillard, Tristan Deleu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limita...
14,509
40.457143
139
py
dcdi
dcdi-master/dcdi/train.py
""" GraN-DAG Copyright © 2019 Sébastien Lachapelle, Philippe Brouillard, Tristan Deleu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights...
28,724
46.715947
146
py
dcdi
dcdi-master/dcdi/prox.py
import math import torch def monkey_patch_RMSprop(RMSProp_class): def step(self, closure=None): """Performs a single optimization step. Arguments: closure (callable, optional): A closure that reevaluates the model and returns the loss. """ loss = None ...
2,283
35.253968
94
py
dcdi
dcdi-master/dcdi/models/base_model.py
""" GraN-DAG Copyright © 2019 Sébastien Lachapelle, Philippe Brouillard, Tristan Deleu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights...
12,935
43.30137
125
py
dcdi
dcdi-master/dcdi/models/learnables.py
""" GraN-DAG Copyright © 2019 Sébastien Lachapelle, Philippe Brouillard, Tristan Deleu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights...
5,233
46.581818
119
py
dcdi
dcdi-master/dcdi/models/flows.py
import torch from torch.autograd import Variable from ..torchkit import log_normal, SigmoidFlow from .base_model import BaseModel class FlowModel(BaseModel): """ Abstract class for normalizing flow model """ def __init__(self, num_vars, num_layers, hid_dim, num_params, nonlin="leaky-relu", ...
7,309
52.357664
120
py
dcdi
dcdi-master/dcdi/utils/penalty.py
import torch def compute_penalty(list_, p=2, target=0.): penalty = 0 for m in list_: penalty += torch.norm(m - target, p=p) ** p return penalty
165
19.75
51
py
dcdi
dcdi-master/dcdi/utils/gumbel.py
import torch def sample_logistic(shape, uniform): u = uniform.sample(shape) return torch.log(u) - torch.log(1 - u) def gumbel_sigmoid(log_alpha, uniform, bs, tau=1, hard=False): shape = tuple([bs] + list(log_alpha.size())) logistic_noise = sample_logistic(shape, uniform) y_soft = torch.sigmoid((l...
675
26.04
63
py
dcdi
dcdi-master/cam/cam.py
"""CAM algorithm. Imported from the Pcalg package. Adapted from: Author: Diviyan Kalainathan .. MIT License .. .. Copyright (c) 2018 Diviyan Kalainathan .. .. Permission is hereby granted, free of charge, to any person obtaining a copy .. of this software and associated documentation files (the "Software"), to deal ....
10,249
38.883268
156
py
dcdi
dcdi-master/data/generation/causal_mechanisms.py
"""Defining a set of classes that represent causal functions/ mechanisms. Author: Diviyan Kalainathan Modified by Philippe Brouillard, July 24th 2019 .. MIT License .. .. Copyright (c) 2018 Diviyan Kalainathan .. .. Permission is hereby granted, free of charge, to any person obtaining a copy .. of this software and a...
32,235
32.790356
98
py
WSPLIN
WSPLIN-main/main.py
import os from collections import OrderedDict os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import time import argparse import datetime import numpy as np from copy import deepcopy import random import torch import torch.backends.cudnn as cudnn from torch.nn.parallel import DistributedDataParallel as NativeDDP import torc...
24,756
46.701349
236
py
WSPLIN
WSPLIN-main/lr_scheduler.py
import torch from torch.optim.lr_scheduler import MultiStepLR from timm.scheduler.cosine_lr import CosineLRScheduler from timm.scheduler.step_lr import StepLRScheduler from timm.scheduler.scheduler import Scheduler import math from typing import Dict, Any def build_scheduler(config, optimizer, n_iter_per_epoch): n...
6,167
38.793548
180
py
WSPLIN
WSPLIN-main/utils.py
from collections import OrderedDict import csv import os from cv2 import norm from sklearn import metrics import torch import torch.distributed as dist import shutil from copy import deepcopy import math import torch.nn.functional as F import torch.nn as nn from timm.utils.clip_grad import dispatch_clip_grad from torch...
25,558
43.527875
187
py
WSPLIN
WSPLIN-main/config.py
import os from timm.data.constants import IMAGENET_DEFAULT_MEAN, IMAGENET_DEFAULT_STD import yaml from yacs.config import CfgNode as CN _C = CN() # Base config files _C.BASE = [''] # ----------------------------------------------------------------------------- # Data settings # --------------------------------------...
13,497
32.493797
187
py
WSPLIN
WSPLIN-main/criterion.py
import torch import torch.nn.functional as F import torch.nn as nn import torch.distributed as dist from timm.loss import LabelSmoothingCrossEntropy, SoftTargetCrossEntropy import numpy as np def _build_criterion(name,config): if name == 'crossentropy': if config.AUG.MIXUP > 0.: # smoothing is ...
5,862
40.58156
235
py
WSPLIN
WSPLIN-main/models/build_models.py
import torch import torch.nn as nn from timm.models import create_model from .wsplin import * from .stn import * from .dino import * from .simsiam import * from .ioplin import * from .utils import LinearProbWrapper # from ._vit import * ONE_BACKBONE_GROUP = ('wsplin','stn','ioplin','simsiam','pict','clmim') TWO_BACKB...
4,089
37.584906
109
py
WSPLIN
WSPLIN-main/models/wsplin.py
import math import os import torch import torch.nn as nn from timm.models.registry import register_model from timm.models.layers import trunc_normal_ class ClassifierNetwork(nn.Module): def __init__(self, num_classes,patches,dp_rate=0.5): super().__init__() self.cls_head = nn.Sequential( ...
2,760
33.08642
168
py
WSPLIN
WSPLIN-main/models/stn.py
import torch import torch.nn as nn import torch.nn.functional as F from timm.models import create_model from timm.models.registry import register_model from timm.models.layers import trunc_normal_ class STN(nn.Module): def __init__(self, backbone,type=1): super().__init__() self.backbone = backbon...
5,834
32.342857
97
py
WSPLIN
WSPLIN-main/models/simsiam.py
import torch import torch.nn as nn import torch.nn.functional as F from timm.models.layers import trunc_normal_ from timm.models.registry import register_model import os from .utils import get_num_features # copyright simsiam@facebook. ref: https://arxiv.org/abs/2011.10566 # Comple from: https://github.com/PatrickHua...
4,828
32.303448
109
py
WSPLIN
WSPLIN-main/models/utils.py
import torch import torch.nn as nn from torch.utils.checkpoint import checkpoint from itertools import chain import numpy as np from timm.models.layers import trunc_normal_ from torch.nn import Parameter import random def patchify(imgs,patch_size): """ imgs: (N, 3, H, W) x: (N, L, patch_size**...
16,834
37.174603
140
py
WSPLIN
WSPLIN-main/models/dino.py
import os import sys import torch import torch.nn as nn import torch.nn.functional as F from timm.models.layers import trunc_normal_ from timm.models.registry import register_model from .utils import MultiCropWrapper sys.path.append(os.path.dirname(__file__) + os.sep + '../') from utils import ModelEmaV3,cosine_schedu...
3,565
36.145833
124
py
WSPLIN
WSPLIN-main/models/ioplin.py
import torch import torch.nn as nn import torch.nn.functional as F from timm.models.registry import register_model from timm.models.layers import trunc_normal_ import os class IOPLIN(nn.Module): def __init__(self, backbone): super().__init__() self.backbone = backbone def forward_features(se...
1,862
30.576271
114
py
WSPLIN
WSPLIN-main/engine/base.py
from contextlib import suppress from copy import deepcopy import time from cv2 import reduce import numpy as np from numpy import ndarray import datetime from collections import OrderedDict try: import wandb has_wandb = True except ImportError: has_wandb = False import sys,os sys.path.append(os.path.dir...
16,504
43.013333
196
py
WSPLIN
WSPLIN-main/engine/wsplin.py
import numpy as np from collections import OrderedDict from sklearn.metrics import roc_auc_score,precision_recall_curve,f1_score import math import torch import random as native_random from timm.utils import * from .iNet_cls import INetClsEngine import sys sys.path.append("..") from utils import getDataByStick class ...
7,067
36.2
179
py
WSPLIN
WSPLIN-main/engine/iNet_cls.py
from ast import Or import numpy as np from collections import OrderedDict from sklearn.metrics import roc_auc_score,precision_recall_curve,f1_score import torch from timm.utils import * import sys sys.path.append("..") from utils import getDataByStick class INetClsEngine: def __init__(self,config,**kwargs): ...
5,013
32.651007
131
py
WSPLIN
WSPLIN-main/engine/dino.py
import numpy as np import sys,os from collections import OrderedDict from timm.utils import * import torch import torch.nn as nn from .iNet_cls import INetClsEngine sys.path.append(os.path.dirname(__file__) + os.sep + '../') from utils import cosine_scheduler class DINOEngine(INetClsEngine): def __init__(self,c...
3,108
38.35443
136
py
WSPLIN
WSPLIN-main/engine/ioplin.py
import numpy as np from collections import OrderedDict from sklearn.metrics import roc_auc_score,precision_recall_curve,f1_score import torch import torch.nn as nn from timm.utils import * from .iNet_cls import INetClsEngine import sys sys.path.append("..") from utils import getDataByStick class PIC: thr=0.5 #阈值...
13,111
37.005797
150
py
WSPLIN
WSPLIN-main/optimizer/optimizer.py
#from torch import optim as optim from timm.optim import create_optimizer_v2 from .ranger import RangerLars import torch.nn as nn def build_optimizer(config, model): """ Use the timm optimizer """ param,weight_decay = get_param(config,model) if config.TRAIN.OPTIMIZER.NAME.lower() == 'rangerlars': ...
2,832
34.860759
171
py
WSPLIN
WSPLIN-main/optimizer/ranger/over9000.py
import torch, math from torch.optim.optimizer import Optimizer import itertools as it from .lookahead import * from .ralamb import * # RAdam + LARS + LookAHead # Lookahead implementation from https://github.com/lonePatient/lookahead_pytorch/blob/master/optimizer.py # RAdam + LARS implementation from https://gist.git...
539
32.75
105
py
WSPLIN
WSPLIN-main/optimizer/ranger/radam.py
# from https://github.com/LiyuanLucasLiu/RAdam/blob/master/radam.py import math import torch from torch.optim.optimizer import Optimizer, required class RAdam(Optimizer): def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, weight_decay=0): defaults = dict(lr=lr, betas=betas, eps=eps, weight...
8,099
37.755981
185
py
WSPLIN
WSPLIN-main/optimizer/ranger/ranger.py
import math import torch from torch.optim.optimizer import Optimizer, required import itertools as it from lookahead import * from radam import * def Ranger(params, alpha=0.5, k=6, *args, **kwargs): radam = RAdam(params, *args, **kwargs) return Lookahead(radam, alpha, k)
283
27.4
53
py
WSPLIN
WSPLIN-main/optimizer/ranger/ralamb.py
import torch, math from torch.optim.optimizer import Optimizer # RAdam + LARS class Ralamb(Optimizer): # def __init__(self, params, lr=8e-4, betas=(0.9, 0.999), eps=1e-8, weight_decay=0): def __init__(self, params, lr=1e-3, betas=(0.9, 0.999), eps=1e-8, weight_decay=0): defaults = dict(lr=lr, bet...
4,119
39.792079
181
py
WSPLIN
WSPLIN-main/optimizer/ranger/lookahead.py
# Lookahead implementation from https://github.com/rwightman/pytorch-image-models/blob/master/timm/optim/lookahead.py """ Lookahead Optimizer Wrapper. Implementation modified from: https://github.com/alphadl/lookahead.pytorch Paper: `Lookahead Optimizer: k steps forward, 1 step back` - https://arxiv.org/abs/1907.08610...
4,075
41.020619
117
py
WSPLIN
WSPLIN-main/dataloader/build_loader.py
from timm.data import Mixup from dataloader.ioplin import ioplin_dataloader from .iNet_torch import * def build_loader(config,is_train): mixup_fn = None mixup_active = config.AUG.MIXUP > 0 or config.AUG.CUTMIX > 0. or config.AUG.CUTMIX_MINMAX is not None name = config.DATA.DATALOADER_NAME.lower().spl...
1,128
39.321429
113
py
WSPLIN
WSPLIN-main/dataloader/iNet_torch.py
from timm.data import create_loader import torch from .dataset import build_dataset def timm_dataloader(config,is_train): if is_train: dataset_train,dataset_val = build_dataset(config,'train_val') loader_train = create_loader( dataset_train, input_size=config.DATA.IMG_SIZE,...
3,797
44.214286
246
py
WSPLIN
WSPLIN-main/dataloader/ioplin.py
import torch from typing import TypeVar, Optional, Iterator from torch.utils.data import Sampler,Dataset import torch.distributed as dist import math from .dataset import build_dataset class SubsetRandomSampler(torch.utils.data.Sampler): r"""Samples elements randomly from a given list of indices, without replaceme...
8,495
44.924324
248
py
WSPLIN
WSPLIN-main/dataloader/dataset/transform.py
from timm.data import create_transform from timm.data.transforms import str_to_interp_mode import albumentations as A from albumentations.pytorch import ToTensorV2 from torchvision import transforms import torch import numpy as np from .transforms import * from .utils import TransformCompatWrapper,MultiViewWarper def ...
6,610
43.972789
162
py
WSPLIN
WSPLIN-main/dataloader/dataset/utils.py
import os import torch import numpy as np import random from PIL import ImageFilter, ImageOps from timm.data.parsers.parser import Parser from copy import deepcopy import torch.utils.data as data class SubsetRandomSampler(torch.utils.data.Sampler): r"""Samples elements randomly from a given list of indices, withou...
5,081
28.375723
98
py
WSPLIN
WSPLIN-main/dataloader/dataset/datasets.py
''' Note: Please implements the target transform in the custom dataset!!! Note: Please implements the target transform in the custom dataset!!! Note: Please implements the target transform in the custom dataset!!! ''' import torch.utils.data as data from timm.data import create_parser from timm.data.transforms import...
12,567
38.031056
148
py
WSPLIN
WSPLIN-main/dataloader/dataset/transforms.py
import torchvision.transforms as transforms import numpy as np from PIL import Image from .utils import GaussianBlur,Solarization class DataAugmentationDINO(object): def __init__(self, global_crops_scale, local_crops_scale, local_crops_number,img_size): flip_and_color_jitter = transforms.Compose([ ...
3,409
39.595238
122
py
fine-grained-evals
fine-grained-evals-main/models/BLIP/eval_retrieval_video.py
''' * Copyright (c) 2022, salesforce.com, inc. * All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause * By Junnan Li ''' import argparse import os import ruamel_yaml as yaml import numpy as np imp...
9,531
37.128
123
py
fine-grained-evals
fine-grained-evals-main/models/BLIP/pretrain.py
''' * Copyright (c) 2022, salesforce.com, inc. * All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause * By Junnan Li ''' import argparse import os import ruamel_yaml as yaml import numpy as np imp...
6,666
37.537572
148
py
fine-grained-evals
fine-grained-evals-main/models/BLIP/eval_nocaps.py
''' * Copyright (c) 2022, salesforce.com, inc. * All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause * By Junnan Li ''' import argparse import os import ruamel_yaml as yaml import numpy as np imp...
4,249
35.016949
119
py
fine-grained-evals
fine-grained-evals-main/models/BLIP/Winoground.py
import argparse import os import ruamel.yaml as yaml import time import datetime import json from pathlib import Path from tqdm import tqdm import torch import torch.nn.functional as F from torchvision import transforms from PIL import Image from data.utils import pre_caption from datasets import load_dataset from...
6,426
43.944056
143
py
fine-grained-evals
fine-grained-evals-main/models/BLIP/utils.py
import math def cosine_lr_schedule(optimizer, epoch, max_epoch, init_lr, min_lr): """Decay the learning rate""" lr = (init_lr - min_lr) * 0.5 * (1. + math.cos(math.pi * epoch / max_epoch)) + min_lr for param_group in optimizer.param_groups: param_group['lr'] = lr def warmup_lr_schedule(opti...
8,474
29.485612
94
py
fine-grained-evals
fine-grained-evals-main/models/BLIP/train_vqa.py
''' * Copyright (c) 2022, salesforce.com, inc. * All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause * By Junnan Li ''' import argparse import os import ruamel_yaml as yaml import numpy as np imp...
7,751
37.376238
128
py
fine-grained-evals
fine-grained-evals-main/models/BLIP/VSR.py
import argparse import os import ruamel.yaml as yaml import time import datetime import json import jsonlines from pathlib import Path from tqdm import tqdm import torch import torch.nn.functional as F from torchvision import transforms from PIL import Image from data.utils import pre_caption from models.blip_pretr...
4,825
37.608
123
py
fine-grained-evals
fine-grained-evals-main/models/BLIP/train_nlvr.py
''' * Copyright (c) 2022, salesforce.com, inc. * All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause * By Junnan Li ''' import argparse import os import ruamel_yaml as yaml import numpy as np imp...
8,060
36.84507
123
py
fine-grained-evals
fine-grained-evals-main/models/BLIP/train_retrieval.py
''' * Copyright (c) 2022, salesforce.com, inc. * All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause * By Junnan Li ''' import argparse import os import ruamel.yaml as yaml import numpy as np imp...
14,183
39.876081
141
py
fine-grained-evals
fine-grained-evals-main/models/BLIP/VALSE.py
import argparse import os import ruamel.yaml as yaml import time import datetime import json from pathlib import Path from tqdm import tqdm import torch import torch.nn.functional as F from torchvision import transforms from PIL import Image from data.utils import pre_caption from models.blip_pretrain import blip_p...
6,007
39.870748
148
py