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 |
|---|---|---|---|---|---|---|
nnsvs | nnsvs-master/tests/test_model.py | import torch
from nnsvs.base import PredictionType
from nnsvs.model import (
FFN,
LSTMRNN,
LSTMRNNSAR,
MDN,
RMDN,
Conv1dResnet,
Conv1dResnetMDN,
Conv1dResnetSAR,
FFConvLSTM,
MDNv2,
VariancePredictor,
)
from nnsvs.util import init_seed
def test_deprecated_imports():
from... | 6,229 | 26.688889 | 66 | py |
nnsvs | nnsvs-master/tests/test_model_configs.py | from pathlib import Path
import hydra
import nnsvs.bin.train
import nnsvs.bin.train_acoustic
import nnsvs.bin.train_postfilter
import pytest
import torch
from nnsvs.util import init_seed
from omegaconf import OmegaConf
from .util import _test_model_impl
RECIPE_DIR = Path(__file__).parent.parent / "recipes"
def _te... | 6,395 | 33.203209 | 88 | py |
nnsvs | nnsvs-master/docs/conf.py | # -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup ------------------------------------------------------------... | 4,386 | 29.255172 | 83 | py |
nnsvs | nnsvs-master/neutrino_compat/server.py | """Web server implementation for singing voice synthesis
NOTE: validation is not implemented. Expect 500 errors for unexpected inputs.
"""
import tarfile
from os import listdir, rmdir
from pathlib import Path
from shutil import move
import numpy as np
import pyworld
import torch
from fastapi import FastAPI, UploadFi... | 8,930 | 27.352381 | 84 | py |
nnsvs | nnsvs-master/neutrino_compat/bin/NEUTRINO.py | """Predict acoustic features by NNSVS with NEUTRINO-compatible file IO
NOTE: options are not yet fully implemented
NEUTRINO - NEURAL SINGING SYNTHESIZER (Electron v1.2.0-Stable)
Copyright (c) 2020-2022 STUDIO NEUTRINO All rights reserved.
usage:
NEUTRINO full.lab timing.lab output.f0 output.mgc outpu... | 8,240 | 32.5 | 89 | py |
nnsvs | nnsvs-master/neutrino_compat/bin/NSF.py | """Predict waveform by neural vocoders with NEUTRINO-compatible file IO
NOTE: options are not yet fully implemented
NSF - Neural Source Filter (v1.2.0-Stable)
Copyright (c) 2020-2022 STUDIO NEUTRINO All rights reserved.
usage:
NSF input.f0 input.mgc input.bap model_name output_wav [option]
options : ... | 5,014 | 31.993421 | 87 | py |
nnsvs | nnsvs-master/utils/enunu2nnsvs.py | """Convert ENUNU's packed model to NNSVS's style
"""
import argparse
import os
import shutil
import sys
from pathlib import Path
import joblib
import numpy as np
import torch
from nnsvs.logger import getLogger
from nnsvs.util import StandardScaler as NNSVSStandardScaler
from omegaconf import OmegaConf
from sklearn.pre... | 5,291 | 34.756757 | 85 | py |
nnsvs | nnsvs-master/utils/merge_postfilters.py | import argparse
import os
import sys
from pathlib import Path
import torch
from omegaconf import OmegaConf
def get_parser():
parser = argparse.ArgumentParser(
description="Merge post-filters",
)
parser.add_argument("mgc_checkpoint", type=str, help="mgc checkpoint")
parser.add_argument("bap_ch... | 1,864 | 32.303571 | 79 | py |
nnsvs | nnsvs-master/nnsvs/dsp.py | import torch
from scipy import signal
from torch import nn
from torch.nn import functional as F
# Part of code was adapted from:
# https://github.com/nii-yamagishilab/project-NN-Pytorch-scripts
def lowpass_filter(x, fs, cutoff=5, N=5):
"""Lowpass filter
Args:
x (np.ndarray): input signal
fs ... | 4,140 | 28.578571 | 88 | py |
nnsvs | nnsvs-master/nnsvs/base.py | from enum import Enum
from torch import nn
class PredictionType(Enum):
"""Prediction types"""
DETERMINISTIC = 1
"""Deterministic prediction
Non-MDN single-stream models should use this type.
Pseudo code:
.. code-block::
# training
y = model(x)
# inference
... | 3,784 | 22.955696 | 94 | py |
nnsvs | nnsvs-master/nnsvs/multistream.py | # Utils for multi-stream features
import numpy as np
import torch
from nnmnkwii import paramgen
def get_windows(num_window=1):
"""Get windows for MLPG.
Args:
num_window (int): number of windows
Returns:
list: list of windows
"""
windows = [(0, 0, np.array([1.0]))]
if num_win... | 6,737 | 28.946667 | 96 | py |
nnsvs | nnsvs-master/nnsvs/discriminators.py | """Discriminator implementations mostly used for GAN-based post-filters.
All the discriminators must returns list of tensors.
The last tensor of the list is regarded as the output of the discrminator.
The others are used as intermedieate feature maps.
"""
import numpy as np
import torch
from nnsvs.util import init_we... | 3,746 | 26.755556 | 78 | py |
nnsvs | nnsvs-master/nnsvs/mdn.py | import torch
import torch.nn.functional as F
from torch import nn
class MDNLayer(nn.Module):
"""Mixture Density Network layer
The input maps to the parameters of a Mixture of Gaussians (MoG) probability
distribution, where each Gaussian has out_dim dimensions and diagonal covariance.
If dim_wise is T... | 9,902 | 39.753086 | 96 | py |
nnsvs | nnsvs-master/nnsvs/svs.py | import json
import time
from copy import deepcopy
from pathlib import Path
import numpy as np
import torch
from hydra.utils import instantiate
from nnmnkwii.io import hts
from nnmnkwii.preprocessing.f0 import interp1d
from nnsvs.gen import (
postprocess_acoustic,
postprocess_duration,
postprocess_waveform,... | 37,016 | 36.657172 | 95 | py |
nnsvs | nnsvs-master/nnsvs/model.py | from warnings import warn
import torch
from nnsvs.base import BaseModel, PredictionType
from nnsvs.dsp import TrTimeInvFIRFilter
from nnsvs.layers.conv import ResnetBlock, WNConv1d
from nnsvs.layers.layer_norm import LayerNorm
from nnsvs.mdn import MDNLayer, mdn_get_most_probable_sigma_and_mu
from nnsvs.multistream im... | 40,986 | 30.577042 | 89 | py |
nnsvs | nnsvs-master/nnsvs/gen.py | from warnings import warn
import librosa
import numpy as np
import pyloudnorm as pyln
import pysptk
import pyworld
import scipy
import torch
from nnmnkwii.frontend import merlin as fe
from nnmnkwii.io import hts
from nnmnkwii.postfilters import merlin_post_filter
from nnmnkwii.preprocessing.f0 import interp1d
from nns... | 49,738 | 34.275887 | 96 | py |
nnsvs | nnsvs-master/nnsvs/postfilters.py | import numpy as np
import torch
from nnsvs.base import BaseModel
from nnsvs.multistream import split_streams
from nnsvs.util import init_weights
from torch import nn
def variance_scaling(gv, feats, offset=2, note_frame_indices=None):
"""Variance scaling method to enhance synthetic speech quality
Method propo... | 17,384 | 31.801887 | 88 | py |
nnsvs | nnsvs-master/nnsvs/util.py | import importlib
import random
from os.path import join
from pathlib import Path
from typing import Any
import numpy as np
import pkg_resources
import pyworld
import torch
from hydra.utils import instantiate
from nnsvs.multistream import get_static_features, get_static_stream_sizes
from nnsvs.usfgan import USFGANWrapp... | 13,862 | 30.578588 | 89 | py |
nnsvs | nnsvs-master/nnsvs/pitch.py | """This module provides functionality for pitch analysis.
References:
Nakano et al, "An Automatic Singing Skill Evaluation Method
for Unknown Melodies Using Pitch Interval Accuracy and Vibrato Features"
Proc. Interspeech 2006.
山田 et al, "HMM に基づく歌声合成のためのビブラートモデル化"
IPSJ SIG Tech. Report 2009.
Note that vibrato extra... | 18,639 | 30.863248 | 91 | py |
nnsvs | nnsvs-master/nnsvs/train_util.py | import os
import random
import shutil
import sys
import types
from glob import glob
from multiprocessing import Manager
from os.path import join
from pathlib import Path
import hydra
import joblib
import librosa
import librosa.display
import matplotlib.pyplot as plt
import mlflow
import numpy as np
import pysptk
impor... | 80,222 | 32.538043 | 95 | py |
nnsvs | nnsvs-master/nnsvs/acoustic_models/multistream.py | import torch
from nnsvs.acoustic_models.util import pad_inference
from nnsvs.base import BaseModel, PredictionType
from nnsvs.multistream import split_streams
from torch import nn
__all__ = [
"MultistreamSeparateF0ParametricModel",
"NPSSMultistreamParametricModel",
"NPSSMDNMultistreamParametricModel",
... | 34,956 | 36.267591 | 92 | py |
nnsvs | nnsvs-master/nnsvs/acoustic_models/tacotron.py | import torch
from nnsvs.acoustic_models.util import pad_inference
from nnsvs.base import BaseModel
from nnsvs.tacotron.decoder import MDNNonAttentiveDecoder
from nnsvs.tacotron.decoder import NonAttentiveDecoder as TacotronNonAttentiveDecoder
from nnsvs.tacotron.postnet import Postnet as TacotronPostnet
from nnsvs.util... | 17,378 | 35.056017 | 91 | py |
nnsvs | nnsvs-master/nnsvs/acoustic_models/tacotron_f0.py | import numpy as np
import torch
from nnsvs.acoustic_models.util import pad_inference
from nnsvs.base import BaseModel, PredictionType
from nnsvs.mdn import MDNLayer, mdn_get_most_probable_sigma_and_mu, mdn_get_sample
from nnsvs.tacotron.decoder import Prenet, ZoneOutCell
from nnsvs.util import init_weights
from torch i... | 27,907 | 36.111702 | 90 | py |
nnsvs | nnsvs-master/nnsvs/acoustic_models/util.py | import numpy as np
import torch
from nnsvs.base import PredictionType
from nnsvs.mdn import mdn_get_most_probable_sigma_and_mu
from torch.nn import functional as F
def predict_lf0_with_residual(
in_feats,
out_feats,
in_lf0_idx=300,
in_lf0_min=5.3936276,
in_lf0_max=6.491111,
out_lf0_idx=180,
... | 5,262 | 38.276119 | 87 | py |
nnsvs | nnsvs-master/nnsvs/acoustic_models/sinsy.py | import torch
from nnsvs.acoustic_models.util import predict_lf0_with_residual
from nnsvs.base import BaseModel, PredictionType
from nnsvs.mdn import MDNLayer, mdn_get_most_probable_sigma_and_mu
from nnsvs.util import init_weights
from torch import nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_seque... | 6,623 | 32.12 | 84 | py |
nnsvs | nnsvs-master/nnsvs/acoustic_models/__init__.py | from functools import partial
from nnsvs.acoustic_models.multistream import (
MDNMultistreamSeparateF0MelModel,
MultistreamSeparateF0MelModel,
MultistreamSeparateF0ParametricModel,
NPSSMDNMultistreamParametricModel,
NPSSMultistreamParametricModel,
)
from nnsvs.acoustic_models.sinsy import ResSkipF0... | 12,451 | 29.669951 | 87 | py |
nnsvs | nnsvs-master/nnsvs/bin/train_postfilter.py | from functools import partial
from pathlib import Path
import hydra
import mlflow
import numpy as np
import torch
import torch.distributed as dist
from hydra.utils import to_absolute_path
from nnsvs.multistream import select_streams
from nnsvs.train_util import (
collate_fn_default,
collate_fn_random_segments,... | 17,689 | 31.820037 | 103 | py |
nnsvs | nnsvs-master/nnsvs/bin/generate.py | # coding: utf-8
import os
from os.path import basename, join
import hydra
import joblib
import numpy as np
import torch
from hydra.utils import to_absolute_path
from nnmnkwii.datasets import FileSourceDataset
from nnsvs.base import PredictionType
from nnsvs.logger import getLogger
from nnsvs.multistream import get_wi... | 3,601 | 32.045872 | 82 | py |
nnsvs | nnsvs-master/nnsvs/bin/train_acoustic.py | from functools import partial
from pathlib import Path
import hydra
import mlflow
import torch
import torch.distributed as dist
from hydra.utils import to_absolute_path
from nnsvs.base import PredictionType
from nnsvs.mdn import mdn_get_most_probable_sigma_and_mu, mdn_loss
from nnsvs.multistream import split_streams
f... | 21,429 | 36.929204 | 103 | py |
nnsvs | nnsvs-master/nnsvs/bin/synthesis.py | import os
from os.path import join
import hydra
import joblib
import numpy as np
import torch
from hydra.utils import to_absolute_path
from nnmnkwii.io import hts
from nnsvs.gen import (
postprocess_acoustic,
postprocess_waveform,
predict_acoustic,
predict_timing,
predict_waveform,
)
from nnsvs.log... | 8,358 | 39.381643 | 91 | py |
nnsvs | nnsvs-master/nnsvs/bin/gen_static_features.py | import os
from os.path import exists, join
import hydra
import joblib
import numpy as np
import pyworld
import torch
from hydra.utils import to_absolute_path
from nnsvs.acoustic_models.util import pad_inference
from nnsvs.base import PredictionType
from nnsvs.gen import get_windows
from nnsvs.logger import getLogger
f... | 8,527 | 34.385892 | 87 | py |
nnsvs | nnsvs-master/nnsvs/bin/train.py | from functools import partial
from pathlib import Path
import hydra
import mlflow
import numpy as np
import torch
import torch.distributed as dist
from hydra.utils import to_absolute_path
from nnmnkwii import metrics
from nnsvs.base import PredictionType
from nnsvs.mdn import mdn_get_most_probable_sigma_and_mu, mdn_lo... | 11,217 | 31.705539 | 103 | py |
nnsvs | nnsvs-master/nnsvs/bin/anasyn.py | import os
from os.path import join
import hydra
import numpy as np
import pysptk
import pyworld
import torch
from hydra.utils import to_absolute_path
from nnsvs.dsp import bandpass_filter
from nnsvs.gen import gen_world_params
from nnsvs.logger import getLogger
from nnsvs.multistream import get_static_stream_sizes, sp... | 7,921 | 33.146552 | 86 | py |
nnsvs | nnsvs-master/nnsvs/layers/conv.py | from torch import nn
from torch.nn.utils import weight_norm
def WNConv1d(*args, **kwargs):
return weight_norm(nn.Conv1d(*args, **kwargs))
class ResnetBlock(nn.Module):
def __init__(self, dim, dilation=1):
super().__init__()
self.block = nn.Sequential(
nn.LeakyReLU(0.2),
... | 640 | 26.869565 | 65 | py |
nnsvs | nnsvs-master/nnsvs/layers/layer_norm.py | # Adapted from https://github.com/espnet/espnet
# Copyright 2019 Shigeki Karita
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Layer normalization module."""
import torch
class LayerNorm(torch.nn.LayerNorm):
"""Layer normalization module.
Args:
nout (int): Output dim size.
di... | 953 | 25.5 | 59 | py |
nnsvs | nnsvs-master/nnsvs/wavenet/modules.py | import torch
from nnsvs.wavenet import conv
from torch import nn
def Conv1d(in_channels, out_channels, kernel_size, *args, **kwargs):
"""Weight-normalized Conv1d layer."""
m = conv.Conv1d(in_channels, out_channels, kernel_size, *args, **kwargs)
return nn.utils.weight_norm(m)
def Conv1d1x1(in_channels, o... | 4,184 | 28.680851 | 76 | py |
nnsvs | nnsvs-master/nnsvs/wavenet/wavenet.py | import torch
from nnsvs.wavenet.modules import Conv1d1x1, ResSkipBlock
from torch import nn
from torch.nn import functional as F
class WaveNet(nn.Module):
"""WaveNet
Args:
in_dim (int): the dimension of the input
out_dim (int): the dimension of the output
layers (int): the number of l... | 4,862 | 27.273256 | 75 | py |
nnsvs | nnsvs-master/nnsvs/wavenet/conv.py | import torch
from packaging import version
from torch import nn
from torch.nn import functional as F
torch_is_ge_180 = version.parse(torch.__version__) >= version.parse("1.8.0")
class Conv1d(nn.Conv1d):
"""Extended nn.Conv1d for incremental dilated convolutions"""
def __init__(self, *args, **kwargs):
... | 2,508 | 34.842857 | 82 | py |
nnsvs | nnsvs-master/nnsvs/tacotron/postnet.py | # Acknowledgement: some of the code was adapted from ESPnet
# Copyright 2019 Nagoya University (Tomoki Hayashi)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
from torch import nn
class Postnet(nn.Module):
"""Post-Net of Tacotron 2
Args:
in_dim (int): dimension of input
layers... | 1,571 | 25.644068 | 70 | py |
nnsvs | nnsvs-master/nnsvs/tacotron/encoder.py | # The code was adapted from ttslearn https://github.com/r9y9/ttslearn
# Acknowledgement: some of the code was adapted from ESPnet
# Copyright 2019 Nagoya University (Tomoki Hayashi)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
from torch import nn
from torch.nn.utils.rnn import pack_padded_sequence, pa... | 2,409 | 29.897436 | 83 | py |
nnsvs | nnsvs-master/nnsvs/tacotron/decoder.py | # The code was adapted from ttslearn https://github.com/r9y9/ttslearn
# NonAttentiveDecoder is added to the original code.
# Acknowledgement: some of the code was adapted from ESPnet
# Copyright 2019 Nagoya University (Tomoki Hayashi)
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
import torch
import tor... | 16,660 | 33.281893 | 90 | py |
nnsvs | nnsvs-master/nnsvs/usfgan/__init__.py | import numpy as np
import torch
from nnsvs.usfgan.utils import SignalGenerator, dilated_factor
from torch import nn
class USFGANWrapper(nn.Module):
def __init__(self, config, generator):
super().__init__()
self.generator = generator
self.config = config
def inference(self, f0, aux_fea... | 2,281 | 33.575758 | 87 | py |
nnsvs | nnsvs-master/nnsvs/usfgan/models/discriminator.py | # -*- coding: utf-8 -*-
# Copyright 2022 Reo Yoneyama (Nagoya University)
# MIT License (https://opensource.org/licenses/MIT)
"""Discriminator modules.
References:
- https://github.com/bigpon/QPPWG
- https://github.com/jik876/hifi-gan
"""
import copy
from logging import getLogger
from tkinter import W
# ... | 33,567 | 33.218145 | 108 | py |
nnsvs | nnsvs-master/nnsvs/usfgan/models/generator.py | # -*- coding: utf-8 -*-
# Copyright 2022 Reo Yoneyama (Nagoya University)
# MIT License (https://opensource.org/licenses/MIT)
"""Unified Source-Filter GAN Generator modules."""
from logging import getLogger
import torch
import torch.nn as nn
from nnsvs.usfgan.layers import Conv1d1x1, ResidualBlocks, upsample
from ... | 18,402 | 32.766972 | 91 | py |
nnsvs | nnsvs-master/nnsvs/usfgan/layers/residual_block.py | # -*- coding: utf-8 -*-
# Copyright 2022 Reo Yoneyama (Nagoya University)
# MIT License (https://opensource.org/licenses/MIT)
"""Residual block modules.
References:
- https://github.com/bigpon/QPPWG
- https://github.com/kan-bayashi/ParallelWaveGAN
- https://github.com/r9y9/wavenet_vocoder
"""
import m... | 12,956 | 31.3925 | 91 | py |
nnsvs | nnsvs-master/nnsvs/usfgan/layers/cheaptrick.py | # -*- coding: utf-8 -*-
# Copyright 2022 Reo Yoneyama (Nagoya University)
# MIT License (https://opensource.org/licenses/MIT)
"""Spectral envelopes estimation module based on CheapTrick.
References:
- https://www.sciencedirect.com/science/article/pii/S0167639314000697
- https://github.com/mmorise/World
"""... | 7,834 | 30.849593 | 85 | py |
nnsvs | nnsvs-master/nnsvs/usfgan/layers/upsample.py | # -*- coding: utf-8 -*-
"""Upsampling module.
This code is modified from https://github.com/r9y9/wavenet_vocoder.
"""
import numpy as np
import torch
import torch.nn.functional as F
from nnsvs.usfgan.layers import Conv1d
class Stretch2d(torch.nn.Module):
"""Stretch2d module."""
def __init__(self, x_scale... | 6,484 | 32.25641 | 92 | py |
nnsvs | nnsvs-master/nnsvs/usfgan/utils/features.py | # -*- coding: utf-8 -*-
# Copyright 2022 Reo Yoneyama (Nagoya University)
# MIT License (https://opensource.org/licenses/MIT)
"""Feature-related functions.
References:
- https://github.com/bigpon/QPPWG
"""
import sys
from logging import getLogger
import numpy as np
import torch
from torch.nn.functional impor... | 5,103 | 27.198895 | 90 | py |
nnsvs | nnsvs-master/nnsvs/usfgan/utils/filters.py | # -*- coding: utf-8 -*-
# Copyright 2020 Yi-Chiao Wu (Nagoya University)
# based on a WaveNet script by Tomoki Hayashi (Nagoya University)
# (https://github.com/kan-bayashi/PytorchWaveNetVocoder)
# based on sprocket-vc script by Kazuhiro Kobayashi (Nagoya University)
# (https://github.com/k2kobayashi/sprocket)
# MIT ... | 1,509 | 24.166667 | 71 | py |
nnsvs | nnsvs-master/nnsvs/usfgan/utils/index.py | # -*- coding: utf-8 -*-
# Copyright 2020 Yi-Chiao Wu (Nagoya University)
# MIT License (https://opensource.org/licenses/MIT)
"""Indexing-related functions."""
import torch
from torch.nn import ConstantPad1d as pad1d
def pd_indexing(x, d, dilation, batch_index, ch_index):
"""Pitch-dependent indexing of past an... | 2,349 | 26.647059 | 68 | py |
nnsvs | nnsvs-master/nnsvs/transformer/encoder.py | # The code was adapted from https://github.com/jaywalnut310/vits
import torch
from torch import nn
from torch.nn import functional as F
from .attentions import MultiHeadAttention, convert_pad_shape
class LayerNorm(nn.Module):
def __init__(self, channels, eps=1e-5):
super().__init__()
self.channel... | 4,282 | 28.951049 | 78 | py |
nnsvs | nnsvs-master/nnsvs/transformer/attentions.py | # The code was adapted from https://github.com/jaywalnut310/vits
import math
import torch
from torch import nn
from torch.nn import functional as F
def convert_pad_shape(pad_shape):
ll = pad_shape[::-1]
pad_shape = [item for sublist in ll for item in sublist]
return pad_shape
def sequence_mask(length, ... | 8,150 | 36.911628 | 88 | py |
nnsvs | nnsvs-master/nnsvs/diffsinger/diffusion.py | from collections import deque
from functools import partial
import numpy as np
import torch
from nnsvs.base import BaseModel, PredictionType
from tqdm import tqdm
def extract(a, t, x_shape):
b, *_ = t.shape
out = a.gather(-1, t)
return out.reshape(b, *((1,) * (len(x_shape) - 1)))
def noise_like(shape, ... | 11,770 | 33.928783 | 91 | py |
nnsvs | nnsvs-master/nnsvs/diffsinger/fs2.py | import math
import torch
from nnsvs.base import BaseModel
from nnsvs.util import make_pad_mask
from torch import nn
from torch.nn import Parameter
from torch.nn import functional as F
def softmax(x, dim):
return F.softmax(x, dim=dim, dtype=torch.float32)
class PositionalEncoding(torch.nn.Module):
"""Positi... | 28,175 | 32.703349 | 93 | py |
nnsvs | nnsvs-master/nnsvs/diffsinger/pe.py | import math
import torch
from torch import nn
def denorm_f0(
f0,
uv,
pitch_padding=None,
min=None,
max=None,
pitch_norm="log",
use_uv=True,
f0_std=1.0,
f0_mean=0.0,
):
assert use_uv
if pitch_norm == "standard":
f0 = f0 * f0_std + f0_mean
elif pitch_norm == "lo... | 14,548 | 30.087607 | 87 | py |
nnsvs | nnsvs-master/nnsvs/diffsinger/denoiser.py | import math
from math import sqrt
import torch
import torch.nn as nn
import torch.nn.functional as F
class Mish(nn.Module):
def forward(self, x):
return x * torch.tanh(F.softplus(x))
class SinusoidalPosEmb(nn.Module):
def __init__(self, dim):
super().__init__()
self.dim = dim
d... | 3,818 | 29.552 | 86 | py |
ShapeMOD | ShapeMOD-main/SA_lang/sa_utils.py | import torch
import torch.nn as nn
import numpy as np
import tasks.ShapeAssembly as sa
from copy import deepcopy
MAX_CUBES = 10
PREC = 4
TRANS_NORM = 10.
SQUARE_THRESH = .1
def loadObj(infile):
tverts = []
ttris = []
with open(infile) as f:
for line in f:
ls = line.split()
... | 21,643 | 28.013405 | 133 | py |
ShapeMOD | ShapeMOD-main/SA_lang/parse_files/old_intersect.py | import torch
import itertools
import trimesh
import scipy
import numpy as np
import faiss
from copy import deepcopy
DOING_PARSE = True
DIM = 20
ATT_DIM = 50
device = torch.device("cuda")
resource = faiss.StandardGpuResources()
def robust_norm(var, dim=2):
return ((var ** 2).sum(dim=dim) + 1e-8).sqrt()
class c... | 31,198 | 31.163918 | 149 | py |
ShapeMOD | ShapeMOD-main/SA_lang/parse_files/symmetry.py | import torch
import numpy as np
import json_parse as jp
import old_intersect as inter
from copy import deepcopy
import math
SDIM_THRESH = .15
SANG_THRESH = .1
SPOS_THRESH = .1
VATT_THRESH = .05
CATT_THRESH = .3
GROUP_THRESH = .1
CPT_THRESH = .1
def smp_pt(geom, pt):
xdir = geom[6:9] / (geom[6:9].norm() + 1e-8)
... | 22,111 | 26.571072 | 153 | py |
ShapeMOD | ShapeMOD-main/SA_lang/parse_files/json_parse.py | import torch
import sys
import ast
import numpy as np
import random
import os
import pickle
import old_intersect as inter
import random
from copy import deepcopy
import networkx as nx
import symmetry as sym
VERBOSE = False
DO_SHORTEN = True
DO_SIMP_SYMMETRIES = True
DO_SQUEEZE = True
DO_VALID_CHECK = True
DO_NORM_AA... | 20,758 | 25.95974 | 100 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/infer_recon_metrics.py | from ShapeAssembly import hier_execute
import sa_utils as utils
import torch
import os
import sys
import math
import faiss
import numpy as np
from valid import check_stability, check_rooted
device = torch.device("cuda")
class SimpChamferLoss(torch.nn.Module):
def __init__(self, device):
super(SimpChamferL... | 8,389 | 30.660377 | 108 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/losses.py | import torch
import torch.nn as nn
import faiss
import numpy as np
import math
import generate as gen
import execute as ex
from copy import deepcopy
import json_parse as jp
def robust_norm(var, dim=2):
return ((var ** 2).sum(dim=dim) + 1e-8).sqrt()
class FScore():
def __init__(self):
self.dimension = ... | 20,155 | 33.811744 | 113 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/make_abs_data.py | import sys
sys.path.append("./dsls")
sys.path.append("../")
sys.path.append("../../")
from tqdm import tqdm
import torch
from ShapeMOD import DSL, Function, ProgNode, OrderedProg
import pickle
import re
import sa_utils as utils
import importlib
def clamp(v, a, b):
return min(max(v, a), b)
def make_function(name... | 15,809 | 29.057034 | 107 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/sem_valid.py | import torch, os, sys, random
import sa_utils as utils
import pickle
import model_prog as mp
from copy import deepcopy
from torch.distributions import Categorical
from make_abs_data import fillProgram, makeSALines, getCuboidDims
from ShapeAssembly import hier_execute, Program
import numpy as np
MAX_TRIES = 10
REJECT_... | 13,496 | 27.656051 | 99 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/pointnet_fd.py | from __future__ import print_function
import argparse
import os
import random
import torch
import torch.nn as nn
import torch.optim as optim
import torch.utils.data as data
from torch.autograd import Variable
import json
import torch.nn.functional as F
from tqdm import tqdm
import numpy as np
import pickle
from sa_util... | 10,819 | 32.190184 | 134 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/infer_sem_valid.py | import torch, os, sys, random
import sa_utils as utils
import pickle
import model_prog as mp
from copy import deepcopy
from torch.distributions import Categorical
from make_abs_data import fillProgram, makeSALines, getCuboidDims
from ShapeAssembly import hier_execute, Program
import numpy as np
MAX_TRIES = 50
BE = 1... | 13,859 | 27.401639 | 99 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/etw_pytorch_utils.py | # From https://github.com/erikwijmans
from __future__ import (
division,
absolute_import,
with_statement,
print_function,
unicode_literals,
)
import torch.nn as nn
import os
import torch
import torch.nn as nn
from torch.autograd.function import InplaceFunction
from itertools import repeat
import nu... | 28,499 | 27.904665 | 175 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/ShapeAssembly.py | # Taken from https://github.com/rkjones4/ShapeAssembly
import torch
import re
import numpy as np
import math
import ast
import sys
import faiss
from copy import deepcopy
"""
This file contains all of the logic in the ShapeAssembly DSL.
You can execute a ShapeAssembly program as follows:
> from ShapeAssembly i... | 52,690 | 30.875983 | 371 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/pc_encoder.py | import torch
import torch.nn as nn
from collections import namedtuple
import etw_pytorch_utils as pt_utils
from pointnet2.utils.pointnet2_modules import PointnetSAModule
class PCEncoder(nn.Module):
r"""
PointNet2 with single-scale grouping
Classification network
Parameters
---------... | 2,553 | 31.329114 | 112 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/infer_model_prog.py | import sys
sys.path.append("../")
sys.path.append("../../")
import os
import torch
import torch.nn as nn
import torch.nn.functional as F
from ShapeAssembly import Program, hier_execute, make_hier_prog, ShapeAssembly
import sa_utils as utils
import infer_recon_metrics
import argparse
import ast
import random
from torch.... | 53,175 | 34.450667 | 148 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/model_prog.py | import sys
sys.path.append("../")
sys.path.append("../../")
import os
import torch
import torch.nn as nn
import torch.nn.functional as F
from ShapeAssembly import Program, hier_execute, make_hier_prog, ShapeAssembly
import sa_utils as utils
import recon_metrics
import gen_metrics
import argparse
import ast
import rando... | 61,405 | 34.826138 | 167 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/recon_metrics.py | from ShapeAssembly import hier_execute
import sa_utils as utils
import torch
import os
import sys
import math
import faiss
import numpy as np
device = torch.device("cuda")
NUM_SAMPS = 10000
V_DIM = 64
CD_MULT = 500.
voxel_inds = ((np.indices((V_DIM, V_DIM, V_DIM)).T + .5) / (V_DIM//2)) -1.
flat_voxel_inds = torch.fro... | 9,981 | 30.488959 | 108 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/gen_metrics.py | from ShapeAssembly import hier_execute, ShapeAssembly, make_hier_prog
import sa_utils as utils
import torch
import os
import sys
from valid import check_stability, check_rooted
from pointnet_fd import get_fd
from recon_metrics import chamfer, CD_MULT
from tqdm import tqdm
import faiss
import numpy as np
NUM_SAMPS = 25... | 10,126 | 30.548287 | 111 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/valid.py | import argparse
from functools import reduce
import numpy as np
import os
import trimesh as tm
from trimesh.collision import CollisionManager
from trimesh.creation import box
import pickle
from tqdm import tqdm
import pybullet as p
import pybullet_data
from trimesh.util import concatenate as meshconcat
import xml.etree... | 11,194 | 35.825658 | 119 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/pointnet2/setup.py | from __future__ import division, absolute_import, with_statement, print_function
from setuptools import setup, find_packages
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
import glob
try:
import builtins
except:
import __builtin__ as builtins
builtins.__POINTNET2_SETUP__ = True
import po... | 1,175 | 28.4 | 83 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/pointnet2/utils/pointnet2_utils.py | from __future__ import (
division,
absolute_import,
with_statement,
print_function,
unicode_literals,
)
import torch
from torch.autograd import Function
import torch.nn as nn
import etw_pytorch_utils as pt_utils
import sys
try:
import builtins
except:
import __builtin__ as builtins
try:
... | 10,413 | 26.049351 | 103 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/pointnet2/utils/linalg_utils.py | from __future__ import (
division,
absolute_import,
with_statement,
print_function,
unicode_literals,
)
import torch
from enum import Enum
import numpy as np
PDist2Order = Enum("PDist2Order", "d_first d_second")
def pdist2(X, Z=None, order=PDist2Order.d_second):
# type: (torch.Tensor, torch.T... | 2,335 | 26.482353 | 83 | py |
ShapeMOD | ShapeMOD-main/SA_lang/tasks/pointnet2/utils/pointnet2_modules.py | from __future__ import (
division,
absolute_import,
with_statement,
print_function,
unicode_literals,
)
import torch
import torch.nn as nn
import torch.nn.functional as F
import etw_pytorch_utils as pt_utils
from pointnet2.utils import pointnet2_utils
if False:
# Workaround for type hints with... | 7,338 | 30.229787 | 106 | py |
LINDA_DSS | LINDA_DSS-master/learning.py |
# update for tensorflow
from __future__ import absolute_import, division, print_function, unicode_literals
import pandas as pd
import numpy as np
import seaborn as sns
import random as rn
import re
import warnings
import csv
import tensorflow as tf
# Force TensorFlow to single thread
# Multiple threads are a potenti... | 35,736 | 37.099147 | 177 | py |
LINDA_DSS | LINDA_DSS-master/Experiments/impact_of_Learning_algo/learning.py |
# update for tensorflow
from __future__ import absolute_import, division, print_function, unicode_literals
import pandas as pd
import numpy as np
import seaborn as sns
import random as rn
import re
import warnings
import csv
import tensorflow as tf
# Force TensorFlow to single thread
# Multiple threads are a potenti... | 33,430 | 37.783063 | 177 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/eval_wc.py |
from __future__ import print_function
import datetime
import time
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.optim as optim
import codecs
from model.crf import *
from model.lm_lstm_crf import *
import model.utils as utils
from model.evaluator import eval_wc
import argparse
impor... | 3,402 | 36.395604 | 307 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/train_wc.py | from __future__ import print_function
import datetime
import time
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.optim as optim
import codecs
from model.crf import *
from model.lm_lstm_crf import *
import model.utils as utils
from model.evaluator import eval_wc
import argparse
import... | 15,992 | 48.82243 | 297 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/seq_w.py | from __future__ import print_function
import datetime
import time
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.optim as optim
import codecs
from model.crf import *
from model.lstm_crf import *
import model.utils as utils
from model.predictor import predict_w
import argparse
import ... | 2,630 | 36.056338 | 201 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/train_w.py | from __future__ import print_function
import datetime
import time
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.optim as optim
import codecs
from model.crf import *
from model.lstm_crf import *
import model.utils as utils
from model.evaluator import eval_w
import argparse
import jso... | 14,299 | 45.278317 | 239 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/seq_wc.py | from __future__ import print_function
import datetime
import time
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.optim as optim
import codecs
from model.crf import *
from model.lm_lstm_crf import *
import model.utils as utils
from model.predictor import predict_wc
import argparse
imp... | 2,909 | 39.416667 | 307 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/eval_w.py |
from __future__ import print_function
import datetime
import time
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.optim as optim
import codecs
from model.crf import *
from model.lstm_crf import *
import model.utils as utils
from model.evaluator import eval_w
import argparse
import js... | 2,982 | 32.897727 | 141 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/docs/source/conf.py | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# LM-LSTM-CRF documentation build configuration file, created by
# sphinx-quickstart on Thu Sep 14 03:49:01 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
... | 5,569 | 29.773481 | 79 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/model/highway.py | """
.. module:: highway
:synopsis: highway network
.. moduleauthor:: Liyuan Liu
"""
import torch
import torch.nn as nn
import model.utils as utils
class hw(nn.Module):
"""Highway layers
args:
size: input and output dimension
dropout_ratio: dropout ratio
"""
def __init__(sel... | 1,607 | 24.52381 | 66 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/model/lm_lstm_crf.py | """
.. module:: lm_lstm_crf
:synopsis: lm_lstm_crf
.. moduleauthor:: Liyuan Liu
"""
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.optim as optim
import numpy as np
import model.crf as crf
import model.utils as utils
import model.highway as highway
class LM_LSTM_CRF(nn.Module):... | 10,117 | 38.678431 | 241 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/model/predictor.py | """
.. module:: predictor
:synopsis: prediction method (for un-annotated text)
.. moduleauthor:: Liyuan Liu
"""
import torch
import torch.autograd as autograd
import numpy as np
import itertools
import sys
from tqdm import tqdm
from model.crf import CRFDecode_vb
from model.utils import *
class predict:
"""... | 10,324 | 35.875 | 147 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/model/ner_dataset.py | """
.. module:: datasets
:synopsis: datasets
.. moduleauthor:: Liyuan Liu
"""
from torch.utils.data import Dataset
class CRFDataset(Dataset):
"""Dataset Class for word-level model
args:
data_tensor (ins_num, seq_length): words
label_tensor (ins_num, seq_length): labels
mask_... | 2,581 | 37.537313 | 211 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/model/utils.py | """
.. module:: utils
:synopsis: utility tools
.. moduleauthor:: Liyuan Liu, Frank Xu
"""
import codecs
import csv
import itertools
from functools import reduce
import numpy as np
import shutil
import torch
import json
import torch.nn as nn
import torch.nn.init
from model.ner_dataset import *
zip = getattr(it... | 29,437 | 34.424789 | 243 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/model/lstm_crf.py | """
.. module:: lstm_crf
:synopsis: lstm_crf
.. moduleauthor:: Liyuan Liu
"""
import torch
import torch.autograd as autograd
import torch.nn as nn
import model.crf as crf
import model.utils as utils
class LSTM_CRF(nn.Module):
"""LSTM_CRF model
args:
vocab_size: size of word dictionary
... | 3,738 | 30.420168 | 118 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/model/evaluator.py | """
.. module:: evaluator
:synopsis: evaluation method (f1 score and accuracy)
.. moduleauthor:: Liyuan Liu, Frank Xu
"""
import torch
import numpy as np
import itertools
import model.utils as utils
from torch.autograd import Variable
from model.crf import CRFDecode_vb
class eval_batch:
"""Base class for ... | 8,538 | 33.01992 | 144 | py |
LM-LSTM-CRF | LM-LSTM-CRF-master/model/crf.py | """
.. module:: crf
:synopsis: conditional random field
.. moduleauthor:: Liyuan Liu
"""
import torch
import torch.autograd as autograd
import torch.nn as nn
import torch.optim as optim
import torch.sparse as sparse
import model.utils as utils
class CRF_L(nn.Module):
"""Conditional Random Field (CRF) layer.... | 14,450 | 36.73107 | 287 | py |
MICRO | MICRO-main/codes/main.py | from datetime import datetime
import math
import os
import random
import sys
from time import time
from tqdm import tqdm
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torch.sparse as sparse
from utility.parser import parse_args
from Models imp... | 8,593 | 39.92381 | 158 | py |
MICRO | MICRO-main/codes/Models.py | import os
import numpy as np
from time import time
import torch
import torch.nn as nn
import torch.nn.functional as F
from utility.parser import parse_args
from utility.norm import build_sim, build_knn_normalized_graph
args = parse_args()
class MICRO(nn.Module):
def __init__(self, n_users, n_items, embedding_dim... | 11,458 | 46.156379 | 149 | py |
MICRO | MICRO-main/codes/utility/norm.py | import torch
def build_sim(context):
context_norm = context.div(torch.norm(context, p=2, dim=-1, keepdim=True))
sim = torch.mm(context_norm, context_norm.transpose(1, 0))
return sim
def build_knn_normalized_graph(adj, topk, is_sparse, norm_type):
device = adj.device
knn_val, knn_ind = torch.topk(a... | 2,279 | 40.454545 | 109 | py |
MICRO | MICRO-main/codes/utility/batch_test.py | import utility.metrics as metrics
from utility.parser import parse_args
from utility.load_data import Data
import multiprocessing
import heapq
import torch
import pickle
import numpy as np
from time import time
cores = multiprocessing.cpu_count() // 5
args = parse_args()
Ks = eval(args.Ks)
data_generator = Data(path... | 5,454 | 31.088235 | 108 | py |
reformer-pytorch | reformer-pytorch-master/setup.py | from setuptools import setup, find_packages
setup(
name = 'reformer_pytorch',
packages = find_packages(exclude=['examples', 'pretraining']),
version = '1.4.4',
license='MIT',
description = 'Reformer, the Efficient Transformer, Pytorch',
author = 'Phil Wang',
author_email = 'lucidrains@gmail.com',
url =... | 841 | 29.071429 | 70 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.