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
NeuralSpeech
NeuralSpeech-master/BinauralGrad/src/binauralgrad/warping.py
""" Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. This source code is licensed under the license found in the LICENSE file in the root directory of this source tree. """ # reference: https://github.com/facebookresearch/BinauralSpeechSynthesis/blob/main/src/warping.py import torch as th import...
4,372
37.699115
101
py
NeuralSpeech
NeuralSpeech-master/BinauralGrad/src/binauralgrad/learner.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import numpy as np import os import torch import torch.nn as nn from torch.nn.parallel import DistributedDataParallel #from torch.utils.tensorboard import SummaryWriter from tqdm import tqdm from binauralgrad.losses import PhaseLoss from binaura...
8,812
40.375587
192
py
NeuralSpeech
NeuralSpeech-master/BinauralGrad/src/binauralgrad/model.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import numpy as np import torch import torch.nn as nn import torch.nn.functional as F import scipy from scipy.spatial.transform import Rotation as R from math import sqrt Linear = nn.Linear ConvTranspose2d = nn.ConvTranspose2d def Conv1d(*arg...
7,085
35.715026
131
py
NeuralSpeech
NeuralSpeech-master/BinauralGrad/src/binauralgrad/dataset.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import numpy as np import os import random import torch import torchaudio from glob import glob from torch.utils.data.distributed import DistributedSampler import torch.nn.functional as F class BinauralConditionalDataset(torch.utils.data.Datase...
4,826
39.90678
117
py
NeuralSpeech
NeuralSpeech-master/BinauralGrad/src/binauralgrad/mstft_loss.py
#Reference: https://github.com/csteinmetz1/auraloss import torch import numpy as np import librosa.filters import scipy.signal class SumAndDifference(torch.nn.Module): """Sum and difference signal extraction module.""" def __init__(self): """Initialize sum and difference extraction module.""" ...
24,435
35.690691
133
py
NeuralSpeech
NeuralSpeech-master/BinauralGrad/src/binauralgrad/train.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from argparse import ArgumentParser from torch.cuda import device_count from torch.multiprocessing import spawn from binauralgrad.learner import train, train_distributed import binauralgrad.params as params_all def _get_free_port(): import s...
1,779
37.695652
107
py
NeuralSpeech
NeuralSpeech-master/AdapterASR/e2e_asr_adaptertransformer.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # Copyright 2019 Shigeki Karita # Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0) """Transformer speech recognition model (pytorch).""" from argparse import Namespace from distutils.util import strtobool import logging import math im...
42,330
40.058196
177
py
NeuralSpeech
NeuralSpeech-master/AdapterASR/balanced_sampler.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # Reference: https://github.com/khornlund/pytorch-balanced-sampler import torch import torch.utils.data import random import collections import logging import numpy as np from torch.utils.data.sampler import BatchSampler, WeightedRandomSampler ...
2,341
38.033333
108
py
NeuralSpeech
NeuralSpeech-master/AdapterASR/utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import torch import logging from espnet.asr.asr_utils import add_results_to_json import argparse import numpy as np import collections import json def load_head_from_pretrained_model(model, model_path): model_dict = torch.load(model_path, m...
11,240
36.47
159
py
NeuralSpeech
NeuralSpeech-master/AdapterASR/data_load.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from espnet.utils.training.batchfy import make_batchset from torch.utils.data import DataLoader from torch.nn.utils.rnn import pad_sequence import torch import os import json import kaldiio import random import logging import sentencepiece as spm...
13,293
35.223433
113
py
NeuralSpeech
NeuralSpeech-master/AdapterASR/train.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import logging import os import collections from espnet.bin.asr_train import get_parser from espnet.utils.dynamic_import import dynamic_import from espnet.utils.deterministic_utils import set_deterministic_pytorch from espnet.asr.pytorch_backend....
25,635
46.650558
144
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/modules/diffusion.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # The diffusion acoustic decoder module is based on the DiffWave architecture: https://github.com/lmnt-com/diffwave # Copyright 2020 LMNT, Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not...
8,890
39.04955
185
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/modules/base.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import numpy as np import torch class BaseModule(torch.nn.Module): def __init__(self): super(BaseModule, self).__init__() @property def nparams(self): """ Returns number of trainable parameters of the module...
893
26.090909
73
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/modules/tts_modules.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import logging import torch import torch.nn as nn from torch.nn import functional as F from modules.operations import SinusoidalPositionalEmbedding, OPERATIONS_ENCODER, OPERATIONS_DECODER from tts_utils.hparams import hparams DEFAULT_MAX_SOURC...
14,686
37.447644
116
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/modules/operations.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import math import torch from torch import nn from torch.nn import Parameter import torch.onnx.operators import torch.nn.functional as F import tts_utils from tts_utils.hparams import hparams class SelfAttention(nn.Module): def __init__(sel...
53,222
40.64554
120
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/modules/priorgrad.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from modules.operations import * from modules.tts_modules import DurationPredictor, LengthRegulator, PitchPredictor, EnergyPredictor,\ TransformerEncoderLayer, DEFAULT_MAX_SOURCE_POSITIONS from modules.diffusion import DiffDecoder from tts_ut...
17,248
46.913889
171
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/tts_utils/stft.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import torch import numpy as np import torch.nn.functional as F from torch.autograd import Variable from scipy.signal import get_window from librosa.util import pad_center, tiny import librosa.util as librosa_util from torchaudio.transforms impo...
6,068
35.341317
97
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/tts_utils/pl_utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import matplotlib from torch.nn import DataParallel from torch.nn.parallel import DistributedDataParallel matplotlib.use('Agg') import glob import itertools import subprocess import threading import traceback from pytorch_lightning.callbacks im...
58,649
34.959534
122
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/tts_utils/audio.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import traceback import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt import librosa import librosa.filters import numpy as np import torch from scipy import signal from scipy.io import wavfile def save_wav(wav, path, sr, n...
4,999
25.455026
116
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/tts_utils/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import glob import logging import re import time from collections import defaultdict import os import sys import shutil import types import numpy as np import torch import torch.nn.functional as F import torch.distributed as dist def reduce_ten...
17,042
29.931034
114
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/tts_utils/world_utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. ########## # world ########## import numpy as np import pysptk import copy import torch gamma = 0 mcepInput = 3 # 0 for dB, 3 for magnitude alpha = 0.45 en_floor = 10 ** (-80 / 20) FFT_SIZE = 2048 def code_harmonic(sp, order): # get mcep...
2,926
26.87619
106
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/tts_utils/preprocessor.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import json import warnings import torch from skimage.transform import resize from tts_utils.world_utils import f0_to_coarse warnings.filterwarnings("ignore") import struct import webrtcvad from scipy.ndimage.morphology import binary_dilation...
10,373
35.657244
115
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/tts_utils/tts_utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import torch import torch.nn.functional as F import numpy as np from tts_utils.stft import STFT def make_pad_mask(lengths, xs=None, length_dim=-1): """Make mask tensor containing indices of padded part. Args: lengths (LongTensor...
8,414
37.424658
82
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/monotonic_align/__init__.py
import numpy as np import torch from .monotonic_align.core import maximum_path_c def maximum_path(value, mask): """ Cython optimised version. value: [b, t_x, t_y] mask: [b, t_x, t_y] """ value = value * mask device = value.device dtype = value.dtype value = value.data.cpu().numpy().astype(np.float32...
608
26.681818
62
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/tasks/base_task.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import matplotlib matplotlib.use('Agg') from tts_utils.hparams import hparams, set_hparams import random import sys import numpy as np import torch.distributed as dist from pytorch_lightning.loggers import TensorBoardLogger from tts_utils.pl_uti...
11,402
31.303116
98
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/tasks/priorgrad_inference.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import os, glob, re from tts_utils.hparams import hparams, set_hparams from tasks.priorgrad import PriorGradDataset from tasks.priorgrad import PriorGradTask import torch import numpy as np from tqdm import tqdm set_hparams() def get_latest_ckp...
3,439
41.469136
142
py
NeuralSpeech
NeuralSpeech-master/PriorGrad-acoustic/tasks/priorgrad.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import matplotlib # matplotlib.use('Agg') from matplotlib import pyplot as plt from tts_utils.pl_utils import data_loader import os, sys import json from multiprocessing.pool import Pool from tqdm import tqdm from modules.tts_modules import Du...
44,586
48.762277
165
py
NeuralSpeech
NeuralSpeech-master/FastCorrect/eval_aishell.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import sys import torch import argparse import re #from fastcorrect_model import FastCorrectModel import os import os.path import time import json import numpy as np from fairseq import utils utils.import_user_module(argparse.Namespace(user_dir=...
4,731
41.630631
223
py
NeuralSpeech
NeuralSpeech-master/FastCorrect/FC_utils/language_pair_dataset.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import logging import numpy as np import torch from fairseq.data im...
24,146
38.455882
90
py
NeuralSpeech
NeuralSpeech-master/FastCorrect/FC_utils/hub_utils_fc.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. #!/usr/bin/env python3 -u # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse import copy import logging...
11,181
35.423453
95
py
NeuralSpeech
NeuralSpeech-master/FastCorrect/FC_utils/binarizer_fc.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os from collections import Counter import torch from fairseq...
4,394
33.606299
103
py
NeuralSpeech
NeuralSpeech-master/FastCorrect/FC_utils/options_fc.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import argparse from typing import Callable, List, Optional import ...
19,822
43.346756
120
py
NeuralSpeech
NeuralSpeech-master/FastCorrect/FC_utils/fastcorrect_generator.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. from collections import namedtuple import numpy as np import torch ...
13,998
36.530831
163
py
NeuralSpeech
NeuralSpeech-master/FastCorrect/FastCorrect/fastcorrect_task.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import os import itertools import logging logger = logging.getLogge...
13,281
34.513369
113
py
NeuralSpeech
NeuralSpeech-master/FastCorrect/FastCorrect/fc_loss.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import math import torch import torch.nn.functional as F from fairs...
7,118
35.137056
119
py
NeuralSpeech
NeuralSpeech-master/FastCorrect/FastCorrect/fastcorrect_model.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # Copyright (c) Facebook, Inc. and its affiliates. # # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. import torch import torch.nn.functional as F from fairseq import uti...
29,151
36.470437
215
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/modules/stft_loss.py
# -*- coding: utf-8 -*- # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # Copyright 2019 Tomoki Hayashi # MIT License (https://opensource.org/licenses/MIT) """STFT-based Loss modules.""" import librosa import torch from parallel_wavegan.losses import LogSTFTMagnitudeLoss, SpectralConvergen...
3,470
32.375
105
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/modules/tts_modules.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import math import logging import torch import torch.nn as nn from torch.nn import functional as F from modules.operations import SinusoidalPositionalEmbedding, OPERATIONS_ENCODER, ConvSeparable from utils.world_utils import build_activation fr...
17,051
37.579186
116
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/modules/lightspeech.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. from modules.operations import * from modules.tts_modules import TransformerEncoder, LightSpeechDecoder, DurationPredictor, LengthRegulator, PitchPredictor, EnergyPredictor import utils from utils.world_utils import f0_to_coarse_torch, restore_pi...
8,395
47.531792
139
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/modules/operations.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import math import torch from torch import nn from torch.nn import Parameter import torch.onnx.operators import torch.nn.functional as F import utils from utils.hparams import hparams from utils.world_utils import build_activation def LayerNorm...
24,598
41.930192
159
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/utils/stft.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import torch import numpy as np import torch.nn.functional as F from torch.autograd import Variable from scipy.signal import get_window from librosa.util import pad_center, tiny import librosa.util as librosa_util def window_sumsquare(window, n...
6,019
35.26506
97
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/utils/pl_utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import os import re import sys import copy import glob import tqdm import logging import itertools import subprocess import threading import traceback from functools import wraps import numpy as np import torch from torch.cuda._utils import _get...
59,913
35.201813
122
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/utils/pwg_decode_from_mel.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import logging import yaml import numpy as np from sklearn.preprocessing import StandardScaler import torch from torch import nn import utils from parallel_wavegan.models import ParallelWaveGANGenerator from parallel_wavegan.utils import read_h...
2,401
33.811594
110
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/utils/__init__.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import os import sys import glob import logging import re import time from collections import defaultdict import shutil import types import numpy as np import torch import torch.nn.functional as F import torch.distributed as dist def reduce_te...
16,922
29.994505
114
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/utils/world_utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. ########## # world ########## import numpy as np import pysptk import copy import math import torch import torch.nn as nn gamma = 0 mcepInput = 3 # 0 for dB, 3 for magnitude alpha = 0.45 en_floor = 10 ** (-80 / 20) FFT_SIZE = 2048 def code_h...
6,554
27.25431
106
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/utils/preprocessor.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import json import warnings import struct import webrtcvad from skimage.transform import resize from scipy.ndimage.morphology import binary_dilation import pyworld as pw import numpy as np import torch import librosa import pyloudnorm as pyln f...
8,211
35.990991
107
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/utils/tts_utils.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import torch from utils.stft import STFT def make_pad_mask(lengths, xs=None, length_dim=-1): """Make mask tensor containing indices of padded part. Args: lengths (LongTensor or List): Batch of lengths (B,). xs (Tensor, o...
8,863
38.048458
84
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/tasks/base_task.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import os import sys import random import logging import matplotlib matplotlib.use('Agg') import numpy as np import torch.distributed as dist from pytorch_lightning.logging import TensorBoardLogger from torch import nn import torch.utils.data i...
11,465
31.207865
98
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/tasks/lightspeech_inference.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import os, glob, re from tqdm import tqdm import numpy as np import torch import utils from utils.hparams import hparams, set_hparams from tasks.lightspeech import LightSpeechDataset, LightSpeechTask set_hparams() def get_latest_ckpt(dir): ...
2,707
37.685714
123
py
NeuralSpeech
NeuralSpeech-master/LightSpeech/tasks/lightspeech.py
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. import os import sys import re import glob import logging import json import matplotlib matplotlib.use('Agg') import matplotlib.pyplot as plt from multiprocessing.pool import Pool from tqdm import tqdm import numpy as np import torch import torc...
37,184
44.681818
131
py
lm-scorer
lm-scorer-master/lm_scorer/models/gpt2.py
from typing import * # pylint: disable=wildcard-import,unused-wildcard-import import torch from transformers import AutoTokenizer, GPT2LMHeadModel from transformers import GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP from transformers.tokenization_utils import BatchEncoding from .abc.transformers import TransformersLMScorer ...
3,499
39.697674
85
py
lm-scorer
lm-scorer-master/lm_scorer/models/abc/base.py
from typing import * # pylint: disable=wildcard-import,unused-wildcard-import from abc import ABC, abstractmethod import math import torch class LMScorer(ABC): def __init__(self, model_name: str, **kwargs: Any) -> None: self._build(model_name, kwargs) @overload def sentence_score( self...
3,273
30.480769
83
py
lm-scorer
lm-scorer-master/lm_scorer/models/abc/batch.py
# pylint: disable=abstract-method from typing import * # pylint: disable=wildcard-import,unused-wildcard-import from abc import abstractmethod import torch from .base import LMScorer class BatchedLMScorer(LMScorer): # @overrides def _build(self, model_name: str, options: Dict[str, Any]) -> None: su...
1,148
30.916667
78
py
lm-scorer
lm-scorer-master/lm_scorer/bin/cli.py
#!/usr/bin/env python3 from typing import * # pylint: disable=wildcard-import,unused-wildcard-import import argparse import itertools import os import sys import torch from ..models.auto import AutoLMScorer as LMScorer def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser( descript...
5,142
28.728324
88
py
lm-scorer
lm-scorer-master/tests/unit/models/abc/test_base.py
# pylint: disable=missing-module-docstring,missing-function-docstring,unused-variable,too-many-locals,too-many-statements import math import pytest # pylint: disable=unused-import import scipy import torch from lm_scorer.models.abc.base import LMScorer def model(text): tokens = ["START"] + text.split(" ") s...
4,467
35.325203
121
py
espressopp
espressopp-master/src/external/transformations.py
""" *********************************** espressopp.external.transformations *********************************** Homogeneous Transformation Matrices and Quaternions. A library for calculating 4x4 matrices for translating, rotating, reflecting, scaling, shearing, projecting, orthogonalizing, and superimposing arrays of...
61,424
32.602298
79
py
espressopp
espressopp-master/doc/ug/conf.py
# -*- coding: utf-8 -*- # # ESPResSo++ documentation build configuration file, created by # sphinx-quickstart on Sat Jan 23 13:11:32 2010. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # ...
7,631
32.038961
92
py
Dataset-3DPOP
Dataset-3DPOP-main/Examples/SampleTrainingImages.py
# !/usr/bin/env python3 """Sample images and save annotaitons to json to be read by pytorch dataloader""" import sys sys.path.append("./") from POP3D_Reader import Trial import os import cv2 import numpy as np import math import pandas as pd import random from tqdm import tqdm import json random.seed(10) def GetInst...
14,223
40.228986
164
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/test.py
import os from skimage import io, transform import torch import torchvision from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F from torch.utils.data import Dataset, DataLoader from torchvision import transforms#, utils # import torch.optim as optim import numpy as np from PIL imp...
5,710
29.704301
136
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/train.py
import torch import torchvision from torch.autograd import Variable import torch.nn as nn import torch.nn.functional as F from torch.utils.data import Dataset, DataLoader from torchvision import transforms, utils import torch.optim as optim import torchvision.transforms as standard_transforms from tensorboardX import ...
20,692
40.05754
160
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/evaluation/metrics.py
import numpy as np import torch from sklearn.metrics import average_precision_score class AverageMeter(object): """Computes and stores the average and current value""" def __init__(self): self.reset() def reset(self): self.val = 0 self.avg = 0 self.sum = 0 self.co...
3,678
31.557522
107
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/networks/DIRL.py
import torch import torch.nn as nn from torchvision import models import torch.nn.functional as F import scipy.stats as st import numpy as np from torch.nn.parameter import Parameter from networks.blocks import Conv2dBlock, BasicBlock, BasicConv import cv2 import copy import os ## ---------------------Bi-directional F...
18,647
40.44
134
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/networks/iHDRNet.py
import math import torch import torch.nn.functional as F from torch import nn from torch.nn import Parameter from networks.blocks import Conv2d_cd, ResNetBlock, Conv2dBlock import numpy as np class SelfAttention(nn.Module): """ Self attention Layer""" def __init__(self,in_dim, mode='self'): super(Self...
9,047
36.38843
122
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/networks/UNet.py
import torch import torchvision.models as models import torch.nn.functional as F import torch.nn as nn from networks.blocks import BasicBlock, Bottleneck class DoubleConv(nn.Module): """(convolution => [BN] => ReLU) * 2""" def __init__(self, in_channels, out_channels): super().__init__() self...
5,067
34.943262
96
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/networks/E_dom.py
import torch import torch.nn as nn import torch.nn.functional as F import numpy as np from collections import OrderedDict import torchvision.models as models from networks.blocks import PartialConv2d class DomainEncoder(nn.Module): def __init__(self, style_dim): super(DomainEncoder, self).__init__() ...
3,091
30.876289
106
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/networks/blocks.py
""" Copyright (C) 2019 NVIDIA Corporation. All rights reserved. Licensed under the CC BY-NC-SA 4.0 license (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode). """ import torch import torch.nn.functional as F from torch import nn import math def conv3x3(in_planes, out_planes, stride=1): "3x3 convolution...
13,469
35.016043
158
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/dataset/base_dataset.py
"""This module implements an abstract base class (ABC) 'BaseDataset' for datasets. It also includes common transformation functions (e.g., get_transform, __scale_width), which can be later used in subclasses. """ import random import numpy as np import torch.utils.data as data #from PIL import Image import cv2 #import...
4,950
35.138686
141
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/dataset/multi_objects_ihd_dataset.py
import os.path import os import torch import torchvision.transforms.functional as tf from dataset.base_dataset import BaseDataset, get_transform #from PIL import Image import cv2 import numpy as np import torchvision.transforms as transforms import random import torch.nn.functional as F import copy class MultiObjectsI...
5,493
37.964539
141
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/dataset/__init__.py
"""This package includes all the modules related to data loading and preprocessing To add a custom dataset class called 'dummy', you need to add a file called 'dummy_dataset.py' and define a subclass 'DummyDataset' inherited from BaseDataset. You need to implement four functions: -- <__init__>: ...
3,557
36.851064
176
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/dataset/ihd_dataset.py
import os.path import os import torch import torchvision.transforms.functional as tf from dataset.base_dataset import BaseDataset, get_transform #from PIL import Image import cv2 import numpy as np import torchvision.transforms as transforms import random import torch.nn.functional as F import copy class IhdDataset(Ba...
5,665
38.347222
141
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/pytorch_iou/__init__.py
import torch import torch.nn.functional as F from torch.autograd import Variable import numpy as np def _iou(pred, target, size_average = True): b = pred.shape[0] IoU = 0.0 for i in range(0,b): #compute the IoU of the foreground Iand1 = torch.sum(target[i,:,:,:]*pred[i,:,:,:]) Ior1...
730
24.206897
74
py
MadisNet-Inharmonious-Region-Localization
MadisNet-Inharmonious-Region-Localization-master/pytorch_ssim/__init__.py
# https://github.com/Po-Hsun-Su/pytorch-ssim/blob/master/pytorch_ssim/__init__.py import torch import torch.nn.functional as F from torch.autograd import Variable import numpy as np from math import exp def gaussian(window_size, sigma): gauss = torch.Tensor([exp(-(x - window_size//2)**2/float(2*sigma**2)) for x in...
4,529
34.952381
104
py
thundergbm
thundergbm-master/python/benchmarks/experiments.py
import utils.data_utils as du from model.catboost_model import CatboostModel from model.lightgbm_model import LightGBMModel from model.xgboost_model import XGboostModel from model.thundergbm_model import ThunderGBMModel from model.datasets import Dataset import utils.file_utils as fu import pandas as pd import math imp...
7,521
36.054187
112
py
thundergbm
thundergbm-master/python/benchmarks/model/xgboost_model.py
from model.base_model import BaseModel import numpy as np import xgboost as xgb import time import utils.data_utils as du from model.datasets import Dataset class XGboostModel(BaseModel): def __init__(self, use_exact=False, debug_verose=1): BaseModel.__init__(self) self.use_exact = use_exact ...
3,015
33.272727
89
py
thundergbm
thundergbm-master/docs/conf.py
# -*- coding: utf-8 -*- # # ThunderSVM documentation build configuration file, created by # sphinx-quickstart on Sat Oct 28 23:38:46 2017. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # ...
5,511
29.622222
79
py
PoseTriplet
PoseTriplet-main/estimator/posegan_evaluate.py
# Copyright (c) 2018-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import math import multiprocessing import os import pickle import random from time import time import numpy as np import torch...
19,271
43.714617
131
py
PoseTriplet
PoseTriplet-main/estimator/posegan_train.py
# Copyright (c) 2018-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import os import random from time import time import numpy as np import torch from torch.autograd import Variable from common...
11,685
43.098113
125
py
PoseTriplet
PoseTriplet-main/estimator/posegan_basementclass.py
# Copyright (c) 2018-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import os import os.path as path import pickle from time import time import numpy as np import torch import torch.optim as opt...
55,174
51.647901
169
py
PoseTriplet
PoseTriplet-main/estimator/function/utils.py
from __future__ import absolute_import, division import os import torch import numpy as np from tensorboardX import SummaryWriter # self define tools class Summary(object): def __init__(self, directory): self.directory = directory self.epoch = 0 self.writer = None self.phase = 0 ...
7,848
33.730088
109
py
PoseTriplet
PoseTriplet-main/estimator/function/gan_utils.py
import torch.nn as nn import torch import numpy as np import torchgeometry as tgm ''' function on pose related information extraction. ''' def get_pose3dbyBoneVec(bones, num_joints=16): ''' conver bone vect to pose3d,is the inverse of get_bone_vector :param bones: :return: ''' Ctinverse = tor...
11,075
34.386581
122
py
PoseTriplet
PoseTriplet-main/estimator/common/custom_dataset.py
# Copyright (c) 2018-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import numpy as np import copy from common.skeleton import Skeleton from common.mocap_dataset import MocapDataset from common.c...
4,740
33.355072
101
py
PoseTriplet
PoseTriplet-main/estimator/common/camera.py
# Copyright (c) 2018-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import numpy as np import torch import torchgeometry as tgm from common.utils import wrap from common.quaternion import qrot, ...
11,136
31.755882
159
py
PoseTriplet
PoseTriplet-main/estimator/common/loss.py
# Copyright (c) 2018-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import torch import numpy as np def mpjpe(predicted, target): """ Mean per-joint position error (i.e. mean Euclidean d...
6,020
31.722826
106
py
PoseTriplet
PoseTriplet-main/estimator/common/utils.py
# Copyright (c) 2018-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import torch import numpy as np import hashlib def wrap(func, *args, unsqueeze=False): """ Wrap a torch function so it...
1,470
30.297872
77
py
PoseTriplet
PoseTriplet-main/estimator/common/model.py
# Copyright (c) 2018-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import torch import torch.nn as nn class TemporalModelBase(nn.Module): """ Do not instantiate this class. """ ...
8,387
40.524752
128
py
PoseTriplet
PoseTriplet-main/estimator/common/camera2world.py
import torch import numpy as np from sklearn.decomposition import PCA from scipy.spatial.transform import Rotation as R """ camera to world: case 1: assume the camera ID is known for each clip. A. do PCA for 150 clips to found a gravity approximation B. assume a stand pose, filter out the stand pose from prediction, d...
3,850
31.91453
97
py
PoseTriplet
PoseTriplet-main/estimator/common/quaternion.py
# Copyright (c) 2018-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # import torch def qrot(q, v): """ Rotate vector(s) v about the rotation described by quaternion(s) q. Expects a ten...
1,001
27.628571
78
py
PoseTriplet
PoseTriplet-main/estimator/poseaugtool/model_virtualCam/virtualCam.py
import torch import torchgeometry as tgm from torch import nn from poseaugtool.model_conv1d.conv1d import Conv1dBlock from common.quaternion import qrot from common.camera import project_to_2d_purelinear class DoubleLinear(nn.Module): def __init__(self, linear_size): super(DoubleLinear, self).__init__() ...
14,619
34.228916
128
py
PoseTriplet
PoseTriplet-main/estimator/poseaugtool/model_conv1d/conv1d.py
import torch.nn as nn import torch import torch.nn.functional as F ############################################################## class DoubleConv(nn.Module): """(convolution => [BN] => ReLU) * 2""" def __init__(self, in_channels, out_channels, mid_channels=None, kernel_size=3 , padding=1, stride=1): ...
5,285
36.489362
122
py
PoseTriplet
PoseTriplet-main/hallucinator/code_rib/ribpose2bvh.py
import random import torch.optim as optim import os import datetime import os.path as path from torch.autograd import Variable from progress.bar import Bar from time import time from bvh_skeleton import humanoid_1205_skeleton from bvh_skeleton.camera import world2cam_sktpos, cam2world_sktpos import torch import nu...
3,920
26.041379
98
py
PoseTriplet
PoseTriplet-main/hallucinator/code_rib/test.py
import torch import sys, os sys.path.insert(0, os.path.dirname(__file__)) from LaFan import LaFan1 from torch.utils.data import Dataset, DataLoader from model import StateEncoder, \ OffsetEncoder, \ TargetEncoder, \ LSTM, \ Decoder, \ ...
17,898
51.336257
126
py
PoseTriplet
PoseTriplet-main/hallucinator/code_rib/py_utils.py
import os import numpy as np import torch def merge_dict(dict_list): ret = {} for dict in dict_list: for key, value in dict.items(): try: ret[key] except KeyError: ret[key] = 0.0 ret[key] += value return ret def update_dict(old_d...
2,734
25.553398
90
py
PoseTriplet
PoseTriplet-main/hallucinator/code_rib/functions.py
import torch import numpy as np import torch.nn as nn from quaternion import qeuler_np from remove_fs import remove_fs def PLU(x, alpha = 0.1, c = 1.0): relu = nn.ReLU() o1 = alpha * (x + c) - c o2 = alpha * (x - c) + c o3 = x - relu(x - o2) o4 = relu(o1 - o3) + o3 return o4 def gen_ztta(dim =...
2,426
36.338462
95
py
PoseTriplet
PoseTriplet-main/hallucinator/code_rib/model.py
import torch import numpy as np import torch.nn as nn from functions import PLU class StateEncoder(nn.Module): def __init__(self, in_dim = 128, hidden_dim = 512, out_dim = 256): super(StateEncoder, self).__init__() self.in_dim = in_dim self.hidden_dim = hidden_dim self.out_dim = ou...
5,161
30.096386
86
py
PoseTriplet
PoseTriplet-main/hallucinator/code_rib/remove_fs.py
import os import sys import numpy as np import torch import argparse from tqdm import tqdm BASEPATH = os.path.dirname(__file__) from os.path import join as pjoin sys.path.insert(0, BASEPATH) sys.path.insert(0, pjoin(BASEPATH, '..')) import foot_sliding.BVH as BVH from foot_sliding.InverseKinematics import JacobianInve...
6,250
29.642157
115
py
PoseTriplet
PoseTriplet-main/hallucinator/code_rib/quaternion.py
import torch import numpy as np # PyTorch-backed implementations def qmul(q, r): """ Multiply quaternion(s) q with quaternion(s) r. Expects two equally-sized tensors of shape (*, 4), where * denotes any number of dimensions. Returns q*r as a tensor of shape (*, 4). """ assert q.shape[-1] == 4...
6,413
32.936508
102
py
PoseTriplet
PoseTriplet-main/hallucinator/code_rib/test-randomfuture-v1.py
import torch import sys, os sys.path.insert(0, os.path.dirname(__file__)) from LaFan import LaFan1 from torch.utils.data import Dataset, DataLoader from model import StateEncoder, \ OffsetEncoder, \ TargetEncoder, \ LSTM, \ Decoder, \ ...
21,956
51.154394
139
py
PoseTriplet
PoseTriplet-main/hallucinator/code_rib/skeleton.py
import torch import os import numpy as np import sys sys.path.insert(0, os.path.dirname(__file__)) from quaternion import qmul_np, qmul, qrot from torch.utils.data import Dataset, DataLoader from LaFan import LaFan1 class Skeleton: def __init__(self, offsets, parents, joints_left=None, joints_right=None): ...
6,005
35.846626
110
py
PoseTriplet
PoseTriplet-main/hallucinator/code_rib/LaFan.py
import torch from torch.utils.data import Dataset, DataLoader import sys, os sys.path.insert(0, os.path.dirname(__file__)) sys.path.append("..") import numpy as np from lafan1 import extract, utils, benchmarks class LaFan1(Dataset): def __init__(self, bvh_path, train = False, seq_len = 50, offset = 10, debug = F...
4,399
38.285714
131
py
PoseTriplet
PoseTriplet-main/hallucinator/code_rib/rlpose2bvh.py
import random import argparse import torch.optim as optim import os import datetime import os.path as path from torch.autograd import Variable from progress.bar import Bar from time import time from bvh_skeleton import humanoid_rib_skeleton from bvh_skeleton.camera import world2cam_sktpos import torch import numpy...
3,416
25.905512
98
py