Skip to content

Commit

Permalink
Pure isort formatting.
Browse files Browse the repository at this point in the history
Signed-off-by: Stanislav Beliaev <[email protected]>
  • Loading branch information
stasbel committed Jan 23, 2020
1 parent b4dad8b commit caddc35
Show file tree
Hide file tree
Showing 147 changed files with 407 additions and 365 deletions.
2 changes: 1 addition & 1 deletion collections/nemo_asr/nemo_asr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
TranscriptDataLayer,
)
from .greedy_ctc_decoder import GreedyCTCDecoder
from .jasper import JasperEncoder, JasperDecoderForCTC
from .jasper import JasperDecoderForCTC, JasperEncoder
from .las.misc import JasperRNNConnector
from .losses import CTCLossNM

Expand Down
15 changes: 8 additions & 7 deletions collections/nemo_asr/nemo_asr/audio_preprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@
'SpectrogramAugmentation',
]

from abc import abstractmethod
import math
import warnings
from abc import abstractmethod

import torch

from nemo.backends.pytorch import NonTrainableNM
from nemo.core import Optimization
from nemo.core.neural_types import *

from .parts.features import FilterbankFeatures
from .parts.spectr_augment import SpecAugment, SpecCutout

try:
import torchaudio

Expand All @@ -45,12 +52,6 @@
"will not work."
)

from nemo.backends.pytorch import NonTrainableNM
from nemo.core import Optimization
from nemo.core.neural_types import *
from .parts.features import FilterbankFeatures
from .parts.spectr_augment import SpecAugment, SpecCutout


class AudioPreprocessor(NonTrainableNM):
"""
Expand Down
4 changes: 2 additions & 2 deletions collections/nemo_asr/nemo_asr/beam_search_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from nemo.backends.pytorch.nm import NonTrainableNM
from nemo.core import DeviceType
from nemo.core.neural_types import (
NeuralType,
AxisType,
BatchTag,
TimeTag,
ChannelTag,
NeuralType,
TimeTag,
)


Expand Down
2 changes: 1 addition & 1 deletion collections/nemo_asr/nemo_asr/data_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@

from .parts.dataset import (
AudioDataset,
seq_collate_fn,
KaldiFeatureDataset,
TranscriptDataset,
seq_collate_fn,
)
from .parts.features import WaveformFeaturizer

Expand Down
4 changes: 2 additions & 2 deletions collections/nemo_asr/nemo_asr/greedy_ctc_decoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

from nemo.backends.pytorch.nm import TrainableNM
from nemo.core.neural_types import (
NeuralType,
AxisType,
BatchTag,
TimeTag,
ChannelTag,
NeuralType,
TimeTag,
)


Expand Down
1 change: 1 addition & 0 deletions collections/nemo_asr/nemo_asr/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Copyright (c) 2019 NVIDIA Corporation

import torch

import nemo

from .metrics import word_error_rate
Expand Down
15 changes: 8 additions & 7 deletions collections/nemo_asr/nemo_asr/jasper.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# Copyright (c) 2019 NVIDIA Corporation
from typing import Optional

import torch
import torch.nn as nn
import torch.nn.functional as F
from typing import Optional

from nemo.backends.pytorch.nm import TrainableNM
from nemo.core.neural_types import (
NeuralType,
AxisType,
ChannelTag,
BatchTag,
TimeTag,
SpectrogramSignalTag,
ProcessedTimeTag,
ChannelTag,
EncodedRepresentationTag,
NeuralType,
ProcessedTimeTag,
SpectrogramSignalTag,
TimeTag,
)

from .parts.jasper import JasperBlock, jasper_activations, init_weights
from .parts.jasper import JasperBlock, init_weights, jasper_activations


class JasperEncoder(TrainableNM):
Expand Down
2 changes: 1 addition & 1 deletion collections/nemo_asr/nemo_asr/las/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from pprint import pformat

import torch

import nemo
from nemo.backends.pytorch.common.metrics import char_lm_metrics

from nemo_asr.metrics import word_error_rate

ENG_MWN = 5.3
Expand Down
4 changes: 2 additions & 2 deletions collections/nemo_asr/nemo_asr/las/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from nemo.backends.pytorch.nm import TrainableNM
from nemo.core.neural_types import (
NeuralType,
AxisType,
BatchTag,
TimeTag,
ChannelTag,
NeuralType,
TimeTag,
)
from nemo_asr.jasper import init_weights as jasper_init_weights

Expand Down
4 changes: 2 additions & 2 deletions collections/nemo_asr/nemo_asr/losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

from nemo.backends.pytorch.nm import LossNM
from nemo.core.neural_types import (
NeuralType,
AxisType,
BatchTag,
TimeTag,
ChannelTag,
NeuralType,
TimeTag,
)


Expand Down
2 changes: 1 addition & 1 deletion collections/nemo_asr/nemo_asr/parts/cleaners.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright (c) 2019 NVIDIA Corporation

import inflect
import re

import inflect
from unidecode import unidecode

NUM_CHECK = re.compile(r'([$]?)(^|\s)(\S*[0-9]\S*)(?=(\s|$)((\S*)(\s|$))?)')
Expand Down
5 changes: 2 additions & 3 deletions collections/nemo_asr/nemo_asr/parts/collections.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Copyright (c) 2019 NVIDIA Corporation
import collections
import os
from typing import Optional, List, Union
from typing import List, Optional, Union

import pandas as pd

import nemo
from nemo_asr.parts import manifest
from nemo_asr.parts import parsers
from nemo_asr.parts import manifest, parsers


class _Collection(collections.UserList):
Expand Down
3 changes: 1 addition & 2 deletions collections/nemo_asr/nemo_asr/parts/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from torch.utils.data import Dataset

import nemo
from nemo_asr.parts import collections
from nemo_asr.parts import parsers
from nemo_asr.parts import collections, parsers


def seq_collate_fn(batch, token_pad_value=0):
Expand Down
6 changes: 4 additions & 2 deletions collections/nemo_asr/nemo_asr/parts/features.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# Taken straight from Patter https://github.com/ryanleary/patter
# TODO: review, and copyright and fix/add comments
import math

import librosa
import torch
import torch.nn as nn
from .perturb import AudioAugmentor
from .segment import AudioSegment
from torch_stft import STFT

import nemo

from .perturb import AudioAugmentor
from .segment import AudioSegment

CONSTANT = 1e-5


Expand Down
2 changes: 1 addition & 1 deletion collections/nemo_asr/nemo_asr/parts/jasper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Tuple, Optional, List
from typing import List, Optional, Tuple

import torch
import torch.nn as nn
Expand Down
2 changes: 1 addition & 1 deletion collections/nemo_asr/nemo_asr/parts/manifest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (c) 2019 NVIDIA Corporation
import json
from typing import Union, Iterator, Dict, Any, List
from typing import Any, Dict, Iterator, List, Union


class ManifestBase:
Expand Down
3 changes: 2 additions & 1 deletion collections/nemo_asr/nemo_asr/parts/parsers.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Copyright (c) 2019 NVIDIA Corporation
import string
from typing import Optional, List
from typing import List, Optional

import frozendict

from nemo_asr.parts import cleaners


Expand Down
3 changes: 1 addition & 2 deletions collections/nemo_asr/nemo_asr/parts/perturb.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import librosa
from scipy import signal

from nemo_asr.parts import collections
from nemo_asr.parts import parsers
from nemo_asr.parts import collections, parsers

from .segment import AudioSegment

Expand Down
6 changes: 2 additions & 4 deletions collections/nemo_nlp/nemo_nlp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
# limitations under the License.
# =============================================================================

import nemo

from .data import *
from .huggingface import *
from .modules import *
from .transformer import *


import nemo


name = "nemo_nlp"
backend = nemo.core.Backend.PyTorch
__version__ = "0.9.0"
3 changes: 2 additions & 1 deletion collections/nemo_nlp/nemo_nlp/data/data_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@
import torch
from torch.utils import data as pt_data

from .datasets import *
import nemo
from nemo.backends.pytorch.nm import DataLayerNM
from nemo.core.neural_types import *

from .datasets import *


class TextDataLayer(DataLayerNM):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import os
import pickle
import random

import h5py
import numpy as np
from torch.utils.data import Dataset
Expand Down
3 changes: 2 additions & 1 deletion collections/nemo_nlp/nemo_nlp/data/datasets/glue.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
https://github.com/huggingface/transformers
"""

import nemo
import numpy as np
from torch.utils.data import Dataset

import nemo


class GLUEDataset(Dataset):
def __init__(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
import pickle
import random

import nemo
import numpy as np
from torch.utils.data import Dataset

import nemo

from . import utils


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@

import random

import nemo
import numpy as np
from torch.utils.data import Dataset

import nemo

from . import utils


Expand Down
11 changes: 6 additions & 5 deletions collections/nemo_nlp/nemo_nlp/data/datasets/squad.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,26 @@
import sys

import numpy as np
from tqdm import tqdm
import torch
from torch.utils.data import Dataset
from tqdm import tqdm

import nemo
from nemo_nlp.utils.nlp_utils import _is_whitespace
from .utils import DataProcessor

from ...utils.metrics.squad_metrics import (
_compute_softmax,
_get_best_indexes,
apply_no_ans_threshold,
exact_match_score,
make_eval_dict,
f1_score,
find_all_best_thresh,
get_final_text,
normalize_answer,
make_eval_dict,
merge_eval,
find_all_best_thresh,
normalize_answer,
)
from .utils import DataProcessor


"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
import pickle
import random

import nemo
import numpy as np
from torch.utils.data import Dataset

import nemo

from . import utils


Expand Down
2 changes: 1 addition & 1 deletion collections/nemo_nlp/nemo_nlp/data/datasets/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import numpy as np
from torch.utils.data import Dataset

from ..utils import dataset_to_ids, clean_src_and_target
from ..utils import clean_src_and_target, dataset_to_ids


class TranslationDataset(Dataset):
Expand Down
Loading

0 comments on commit caddc35

Please sign in to comment.