repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
nussl | nussl-master/nussl/evaluation/__init__.py | """
Evaluation
==========
Evaluation base
---------------
.. autoclass:: nussl.evaluation.EvaluationBase
:members:
:autosummary:
BSS Evaluation base
-------------------
.. autoclass:: nussl.evaluation.BSSEvaluationBase
:members:
:autosummary:
Scale invariant BSSEval
-----------------------
.. auto... | 1,058 | 18.611111 | 80 | py |
nussl | nussl-master/nussl/evaluation/precision_recall_fscore.py | import sklearn
import numpy as np
from . import EvaluationBase
from ..core.masks import BinaryMask
class PrecisionRecallFScore(EvaluationBase):
"""
This class provides common statistical metrics for determining how well a source separation algorithm in nussl was
able to create a binary mask compared to a... | 5,120 | 43.530435 | 121 | py |
nussl | nussl-master/nussl/evaluation/bss_eval.py | import numpy as np
import museval
from .evaluation_base import EvaluationBase
def _scale_bss_eval(references, estimate, idx, compute_sir_sar=True):
"""
Helper for scale_bss_eval to avoid infinite recursion loop.
"""
source = references[..., idx]
source_energy = (source ** 2).sum()
alpha = (
... | 13,449 | 39.757576 | 100 | py |
nussl | nussl-master/nussl/core/constants.py | """
A repository containing all of the constants frequently used in
this wacky, mixed up source separation stuff.
"""
import os
from collections import OrderedDict
from six.moves.urllib_parse import urljoin
import scipy.signal
__all__ = ['DEFAULT_SAMPLE_RATE', 'DEFAULT_WIN_LEN_PARAM', 'DEFAULT_BIT_DEPTH',
... | 4,474 | 41.619048 | 107 | py |
nussl | nussl-master/nussl/core/effects.py | """
The effect functions do not augment an AudioSignal object, but rather
return a FFmpegFilter or a SoXFilter, which may be called on either a sox.transform.Transformer
or a python-ffmpeg stream, depending on the specific effect. To apply the effect on an AudioSignal,
apply_effect_sox or apply_effect_ffmpeg must be ... | 29,754 | 40.673669 | 100 | py |
nussl | nussl-master/nussl/core/play_utils.py | """
These are optional utilities included in nussl that allow one to embed an AudioSignal
as a playable object in a Jupyter notebook, or to play audio from
the terminal.
"""
from copy import deepcopy
import subprocess
from tempfile import NamedTemporaryFile
import random, string
import importlib_resources as pkg_resou... | 5,338 | 33.895425 | 97 | py |
nussl | nussl-master/nussl/core/migration.py | import torch
import json
from .. import __version__, STFTParams
from ..separation.base import SeparationException
from ..datasets import transforms as tfm
from ..evaluation import BSSEvalV4, BSSEvalScale
class SafeModelLoader(object):
"""
Loads a nussl model and populates the metadata with defaults if
""... | 5,681 | 32.423529 | 86 | py |
nussl | nussl-master/nussl/core/mixing.py | """
Small collection of utilities for altering and remixing
AudioSignal objects.
"""
import copy
import numpy as np
from . import AudioSignal
def pan_audio_signal(audio_signal, angle_in_degrees):
"""
Pans an audio signal left or right by the desired number of degrees. This
returns a copy of the input a... | 3,428 | 33.989796 | 88 | py |
nussl | nussl-master/nussl/core/utils.py | """
Provides utilities for running nussl algorithms that do not belong to
any specific algorithm or that are shared between algorithms.
"""
import warnings
import numpy as np
import torch
import random
from .. import musdb
import librosa
from . import constants
import os
from contextlib import contextmanager
def se... | 23,707 | 36.27673 | 99 | py |
nussl | nussl-master/nussl/core/efz_utils.py | """
The *nussl* External File Zoo (EFZ) is a server that houses all files that are too large to
bundle with *nussl* when distributing it through ``pip`` or Github. These types of files include
audio examples, benchmark files for tests, and trained neural network models.
*nussl* has built-in utilities for accessing the... | 25,938 | 40.30414 | 159 | py |
nussl | nussl-master/nussl/core/audio_signal.py | import copy
import numbers
import os.path
import warnings
from collections import namedtuple
import audioread
import librosa
import numpy as np
import scipy.io.wavfile as wav
import scipy
from scipy.signal import check_COLA
import soundfile as sf
import pyloudnorm
from . import constants
from . import utils
from . im... | 99,390 | 39.767432 | 102 | py |
nussl | nussl-master/nussl/core/__init__.py | """
Core
====
AudioSignals
------------
.. autoclass:: nussl.core.AudioSignal
:members:
:autosummary:
Masks
-----
.. automodule:: nussl.core.masks
:members:
:autosummary:
Constants
------------
.. automodule:: nussl.core.constants
:members:
:autosummary:
External File Zoo
-----------------
.... | 1,293 | 15.175 | 49 | py |
nussl | nussl-master/nussl/core/masks/binary_mask.py | """
The :class:`BinaryMask` class is for creating a time-frequency mask with binary values. Like all
:class:`separation.masks.mask_base.MaskBase` objects, :class:`BinaryMask` is initialized with a 2D or 3D numpy array
containing the mask data. The data type (numpy.dtype) of the initial mask can be either bool, int, or... | 5,099 | 39.15748 | 121 | py |
nussl | nussl-master/nussl/core/masks/mask_base.py | """
Base class for Mask objects. Contains many common utilities used for accessing masks. The mask itself is
represented under the hood as a three dimensional numpy :obj:`ndarray` object. The dimensions are
``[NUM_FREQ, NUM_HOPS, NUM_CHAN]``. Safe accessors for these array indices are in :ref:`constants` as well as
b... | 6,907 | 28.521368 | 120 | py |
nussl | nussl-master/nussl/core/masks/soft_mask.py | """
The :class:`SoftMask` class is for creating a time-frequency mask with values in the range ``[0.0, 1.0]``. Like all
:class:`separation.masks.mask_base.MaskBase` objects, :class:`SoftMask` is initialized with a 2D or 3D numpy array
containing the mask data. The data type (numpy.dtype) of the initial mask must be fl... | 3,755 | 34.771429 | 121 | py |
nussl | nussl-master/nussl/core/masks/__init__.py | """
init for masks files
"""
from .mask_base import MaskBase
from .binary_mask import BinaryMask
from .soft_mask import SoftMask
__all__ = ['MaskBase', 'BinaryMask', 'SoftMask']
| 180 | 17.1 | 48 | py |
nussl | nussl-master/nussl/core/templates/__init__.py | 0 | 0 | 0 | py | |
nussl | nussl-master/nussl/separation/__init__.py | """
Separation algorithms
=====================
Base classes
------------
These classes are used to build every type of source separation
algorithm currently in nussl. They provide helpful utilities
and make it such that the end-user only has to implement
one or two functions to create a new separation algorithm,
dep... | 2,252 | 19.861111 | 63 | py |
nussl | nussl-master/nussl/separation/composite/ensemble_clustering.py | import numpy as np
from .. import ClusteringSeparationBase, SeparationException
class EnsembleClustering(ClusteringSeparationBase):
"""
Run multiple separation algorithms on a single mixture and concatenate their
masks to input into a clustering algorithm.
This algorithm allows you to combine th... | 8,085 | 39.43 | 97 | py |
nussl | nussl-master/nussl/separation/composite/overlap_add.py | from .. import SeparationBase
from ... import AudioSignal
import numpy as np
import tqdm
class OverlapAdd(SeparationBase):
def __init__(self, separation_object, window_duration=15, hop_duration=None, window_type='hanning',
find_permutation=False, verbose=False):
"""Apply overlap/add to a ... | 9,984 | 41.854077 | 108 | py |
nussl | nussl-master/nussl/separation/composite/__init__.py | """
Ensemble clustering
-------------------
.. autoclass:: nussl.separation.composite.EnsembleClustering
:autosummary:
.. autoclass:: nussl.separation.composite.OverlapAdd
:autosummary:
"""
from .ensemble_clustering import EnsembleClustering
from .overlap_add import OverlapAdd
| 289 | 19.714286 | 60 | py |
nussl | nussl-master/nussl/separation/primitive/melodia.py | import numpy as np
from scipy.ndimage.filters import convolve
from scipy.ndimage import maximum_filter, gaussian_filter
from .. import MaskSeparationBase, SeparationException
from ..benchmark import HighLowPassFilter
from ... import AudioSignal
from ... import vamp_imported
import numpy as np
import scipy.signal
if v... | 15,855 | 38.344913 | 97 | py |
nussl | nussl-master/nussl/separation/primitive/timbre.py | import numpy as np
import librosa
from ..base import ClusteringSeparationBase, NMFMixin
class TimbreClustering(ClusteringSeparationBase, NMFMixin):
"""
Implements separation by timbre via NMF with MFCC clustering. The
steps are:
1. Factorize the magnitude spectrogram of the mixture with NMF.
2. ... | 2,236 | 38.245614 | 86 | py |
nussl | nussl-master/nussl/separation/primitive/hpss.py | import numpy as np
import librosa
from .. import MaskSeparationBase
class HPSS(MaskSeparationBase):
"""
Implements harmonic/percussive source separation based on [1]. This is a
wrapper around the librosa implementation.
References:
[1] Fitzgerald, Derry. “Harmonic/percussive separation usi... | 2,404 | 32.873239 | 86 | py |
nussl | nussl-master/nussl/separation/primitive/repet_sim.py | import numpy as np
from .. import MaskSeparationBase
from ..benchmark import HighLowPassFilter
from ...core import utils
from ...core import constants
class RepetSim(MaskSeparationBase):
"""
Implements the REpeating Pattern Extraction Technique algorithm using
the Similarity Matrix (REPET-SIM).
REP... | 7,979 | 38.50495 | 106 | py |
nussl | nussl-master/nussl/separation/primitive/repet.py | import numpy as np
import scipy.fftpack as scifft
from .. import MaskSeparationBase, SeparationException
from ..benchmark import HighLowPassFilter
from ...core import constants
class Repet(MaskSeparationBase):
"""Implements the original REpeating Pattern Extraction Technique algorithm
using the beat spectru... | 11,564 | 38.20339 | 120 | py |
nussl | nussl-master/nussl/separation/primitive/__init__.py | """
Cluster sources by timbre
-------------------------
.. autoclass:: nussl.separation.primitive.TimbreClustering
:autosummary:
Foreground/background via 2DFT
------------------------------
.. autoclass:: nussl.separation.primitive.FT2D
:autosummary:
Harmonic/percussive separation
-------------------------... | 984 | 20.413043 | 58 | py |
nussl | nussl-master/nussl/separation/primitive/ft2d.py | import numpy as np
from scipy.ndimage.filters import maximum_filter, minimum_filter, uniform_filter
from .. import MaskSeparationBase, SeparationException
from ..benchmark import HighLowPassFilter
class FT2D(MaskSeparationBase):
"""
This separation method is based on using 2DFT image processing for source
... | 9,686 | 38.060484 | 96 | py |
nussl | nussl-master/nussl/separation/base/deep_mixin.py | import torch
import yaml
import json
from ...ml import SeparationModel
from ...datasets import transforms as tfm
OMITTED_TRANSFORMS = (
tfm.GetExcerpt,
tfm.MagnitudeWeights,
tfm.SumSources,
tfm.Cache,
tfm.IndexSources,
)
class DeepMixin:
def load_model(self, model_path, device='cpu'):
... | 5,490 | 33.753165 | 91 | py |
nussl | nussl-master/nussl/separation/base/mask_separation_base.py | """
Base class for separation algorithms that make masks. Most algorithms in
nussl are derived from MaskSeparationBase.
"""
from ...core import masks
from . import SeparationBase
from .separation_base import SeparationException
class MaskSeparationBase(SeparationBase):
"""
Base class for separation algorit... | 9,282 | 38.004202 | 106 | py |
nussl | nussl-master/nussl/separation/base/separation_base.py | import copy
import warnings
import numpy as np
from ... import AudioSignal, play_utils
class SeparationBase(object):
"""Base class for all separation algorithms in nussl.
Do not call this. It will not do anything.
Parameters:
input_audio_signal (AudioSignal). AudioSignal` object.
T... | 7,666 | 34.660465 | 122 | py |
nussl | nussl-master/nussl/separation/base/nmf_mixin.py | import numpy as np
from ... import ml
from ... import AudioSignal
class NMFMixin:
@staticmethod
def fit(audio_signals, n_components, beta_loss='frobenius',
l1_ratio=0.5, **kwargs):
"""
Fits an NMF model to the magnitude spectrograms of each
audio signal. If `audio_signals`... | 5,503 | 43.747967 | 93 | py |
nussl | nussl-master/nussl/separation/base/__init__.py | """
Base for all methods
--------------------
.. autoclass:: nussl.separation.SeparationBase
:members:
:autosummary:
Base for masking-based methods
------------------------------
.. autoclass:: nussl.separation.MaskSeparationBase
:members:
:autosummary:
Base for clustering-based methods
------------... | 944 | 20.477273 | 64 | py |
nussl | nussl-master/nussl/separation/base/clustering_separation_base.py | import numpy as np
from ... import ml
from . import SeparationException, MaskSeparationBase
ALLOWED_CLUSTERING_TYPES = ['KMeans', 'GaussianMixture', 'MiniBatchKMeans']
class ClusteringSeparationBase(MaskSeparationBase):
"""
A base class for any clustering-based separation approach. Subclasses
of this ... | 9,170 | 42.056338 | 97 | py |
nussl | nussl-master/nussl/separation/spatial/duet.py | import numpy as np
from scipy import signal
from .. import MaskSeparationBase
from ...core import utils
from ...core import constants
class Duet(MaskSeparationBase):
"""
The DUET algorithm was originally proposed by S.Rickard and F.Dietrich for DOA
estimation and further developed for BSS and demixing b... | 17,163 | 43.123393 | 119 | py |
nussl | nussl-master/nussl/separation/spatial/spatial_clustering.py | import numpy as np
from ..base import ClusteringSeparationBase
class SpatialClustering(ClusteringSeparationBase):
"""
Implements clustering on IPD/ILD features between the first two channels.
IPD/ILD features are inter-phase difference and inter-level difference
features. Sounds coming from differen... | 878 | 30.392857 | 77 | py |
nussl | nussl-master/nussl/separation/spatial/projet.py | import copy
import numpy as np
import torch
from .. import SeparationBase, SeparationException
from ... import AudioSignal
class Projet(SeparationBase):
"""
Implements the PROJET algorithm for spatial audio separation using projections.
This implementation uses PyTorch to speed up computation considerab... | 11,377 | 37.181208 | 99 | py |
nussl | nussl-master/nussl/separation/spatial/__init__.py | """
Cluster by inter-phase and inter-level difference
-------------------------------------------------
.. autoclass:: nussl.separation.spatial.SpatialClustering
:autosummary:
PROJET: Separate via spatial projections
-------------------------------------------------
.. autoclass:: nussl.separation.spatial.Projet... | 520 | 19.84 | 57 | py |
nussl | nussl-master/nussl/separation/deep/deep_mask_estimation.py | import torch
from ..base import MaskSeparationBase, DeepMixin, SeparationException
from ... import ml
class DeepMaskEstimation(DeepMixin, MaskSeparationBase):
"""
Separates an audio signal using the masks produced by a deep model for every
time-frequency point. It expects that the model outputs a dictio... | 4,119 | 42.829787 | 91 | py |
nussl | nussl-master/nussl/separation/deep/deep_audio_estimation.py | import torch
from ..base import SeparationBase, DeepMixin, SeparationException
class DeepAudioEstimation(DeepMixin, SeparationBase):
"""
Separates an audio signal using a model that produces separated sources directly
in the waveform domain. It expects that the model outputs a dictionary where one
of ... | 2,455 | 39.933333 | 86 | py |
nussl | nussl-master/nussl/separation/deep/deep_clustering.py | import torch
from ..base import ClusteringSeparationBase, DeepMixin, SeparationException
class DeepClustering(DeepMixin, ClusteringSeparationBase):
"""
Clusters the embedding produced by a deep model for every time-frequency point.
This is the deep clustering source separation approach. It is flexible wi... | 2,524 | 44.089286 | 86 | py |
nussl | nussl-master/nussl/separation/deep/__init__.py | """
Deep clustering
---------------
.. autoclass:: nussl.separation.deep.DeepClustering
:autosummary:
Deep mask estimation
--------------------
.. autoclass:: nussl.separation.deep.DeepMaskEstimation
:autosummary:
Deep audio estimation
---------------------
.. autoclass:: nussl.separation.deep.DeepAudioEst... | 504 | 19.2 | 56 | py |
nussl | nussl-master/nussl/separation/benchmark/ideal_ratio_mask.py | from ..base import MaskSeparationBase, SeparationException
from ...datasets import transforms
class IdealRatioMask(MaskSeparationBase):
"""
Implements an ideal ratio mask (IRM) that is computed by using the known
ground truth performance. This is one of the upper baselines.
Args:
input_au... | 2,379 | 36.777778 | 86 | py |
nussl | nussl-master/nussl/separation/benchmark/mix_as_estimate.py | from ..base import SeparationBase
class MixAsEstimate(SeparationBase):
"""
This algorithm does nothing but scale the mix by the number of sources. This can
be used to compute the improvement metrics (e.g. improvement in SDR over using the
mixture as the estimate).
Args:
input_audio_sig... | 799 | 28.62963 | 86 | py |
nussl | nussl-master/nussl/separation/benchmark/__init__.py | """
High pass filter
----------------
.. autoclass:: nussl.separation.benchmark.HighLowPassFilter
:autosummary:
Ideal binary mask
-----------------
.. autoclass:: nussl.separation.benchmark.IdealBinaryMask
:autosummary:
Ideal ratio mask
----------------
.. autoclass:: nussl.separation.benchmark.IdealRatioM... | 786 | 19.179487 | 59 | py |
nussl | nussl-master/nussl/separation/benchmark/ideal_binary_mask.py | from ..base import MaskSeparationBase, SeparationException
from ...datasets import transforms
class IdealBinaryMask(MaskSeparationBase):
"""
Implements an ideal binary mask (IBM) that is computed by using the known
ground truth performance. This is one of the upper baselines.
Args:
input_... | 1,525 | 32.173913 | 84 | py |
nussl | nussl-master/nussl/separation/benchmark/wiener_filter.py | import numpy as np
import norbert
from ..base import MaskSeparationBase, SeparationException
class WienerFilter(MaskSeparationBase):
"""
Implements a multichannel Wiener filter that is computed by using some
source estimates. When using the estimates produced by IdealRatioMask or
IdealBinaryMask, th... | 2,279 | 37.644068 | 88 | py |
nussl | nussl-master/nussl/separation/benchmark/high_low_pass_filter.py | import numpy as np
from .. import MaskSeparationBase
class HighLowPassFilter(MaskSeparationBase):
"""
Implements a super simple separation algorithm that just masks everything below
the specified hz. It does this by zeroing out the associated FFT bins via a mask to
produce the "high" source, and the ... | 1,314 | 36.571429 | 87 | py |
nussl | nussl-master/nussl/separation/factorization/ica.py | import copy
import numpy as np
import sklearn
from .. import SeparationBase
from ... import AudioSignal
from ...core import utils
class ICA(SeparationBase):
"""
Separate sources using the Independent Component Analysis, given
observations of the audio scene. nussl's ICA is a wrapper for sci-kit learn's... | 3,485 | 33.176471 | 118 | py |
nussl | nussl-master/nussl/separation/factorization/rpca.py | import numpy as np
from .. import MaskSeparationBase
from ..benchmark import HighLowPassFilter
class RPCA(MaskSeparationBase):
"""
Implements foreground/background separation using RPCA.
Huang, Po-Sen, et al. "Singing-voice separation from monaural recordings using
robust principal component analys... | 5,327 | 38.761194 | 97 | py |
nussl | nussl-master/nussl/separation/factorization/__init__.py | """
Robust principle component analysis
-----------------------------------
.. autoclass:: nussl.separation.factorization.RPCA
:autosummary:
Independent component analysis
------------------------------
.. autoclass:: nussl.separation.factorization.ICA
:autosummary:
"""
from .rpca import RPCA
from .ica imp... | 328 | 17.277778 | 50 | py |
nussl | nussl-master/nussl/datasets/hooks.py | """
While *nussl* does not come with any data sets, it does have the capability to interface with
many common source separation data sets used within the MIR and speech separation communities.
These data set "hooks" subclass BaseDataset and by default return AudioSignal objects in
labeled dictionaries for ease of use. ... | 21,028 | 37.304189 | 94 | py |
nussl | nussl-master/nussl/datasets/base_dataset.py | import warnings
from typing import Iterable
import copy
from torch.utils.data import Dataset
from .. import AudioSignal
from . import transforms as tfm
import tqdm
class BaseDataset(Dataset, Iterable):
"""
The BaseDataset class is the starting point for all dataset hooks
in nussl. To subclass BaseDatase... | 14,293 | 38.927374 | 90 | py |
nussl | nussl-master/nussl/datasets/__init__.py | """
Datasets
========
Base class
----------
.. autoclass:: nussl.datasets.BaseDataset
:members:
:autosummary:
MUSDB18
-------
.. autoclass:: nussl.datasets.MUSDB18
:members:
:autosummary:
WHAM
----
.. autoclass:: nussl.datasets.WHAM
:members:
:autosummary:
FUSS
----
.. autoclass:: nussl.data... | 930 | 13.323077 | 45 | py |
nussl | nussl-master/nussl/datasets/transforms.py | import os
import shutil
import logging
import random
from collections import OrderedDict
import torch
import zarr
import numcodecs
import numpy as np
from sklearn.preprocessing import OneHotEncoder
from .. import utils
# This is for when you're running multiple
# training threads
if hasattr(numcodecs, 'blosc'):
... | 30,671 | 36.496333 | 94 | py |
nussl | nussl-master/nussl/ml/cluster.py | from sklearn.mixture import GaussianMixture
from sklearn.cluster import KMeans, MiniBatchKMeans
| 96 | 31.333333 | 51 | py |
nussl | nussl-master/nussl/ml/__init__.py | """
Machine Learning
================
SeparationModel
---------------
.. autoclass:: nussl.ml.SeparationModel
:members:
:autosummary:
Building blocks for SeparationModel
-----------------------------------
.. automodule:: nussl.ml.modules
:members:
:autosummary:
.. automodule:: nussl.ml.cluster
... | 2,207 | 20.647059 | 81 | py |
nussl | nussl-master/nussl/ml/confidence.py | """
There are ways to measure the quality of a separated source without
requiring ground truth. These functions operate on the output of
clustering-based separation algorithms and work by analyzing
the clusterability of the feature space used to generate the
separated sources.
"""
from sklearn.metrics import silhouett... | 14,964 | 42.502907 | 89 | py |
nussl | nussl-master/nussl/ml/networks/separation_model.py | import os
import json
import inspect
import torch
from torch import nn
import numpy as np
from . import modules
from ... import __version__
import copy
def _remove_cache_from_tfms(transforms):
"""Helper function to remove cache from transforms.
"""
from ... import datasets
transforms = copy.deepcopy(... | 12,448 | 36.954268 | 92 | py |
nussl | nussl-master/nussl/ml/networks/builders.py | """
Functions that make it easy to build commonly used source separation architectures.
Currently contains mask inference, deep clustering, and chimera networks that are
based on recurrent neural networks. These functions are a good place to start when
creating your own network toplogies. Since there can be dependencie... | 28,349 | 36.951807 | 102 | py |
nussl | nussl-master/nussl/ml/networks/__init__.py | from .separation_model import SeparationModel
from . import builders
| 69 | 22.333333 | 45 | py |
nussl | nussl-master/nussl/ml/networks/modules/filter_bank.py | import nussl
from torch import nn
import torch
from .... import AudioSignal
class FilterBank(nn.Module):
"""
Base class for implementing short-time filter-bank style transformations
of an audio signal.
This class accepts two different tensors, as there are two modes it can
be called in:
... | 12,694 | 36.670623 | 81 | py |
nussl | nussl-master/nussl/ml/networks/modules/__init__.py | from ...unfold import GaussianMixtureTorch
from .filter_bank import FilterBank, STFT, LearnedFilterBank
from .blocks import (
AmplitudeToDB,
Alias,
ShiftAndScale,
BatchNorm,
InstanceNorm,
GroupNorm,
LayerNorm,
MelProjection,
Embedding,
Mask,
Split,
Expand,
Concatenat... | 404 | 17.409091 | 60 | py |
nussl | nussl-master/nussl/ml/networks/modules/blocks.py | import warnings
import torch
import torch.nn as nn
import librosa
import numpy as np
from torch.utils.checkpoint import checkpoint
class AmplitudeToDB(nn.Module):
"""
Takes a magnitude spectrogram and converts it to a log
amplitude spectrogram in decibels.
Args:
data (torch.Tensor): Magni... | 34,373 | 38.239726 | 116 | py |
nussl | nussl-master/nussl/ml/unfold/gaussian_mixture.py | import torch
import torch.nn as nn
import numpy as np
import gpytorch
class GaussianMixtureTorch(nn.Module):
def __init__(self, n_components, n_iter=5, covariance_type='diag',
covariance_init=1.0, reg_covar=1e-4):
"""
Initializes a Gaussian mixture model with n_clusters.
... | 7,016 | 36.524064 | 92 | py |
nussl | nussl-master/nussl/ml/unfold/__init__.py | """
Deep unfolding is a type of architecture where an optimization
process like clustering, non-negative matrix factorization and
other EM style algorithms (anything with update functions) are
unfolded as layers in a neural network. In practice this results
in having the operations available to do on torch Tensors. Thi... | 492 | 40.083333 | 69 | py |
nussl | nussl-master/nussl/ml/train/loss.py | from itertools import permutations, combinations
import torch
import torch.nn as nn
class L1Loss(nn.L1Loss):
DEFAULT_KEYS = {'estimates': 'input', 'source_magnitudes': 'target'}
class MSELoss(nn.MSELoss):
DEFAULT_KEYS = {'estimates': 'input', 'source_magnitudes': 'target'}
class KLDivLoss(nn.KLDivLoss):
... | 10,749 | 35.815068 | 84 | py |
nussl | nussl-master/nussl/ml/train/__init__.py | """
Training
--------
.. autofunction:: nussl.ml.train.create_train_and_validation_engines
.. autofunction:: nussl.ml.train.add_tensorboard_handler
.. autofunction:: nussl.ml.train.cache_dataset
.. autofunction:: nussl.ml.train.add_validate_and_checkpoint
.. autofunction:: nussl.ml.train.add_stdout_handler
.. aut... | 1,059 | 17.928571 | 68 | py |
nussl | nussl-master/nussl/ml/train/trainer.py | import os
import logging
import copy
import time
from datetime import timedelta
from ignite.engine import Events, Engine, EventEnum
from ignite.handlers import Timer
from ignite.contrib.handlers import ProgressBar
from ignite.metrics import RunningAverage
from torch.utils.tensorboard import SummaryWriter
import torch
... | 13,287 | 36.325843 | 91 | py |
nussl | nussl-master/nussl/ml/train/closures.py | import copy
import torch
from . import loss
from .trainer import BackwardsEvents
class Closure(object):
"""
Closures are used with ignite Engines to train a model given an optimizer
and a set of loss functions. Closures perform forward passes of models given
the input data. The loss is computed vi... | 10,220 | 36.577206 | 104 | py |
nussl | nussl-master/recipes/hashes/get_hashes.py | from nussl import efz_utils
import json
with open('musdb_hashes.json', 'w') as f:
hashes = {}
hash_ = efz_utils._hash_directory('/home/data/musdb/raw/musdb_unzip')
hashes['musdb'] = hash_
json.dump(hashes, f, indent=4)
with open('wham_hashes.json', 'w') as f:
hashes = {}
wav8k_hash = efz_utils... | 556 | 26.85 | 73 | py |
nussl | nussl-master/recipes/wham/chimera.py | """
This recipe trains and evaluates a mask inference model
on the clean data from the WHAM dataset with 8k. It's divided into
three big chunks: data preparation, training, and evaluation.
Final output of this script:
"""
import nussl
from nussl import ml, datasets, utils, separation, evaluation
import os
import torch... | 7,122 | 35.716495 | 90 | py |
nussl | nussl-master/recipes/wham/evaluate_dpcl.py | """
This recipe trains and evaluates a deep clustering model
on the clean data from the WHAM dataset with 8k. It's divided into
three big chunks: data preparation, training, and evaluation.
Final output of this script:
┌───────────────────┬────────────────────┬────────────────────┐
│ │ OVERALL (N = ... | 3,803 | 32.368421 | 90 | py |
nussl | nussl-master/recipes/wham/ideal_ratio_mask.py | """
This recipe evaluates an oracle ideal ratio mask on the mix_clean
and min subset in the WHAM dataset using phase sensitive spectrum
approximation. Output of this script for psa:
┌────────────────────┬────────────────────┬────────────────────┐
│ │ OVERALL (N = 6000) │ │
╞════... | 3,223 | 34.428571 | 90 | py |
nussl | nussl-master/recipes/wham/deep_clustering.py | """
This recipe trains and evaluates a deep clustering model
on the clean data from the WHAM dataset with 8k. It's divided into
three big chunks: data preparation, training, and evaluation.
Final output of this script:
┌───────────────────┬────────────────────┬────────────────────┐
│ │ OVERALL (N = ... | 7,718 | 35.239437 | 93 | py |
nussl | nussl-master/recipes/wham/ideal_binary_mask.py | """
This recipe evaluates an oracle ideal binary mask on the mix_clean
and min subset in the WHAM dataset. Output of this script:
┌───────────────────┬────────────────────┬───────────────────┐
│ │ OVERALL (N = 6000) │ │
╞═══════════════════╪════════════════════╪═══════════════════╡... | 2,408 | 32.458333 | 90 | py |
nussl | nussl-master/recipes/wham/mask_inference.py | """
This recipe trains and evaluates a mask infeerence model
on the clean data from the WHAM dataset with 8k. It's divided into
three big chunks: data preparation, training, and evaluation.
Final output of this script:
┌────────────────────┬────────────────────┬───────────────────┐
│ │ OVERALL (N... | 7,759 | 35.093023 | 89 | py |
nussl | nussl-master/tests/conftest.py | import pytest
from nussl import efz_utils
import tempfile
import os
import musdb
import zipfile
import scaper
import random
import glob
import nussl
from nussl.datasets import transforms
from nussl import datasets
import numpy as np
import torch
import json
def _unzip(path_to_zip, target_path):
with zipfile.ZipFi... | 8,129 | 30.511628 | 74 | py |
nussl | nussl-master/tests/__init__.py | 0 | 0 | 0 | py | |
nussl | nussl-master/tests/evaluation/test_evaluation.py | import nussl
import pytest
from nussl.core.masks import SoftMask, BinaryMask
import numpy as np
from nussl.evaluation.evaluation_base import AudioSignalListMismatchError
import torch
import json
import tempfile
import os
import glob
@pytest.fixture(scope='module')
def estimated_and_true_sources(musdb_tracks):
i =... | 16,758 | 33.412731 | 84 | py |
nussl | nussl-master/tests/core/test_stft.py | import nussl
import scipy.io.wavfile as wav
import pytest
import numpy as np
import tempfile
import librosa
from nussl.core.audio_signal import AudioSignalException, STFTParams
from nussl.core.constants import ALL_WINDOWS
from nussl import AudioSignal
from scipy.signal import check_COLA
import copy
import itertools
sr... | 7,909 | 30.141732 | 90 | py |
nussl | nussl-master/tests/core/test_migration.py | import nussl
import pytest
import numpy as np
from nussl.separation.base import SeparationException
from nussl.core.migration import SafeModelLoader
from copy import deepcopy
import nussl.datasets.transforms as nussl_tfm
fix_dir = 'tests/local/trainer'
def test_safe_model_loader():
safe_loader = SafeModelLoader()... | 1,440 | 35.025 | 104 | py |
nussl | nussl-master/tests/core/test_effects.py | from copy import deepcopy
import numpy as np
import nussl.core.effects as effects
from nussl.core.audio_signal import AudioSignalException
import os
import os.path as path
import pytest
REGRESSION_PATH = "tests/core/regression/effects"
os.makedirs(REGRESSION_PATH, exist_ok=True)
# Note: When changing these tests, ple... | 16,955 | 31.42065 | 100 | py |
nussl | nussl-master/tests/core/test_mixing.py | import nussl
import numpy as np
import pytest
def test_pan_audio_signal(mix_and_sources):
mix, sources = mix_and_sources
sources = list(sources.values())
panned_audio = nussl.mixing.pan_audio_signal(sources[0], -45)
zeros = np.zeros_like(panned_audio.audio_data[0])
sum_ch = np.sum(panned_audio.a... | 1,683 | 33.367347 | 81 | py |
nussl | nussl-master/tests/core/test_audio_signal.py | import nussl
import scipy.io.wavfile as wav
import pytest
import numpy as np
import tempfile
import librosa
from nussl.core.audio_signal import AudioSignalException
import copy
sr = nussl.constants.DEFAULT_SAMPLE_RATE
dur = 3 # seconds
length = dur * sr
def test_load(benchmark_audio):
# Load from file
a = n... | 17,740 | 32.160748 | 101 | py |
nussl | nussl-master/tests/core/test_masks.py | import nussl
import pytest
import numpy as np
from nussl.core.audio_signal import AudioSignalException
from nussl.core.masks import BinaryMask, SoftMask, MaskBase
from copy import deepcopy
sr = nussl.constants.DEFAULT_SAMPLE_RATE
dur = 3 # seconds
length = dur * sr
stft_tol = 1e-6
def test_apply_mask(benchmark_audi... | 6,025 | 29.281407 | 79 | py |
nussl | nussl-master/tests/core/test_play_utils.py | import sys
import builtins
import nussl
import os
import numpy as np
import pytest
import importlib
def test_jupyter_embed_audio(benchmark_audio):
for key, path in benchmark_audio.items():
s1 = nussl.AudioSignal(path)
audio_element = nussl.play_utils.embed_audio(s1)
assert os.path.splitext... | 3,456 | 29.866071 | 79 | py |
nussl | nussl-master/tests/core/test_efz_utils.py | import nussl
import os
import tempfile
import pytest
from nussl.core.efz_utils import (
NoConnectivityError, FailedDownloadError,
MismatchedHashError, MetadataError
)
from nussl.core import constants
from random import shuffle
import numpy as np
from six.moves.urllib_parse import urljoin
def get_smallest_file... | 4,165 | 35.226087 | 87 | py |
nussl | nussl-master/tests/core/test_utils.py | import nussl
import numpy as np
from nussl.separation.base import MaskSeparationBase, SeparationBase
from nussl.core.masks import BinaryMask, SoftMask, MaskBase
import pytest
import torch
import random
import matplotlib.pyplot as plt
import os
import tempfile
def test_utils_seed():
seeds = [0, 123, 666, 15, 2]
... | 10,429 | 29.408163 | 88 | py |
nussl | nussl-master/tests/separation/test_composite.py | from nussl.separation.base.separation_base import SeparationBase
import pytest
from nussl.separation import (
primitive,
factorization,
composite,
SeparationException
)
import numpy as np
import os
import nussl
import copy
import random
REGRESSION_PATH = 'tests/separation/regression/composite/'
os.make... | 6,068 | 30.123077 | 91 | py |
nussl | nussl-master/tests/separation/test_nmf.py | from nussl.separation.base import NMFMixin
from nussl import datasets, ml, separation, evaluation
import nussl
import pytest
import numpy as np
import os
import copy
REGRESSION_PATH = 'tests/separation/regression/nmf/'
os.makedirs(REGRESSION_PATH, exist_ok=True)
def test_nmf_mixin(
drum_and_vocals,
c... | 1,615 | 24.650794 | 62 | py |
nussl | nussl-master/tests/separation/test_factorization.py | import pytest
from nussl.separation import factorization, SeparationException
import numpy as np
import os
import nussl
import copy
REGRESSION_PATH = 'tests/separation/regression/factorization/'
os.makedirs(REGRESSION_PATH, exist_ok=True)
def test_rpca(
music_mix_and_sources,
check_against_regression... | 2,582 | 26.478723 | 72 | py |
nussl | nussl-master/tests/separation/test_deep.py | from nussl.separation.base import DeepMixin, SeparationException
from nussl.separation.base.deep_mixin import OMITTED_TRANSFORMS
from nussl import datasets, ml, separation, evaluation
import nussl
import torch
from torch import optim
import tempfile
import pytest
import os
import numpy as np
fix_dir = 'tests/local/tra... | 9,458 | 32.661922 | 96 | py |
nussl | nussl-master/tests/separation/test_spatial.py | import pytest
import nussl
from nussl.separation import SeparationException
import numpy as np
import os
REGRESSION_PATH = 'tests/separation/regression/spatial/'
os.makedirs(REGRESSION_PATH, exist_ok=True)
def test_spatial_clustering(mix_and_sources, check_against_regression_data):
nussl.utils.seed(0)
mix, s... | 4,142 | 30.869231 | 76 | py |
nussl | nussl-master/tests/separation/test_separation_base.py | from nussl import separation, datasets, AudioSignal, core, evaluation
import pytest
import numpy as np
from nussl.separation.base import SeparationException
def test_separation_base(mix_source_folder, monkeypatch):
dataset = datasets.MixSourceFolder(mix_source_folder)
item = dataset[0]
mix = item['mix']
... | 8,316 | 32.946939 | 89 | py |
nussl | nussl-master/tests/separation/test_primitive.py | import pytest
from nussl.separation import primitive, SeparationException
import numpy as np
import os
import nussl
import copy
from importlib import reload
REGRESSION_PATH = 'tests/separation/regression/primitive/'
os.makedirs(REGRESSION_PATH, exist_ok=True)
def test_timbre_clustering(
drum_and_vocals,
che... | 5,680 | 26.985222 | 78 | py |
nussl | nussl-master/tests/separation/test_benchmark.py | import nussl
from nussl.separation import SeparationException
import pytest
import os
import json
REGRESSION_PATH = 'tests/separation/regression/benchmark/'
os.makedirs(REGRESSION_PATH, exist_ok=True)
def test_high_low_pass(
music_mix_and_sources,
check_against_regression_data
):
mix, sources = m... | 4,093 | 29.781955 | 85 | py |
nussl | nussl-master/tests/datasets/test_hooks.py | import pytest
import nussl
from nussl.core import constants
import os
import numpy as np
from nussl.datasets.base_dataset import DataSetException
from nussl.datasets import transforms
import tempfile
import shutil
def test_dataset_hook_musdb18(musdb_tracks):
dataset = nussl.datasets.MUSDB18(
folder=musdb_... | 7,177 | 35.252525 | 90 | py |
nussl | nussl-master/tests/datasets/test_base_dataset.py | import pytest
from nussl.datasets import BaseDataset, transforms
from nussl.datasets.base_dataset import DataSetException
import nussl
from nussl import STFTParams
import numpy as np
import soundfile as sf
import itertools
import tempfile
import os
import torch
class BadTransform(object):
def __init__(self, fake=... | 10,049 | 30.40625 | 88 | py |
nussl | nussl-master/tests/datasets/test_transforms.py | import pytest
from nussl.datasets import transforms
from nussl.datasets.transforms import TransformException
import nussl
from nussl import STFTParams, evaluation
import numpy as np
from nussl.core.masks import BinaryMask, SoftMask
import itertools
import copy
import torch
import tempfile
import os
stft_tol = 1e-6
d... | 13,537 | 28.239741 | 79 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.