python_code stringlengths 0 992k | repo_name stringlengths 8 46 | file_path stringlengths 5 162 |
|---|---|---|
# 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
from collections import OrderedDict
from torch.utils.data import Dataset
from torch.utils.data.dataloader import default_collat... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/datasets/mmdataset.py |
# 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 random
import numpy as np
import torch
from .shardedtensor import *
from .load_config import *
def set_seed(seed=43211):
random.s... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/utils/__init__.py |
# 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 omegaconf
from omegaconf import OmegaConf
def load_config(args=None, config_file=None, overwrite_fairseq=False):
"""TODO... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/utils/load_config.py |
# 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 pickle
import numpy as np
class ShardedTensor(object):
def __init__(self, data, starts):
self.data = data
... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/utils/shardedtensor.py |
# coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/models/transformermodel.py |
# 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 .mmfusion import *
from .transformermodel import *
from .mmfusionnlg import *
try:
from .fairseqmmmodel import *
except ImportError:
... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/models/__init__.py |
# 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 fairseq.models import (
BaseFairseqModel,
register_model,
register_model_architecture
)
@register_model("mmmodel")
class Fa... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/models/fairseqmmmodel.py |
# coding=utf-8
# Copyright 2018 The Google AI Language Team Authors, Facebook AI Research authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the L... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/models/mmfusionnlg.py |
# coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/models/mmfusion.py |
# 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 random
import json
import numpy as np
import torch
import pickle
import math
from tqdm import tqdm
class Predictor(object):... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/evaluators/predictor.py |
# 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 .metric import *
from .evaluator import *
# experimental.
try:
from .expmetric import *
except ImportError:
pass
| EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/evaluators/__init__.py |
# 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 numpy as np
import json
class Metric(object):
def __init__(self, config, metric_names):
self.metric_names = metric_names
... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/evaluators/metric.py |
# 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 glob
import numpy as np
from . import metric as metric_path
from . import predictor as predictor_path
class Evaluator(objec... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/evaluators/evaluator.py |
# 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 random
import json
import pickle
from tqdm import tqdm
import os
import numpy as np
class CaptionDedupProcessor(object):
"""remov... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/processors/dedupprocessor.py |
# 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 .how2processor import (
ShardedHow2MetaProcessor,
ShardedVideoProcessor,
ShardedTextProcessor,
VariedLenAligner,
Over... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/processors/how2retriprocessor.py |
# 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 .processor import *
from .how2processor import *
from .how2retriprocessor import *
from .dsprocessor import *
try:
from .rawvideopr... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/processors/__init__.py |
# Copyright (c) Facebook, Inc. All Rights Reserved
import numpy as np
import os
import torch
class Processor(object):
"""
A generic processor for video (codec, feature etc.) and text.
"""
def __call__(self, **kwargs):
raise NotImplementedError
class MetaProcessor(Processor):
"""
A ... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/processors/processor.py |
# Copyright (c) Facebook, Inc. All Rights Reserved
"""
Processors for all downstream (ds) tasks.
"""
import json
import os
import pickle
import random
import math
import numpy as np
import torch
from collections import defaultdict
from .processor import (
MetaProcessor,
VideoProcessor,
TextProcessor,
... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/processors/dsprocessor.py |
# coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/processors/how2processor.py |
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
"""Contains a PyTorch definition for Gated Separable 3D network (S3D-G)
with a text module for computing joint text-video embedding from raw text
and video input. The following code will enable y... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/processors/models/s3dg.py |
# 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 numpy as np
import pickle
import time
try:
import faiss
except ImportError:
pass
from collections import defaultdict... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/modules/retri.py |
# 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 .mm import *
try:
from .expmm import *
except ImportError:
pass
| EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/modules/__init__.py |
# Copyright (c) Facebook, Inc. All Rights Reserved
import torch
import os
import numpy as np
import pickle
from . import retri
from ..utils import get_local_rank
class VectorPool(object):
"""
Base class of retrieval space.
"""
def __init__(self, config):
from transformers import AutoConfig
... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/modules/vectorpool.py |
# coding=utf-8
# Copyright 2018 The Google AI Language Team Authors and The HuggingFace Inc. team.
# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a cop... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt/modules/mm.py |
# 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 numpy as np
import os
import pickle
from mmpt.utils import ShardedTensor
class Shard(object):
def __init__(
self,
... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/scripts/video_feature_extractor/shard_feature.py |
# Copyright Howto100M authors.
# Copyright (c) Facebook, Inc. All Rights Reserved
import torch as th
import pandas as pd
import os
import numpy as np
import ffmpeg
import random
from torch.utils.data import Dataset
class VideoLoader(Dataset):
"""modified from how2's video_feature_extractor."""
def __init__(... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/scripts/video_feature_extractor/videoreader.py |
# 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 urllib.parse
import json
import pandas as pd
from tqdm import tqdm
# TODO: extending to other datasets.
supported_formats =... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/scripts/video_feature_extractor/pathbuilder.py |
# Copyright (c) Howto100M authors and Facebook, Inc. All Rights Reserved
import torch as th
from torch import nn
class GlobalAvgPool(nn.Module):
def __init__(self):
super(GlobalAvgPool, self).__init__()
def forward(self, x):
return th.mean(x, dim=[-2, -1])
def get_model(args):
assert ... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/scripts/video_feature_extractor/model.py |
# Copyright Howto100m authors.
# Copyright (c) Facebook, Inc. All Rights Reserved
import torch as th
class Normalize(object):
def __init__(self, mean, std):
self.mean = th.FloatTensor(mean).view(1, 3, 1, 1)
self.std = th.FloatTensor(std).view(1, 3, 1, 1)
def __call__(self, tensor):
t... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/scripts/video_feature_extractor/preprocessing.py |
# Copyright Howto100M authors.
# Copyright (c) Facebook, Inc. All Rights Reserved
import torch as th
import torch.nn.functional as F
import math
import numpy as np
import argparse
from torch.utils.data import DataLoader
from model import get_model
from preprocessing import Preprocessing
from random_sequence_shuffler ... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/scripts/video_feature_extractor/extract.py |
# Copyright (c) Facebook, Inc. All Rights Reserved
import numpy as np
from torch.utils.data.sampler import Sampler
class RandomSequenceSampler(Sampler):
def __init__(self, n_sample, seq_len):
self.n_sample = n_sample
self.seq_len = seq_len
def _pad_ind(self, ind):
zeros = np.zeros(... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/scripts/video_feature_extractor/random_sequence_shuffler.py |
# 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 pickle
import os
import argparse
import numpy as np
from torch.utils.data import Dataset, DataLoader
from mmpt.processors import PKLJS... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/scripts/text_token_extractor/pretokenization.py |
# 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 glob
import argparse
import pprint
import omegaconf
from omegaconf import OmegaConf
from torch.utils.data import DataLoader
... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt_cli/predict.py |
# 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 mmpt.utils import recursive_config
class BaseJob(object):
def __init__(self, yaml_file, dryrun=False):
self.yaml_... | EXA-1-master | exa/libraries/fairseq/examples/MMPT/mmpt_cli/localjob.py |
# 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 . import rxf_src # noqa
| EXA-1-master | exa/libraries/fairseq/examples/rxf/__init__.py |
# 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 . import label_smoothed_cross_entropy_r3f, sentence_prediction_r3f # noqa
| EXA-1-master | exa/libraries/fairseq/examples/rxf/rxf_src/__init__.py |
# 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 fairseq import utils
from fairseq.criterions import FairseqCriterion, register_... | EXA-1-master | exa/libraries/fairseq/examples/rxf/rxf_src/sentence_prediction_r3f.py |
# 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 fairseq import utils
from fairseq.logging import metrics
from fairseq.criterion... | EXA-1-master | exa/libraries/fairseq/examples/rxf/rxf_src/label_smoothed_cross_entropy_r3f.py |
# 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 . import transformer_xl_model, truncated_bptt_lm_task # noqa
| EXA-1-master | exa/libraries/fairseq/examples/truncated_bptt/__init__.py |
# 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 os
from dataclasses import dataclass, field
from typing import List, Optional, Tuple
import torch
from fairseq import u... | EXA-1-master | exa/libraries/fairseq/examples/truncated_bptt/truncated_bptt_lm_task.py |
# 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
from dataclasses import dataclass, field
from typing import Dict, List, Optional
import torch
from fairseq.dataclass import Fa... | EXA-1-master | exa/libraries/fairseq/examples/truncated_bptt/transformer_xl_model.py |
# 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 . import tasks, criterions, models # noqa
| EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/__init__.py |
# 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 os
from argparse import Namespace
from pathlib import Path
import torch
from fairseq.data import (
encoders,
Dic... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/tasks/speech_text_joint.py |
# 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 importlib
import os
| EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/tasks/__init__.py |
# 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 os
import re
from argparse import Namespace
from pathlib import Path
from fairseq.data import ConcatDataset, Dictionary,... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/tasks/speech_text_denoise_pretrain.py |
# 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 itertools
import logging
import os
import re
import numpy as np
import torch
from examples.speech_text_joint_to_text.data.pair_denois... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/tasks/pair_denoising.py |
# 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
from collections import namedtuple
import torch
import torch.nn as nn
from fairseq import checkpoint_utils
from fairseq import... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/models/s2t_dualinputtransformer.py |
# 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
from collections import OrderedDict, namedtuple
import torch.nn as nn
from fairseq import checkpoint_utils, utils
from fairse... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/models/s2t_dualinputwavtransformer.py |
# 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 importlib
import os
| EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/models/__init__.py |
# 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 copy
import torch.nn as nn
from fairseq import checkpoint_utils
from fairseq import utils
from fairseq.data.data_utils import lengths_... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/models/s2t_dualinputxmtransformer.py |
#!/usr/bin/env python3
import logging
from collections import OrderedDict, namedtuple
from typing import Dict, Optional
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch import Tensor
from fairseq import checkpoint_utils, utils
from fairseq.file_io import PathManager
from fairseq.models i... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/models/joint_speech_text_pretrain_transformer.py |
#!/usr/bin/env python3
# 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 re
from collections import OrderedDict
import torch
from fairseq.file_io import PathManager
... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/scripts/convert_model.py |
# 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 itertools
import logging
import re
import time
from g2p_en import G2p
logger = logging.getLogger(__name__)
FAIL_SENT... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/scripts/g2p_encode.py |
# 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 copy
import math
import re
import torch
from fairseq.data import data_utils
from fairseq.data.language_pair_dataset import LanguagePa... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/data/pair_denoising_dataset.py |
# 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
from fairseq import utils
from fairseq.criterions import register_criterion
from fairseq.criterions.label_smoothed_cross_entropy ... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/criterions/multi_modality_cross_entropy.py |
# 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 fairseq import utils
from fairseq.criterions import FairseqCriterion, register_c... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/criterions/text_guide_cross_entropy_acc.py |
# 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 importlib
import os
for file in os.listdir(os.path.dirname(__file__)):
if file.endswith(".py") and not file.startswith("_"):
... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/criterions/__init__.py |
#
# 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 math
from dataclasses import dataclass, field
from fairseq import utils
from fairseq.logging import metrics
from fairseq.criterions import FairseqCriterion, register_crite... | EXA-1-master | exa/libraries/fairseq/examples/speech_text_joint_to_text/criterions/multi_modality_compound.py |
# 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
from fairseq.optim.amp_optimizer import AMPOptimizer
from fairseq.tasks import register_task
from fairseq.tasks.speech_to_text im... | EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/speech_to_text_head_selection.py |
EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/__init__.py | |
# 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
from torch.nn.modules.loss import _Loss
class HeadSelectionLoss(_Loss):
def __init__(self, args):
sup... | EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/loss/attention_head_selection.py |
EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/loss/__init__.py | |
# 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
from typing import Dict, List, Optional
from pathlib import Path
import torch.nn as nn
from torch import Tensor
from fairseq im... | EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/models/head_selection_s2t_transformer.py |
EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/models/__init__.py | |
# 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 typing import Any, List, Dict, Optional
import torch
import torch.nn as nn
from torch import Tensor
from fairseq.utils import safe_hasat... | EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/models/head_selection_transformer.py |
# 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 typing import Optional, Tuple
import torch
from torch import Tensor
from torch.nn.functional import (
linear, softmax, dropout, pad,
... | EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/modules/multihead_functional.py |
# 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 typing import Dict, Optional, Tuple
import torch
from fairseq import utils
from fairseq.modules.quant_noise import quant_noise
from torch... | EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/modules/multihead_attention_selection.py |
# 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 fairseq.utils import safe_getattr
from fairseq.modules import TransformerEncoderLayer, TransformerDecoderLayer
from ..modules.multihead_a... | EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/modules/head_selection_transformer_layer.py |
EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/modules/__init__.py | |
# 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 as nn
import math
class AttnHeadSelector(nn.Module):
"""
Latent variable modeling of attention head selection
"""
def __init__(
self, num_ta... | EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/modules/attn_head_selector.py |
EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/data/__init__.py | |
# 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
from pathlib import Path
from typing import Dict, List, Optional
from dataclasses import dataclass
import torch
from fairseq.d... | EXA-1-master | exa/libraries/fairseq/examples/attention_head_selection/src/data/speech_to_text_dataset_with_domain.py |
#!/usr/bin/env python3
# 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.
"""
Helper script to pre-compute embeddings for a flashlight (previously called wav2letter++) dataset
"""
import argpa... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/wav2vec_featurize.py |
EXA-1-master | exa/libraries/fairseq/examples/wav2vec/__init__.py | |
#!/usr/bin/env python3
# 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.
"""
Data pre-processing: build vocabularies and binarize training data.
"""
import argparse
import glob
import os
impor... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/wav2vec_manifest.py |
#!/usr/bin/env python3
# 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.
"""
Helper script to pre-compute embeddings for a flashlight (previously called wav2letter++) dataset
"""
import argpa... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/libri_labels.py |
#!/usr/bin/env python3
# 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.
"""
Helper script to pre-compute embeddings for a flashlight (previously called wav2letter++) dataset
"""
import argpa... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/vq-wav2vec_featurize.py |
EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/__init__.py | |
#!/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.
"""
Run inference for pre-processed data with a trained model.
"""
import ast
from collections import namedtuple
fr... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/w2vu_generate.py |
# 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 .unpaired_audio_text import UnpairedAudioText
__all__ = [
"UnpairedAudioText",
]
| EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/tasks/__init__.py |
# Copyright (c) 2017-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. An additional grant of patent rights
# can be found in the PATENTS file in the same directory.
from dataclasses import dataclass,... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/tasks/unpaired_audio_text.py |
import kaldi_io
import numpy as np
import os
def get_parser():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("w2v_dir", help="wav2vec feature and text directory")
parser.add_argument("tar_root", help="output data directory in kaldi's format")
parser.add_argument("split", h... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/kaldi_self_train/st/local/prepare_data_from_w2v.py |
"""
Implement unsupervised metric for decoding hyperparameter selection:
$$ alpha * LM_PPL + ViterbitUER(%) * 100 $$
"""
import argparse
import logging
import math
import sys
import kenlm
import editdistance
from g2p_en import G2p
logging.root.setLevel(logging.INFO)
logging.basicConfig(stream=sys.stdout, level=lo... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/kaldi_self_train/st/local/unsup_select.py |
import sys
for idx, line in enumerate(sys.stdin):
print(f"utt{idx:010d} {line}", end='') | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/kaldi_self_train/st/local/copy_aligned_text.py |
# 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 dataclasses import dataclass
from enum import Enum, auto
import math
import numpy as np
from typing import Tuple, List, Optional, Dict
i... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/models/wav2vec_u.py |
# 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 .wav2vec_u import Wav2vec_U
__all__ = [
"Wav2vec_U",
]
| EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/models/__init__.py |
#!/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 sys
from copy import deepcopy
from scipy.signal import lfilter
import numpy as np
from tqdm... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/vads.py |
#!/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 os
import os.path as osp
import numpy as np
import tqdm
import torch
import sys
import faiss... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/wav2vec_apply_cluster_faiss.py |
#!/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 gc
import os
import os.path as osp
import random
import numpy as np
import tqdm
import torch
... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/wav2vec_cluster_faiss.py |
#!/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 os
import argparse
import sys
parser = argparse.ArgumentParser()
parser.add_argument("--tsv", required=True... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/filter_tsv.py |
#!/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 os
import os.path as osp
import numpy as np
import tqdm
import torch
import random
from shuti... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/merge_clusters.py |
#!/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 sys
def main():
for line in sys.stdin:
print(line.replace(" ", "").replace("|", " ").strip())
... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/ltr_to_wrd.py |
#!/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 numpy as np
import sys
def get_parser():
parser = argparse.ArgumentParser(
desc... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/phonemize_with_sil.py |
#!/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 os
import os.path as osp
import math
import numpy as np
import tqdm
import torch
import torch... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/mean_pool.py |
#!/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 sys
def main():
for line in sys.stdin:
print(" ".join(list(line.strip().replace(" ", "|"))) + "... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/wrd_to_ltr.py |
#!/usr/bin/env python3
# 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 regex
import sys
def main():
filter_r = regex.compile(r"[^\p{L}\p{N}\p{M}\' \-]")
for line in sys.std... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/normalize_text.py |
#!/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.
"""
Implement unsupervised metric for decoding hyperparameter selection:
$$ alpha * LM_PPL + ViterbitUER(%) * 10... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/wer.py |
#!/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 sys
for idx, line in enumerate(sys.stdin):
print(f"utt{idx:010d} {line}", end="")
| EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/copy_labels.py |
#!/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 os
import os.path as osp
import numpy as np
import faiss
def get_parser():
parser = a... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/pca.py |
#!/usr/bin/env python3
# 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 fasttext as ft
import os
import regex
import sys
def get_parser():
parser = argparse.Argum... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/normalize_and_filter_text.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.