python_code stringlengths 0 992k | repo_name stringlengths 8 46 | file_path stringlengths 5 162 |
|---|---|---|
#!/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 fairseq.data import Dictionary
def get_parser():
parser = argparse.ArgumentPa... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/filter_lexicon.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
from shutil ... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/apply_pca.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 g2p_en import G2p
def main():
parser = argparse.ArgumentParser()
parser.a... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/g2p_wrd_to_phn.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.
"""
get intervals from .vads file, specify output data, and this script removes silences and saves the audio data in... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/remove_silence.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 tqdm
import torch
import torch.nn.functional as F
from shutil... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/scripts/wav2vec_extract_features.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 .extracted_features_dataset import ExtractedFeaturesDataset
from .random_input_dataset import RandomInputDataset
__all__ = [
"Extra... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/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
import os
import contextlib
import numpy as np
import torch
from fairseq.data import FairseqDataset, data_utils
logger = l... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/data/extracted_features_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 random
from typing import List
from fairseq.data import BaseWrapperDataset, data_utils
class RandomInputDataset(BaseWrapperDataset):... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/unsupervised/data/random_input_dataset.py |
"""
Usage:
This script is used to extract the embedding / logit for speech classification task.
1. Set fdir into your model checkpoint directory
2. Run the following command (preferrably on GPU machine to speed up the inference process)
CUDA_VISIBLE_DEVICES=0 python3 examples/wav2vec/gen_audio_embeddin... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/xlsr/scripts/gen_audio_embedding.py |
"""
Usage:
This scripts it to evaluate the classification accuracy/error rate from the embedding extracted
by gen_audio_embedding.py
Example (LID classification)
PYTHONPATH='.' python examples/wav2vec/eval_speaker_clf_task.py \
--data /fsx/androstj/exps/lid_voxlingua/infer/atj_xlsr2_100pct... | EXA-1-master | exa/libraries/fairseq/examples/wav2vec/xlsr/scripts/eval_speaker_clf_task.py |
#!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import contextlib
import sys
from collections import Counter
from multiprocessing imp... | EXA-1-master | exa/libraries/fairseq/examples/roberta/multiprocessing_bpe_encoder.py |
#!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import json
import os
import re
class InputExample:
def __init__(self, paragrap... | EXA-1-master | exa/libraries/fairseq/examples/roberta/preprocess_RACE.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 json
from functools import lru_cache
def convert_sentence_to_json(sentence):
if "_" in sentence:
prefix, rest = sentence.... | EXA-1-master | exa/libraries/fairseq/examples/roberta/wsc/wsc_utils.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 LegacyFairseqCriterion, reg... | EXA-1-master | exa/libraries/fairseq/examples/roberta/wsc/wsc_criterion.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 wsc_criterion # noqa
from . import wsc_task # noqa
| EXA-1-master | exa/libraries/fairseq/examples/roberta/wsc/__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 json
import os
import tempfile
import numpy as np
import torch
import torch.nn.functional as F
from fairseq import utils
from fairseq.... | EXA-1-master | exa/libraries/fairseq/examples/roberta/wsc/wsc_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.
from . import commonsense_qa_task # noqa
| EXA-1-master | exa/libraries/fairseq/examples/roberta/commonsense_qa/__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 json
import os
import numpy as np
import torch
from fairseq.data import (
Dictionary,
IdDataset,
ListDataset,
NestedDi... | EXA-1-master | exa/libraries/fairseq/examples/roberta/commonsense_qa/commonsense_qa_task.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 fileinput
import sacremoses
def main():
parser = argparse.ArgumentParser(description="... | EXA-1-master | exa/libraries/fairseq/examples/megatron_11b/detok.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 ast
import logging
import matplotlib.pyplot as plt
import numpy as np
from pathlib import Path
import soundfile as sf
import sys
import... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/generate_waveform.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.
| EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/__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 io
import os
from pathlib import Path
from typing import Optional, List, Dict
import zipfile
import tempfile
from dataclasses import da... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/data_utils.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 torch
from scipy.interpolate import interp1d
import torchaudio
from fairseq.tasks.text_to_speech import (
batch... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/utils.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.
"""
Signal processing-based evaluation using waveforms
"""
import csv
import numpy as np
import os.path as op
import torch
import tqdm
from... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/evaluation/eval_sp.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 editdistance
import re
import shutil
import soundfile as sf
import subprocess
from pathlib import Path
from examples.s... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/evaluation/eval_asr.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.
"""
Signal processing-based evaluation using waveforms
"""
import numpy as np
import os.path as op
import torchaudio
import tqdm
from tabulat... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/evaluation/eval_f0.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 csv
from pathlib import Path
def main(args):
"""
`uid syn ref text`
"""
in_root = Path(args.generation_root).resolve... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/evaluation/get_eval_manifest.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.
| EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/evaluation/__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 argparse
import logging
import numpy as np
import re
from pathlib import Path
from collections import defaultdict
import pandas as pd
... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/get_vctk_audio_manifest.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
from collections import defaultdict
from itertools import chain
from pathlib import Path
import numpy as np
import torchaudi... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/get_speaker_embedding.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 logging
from pathlib import Path
from collections import defaultdict
import pandas as pd
from torchaudio.datasets impo... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/get_ljspeech_audio_manifest.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 logging
from pathlib import Path
import shutil
from tempfile import NamedTemporaryFile
from collections import Counter,... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/get_feature_manifest.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.
| EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/__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 argparse
import logging
from pathlib import Path
from collections import defaultdict
from typing import List, Dict, Tuple
import panda... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/get_common_voice_audio_manifest.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 logging
import os
import csv
import tempfile
from collections import defaultdict
from pathlib import Path
import torch... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/denoise_and_vad_audio.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 librosa
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.utils.data
import torchaudio
EMBEDDER_PARAMS... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/speaker_embedder/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# author: adefossez
import logging
import torch.hub
from .demucs import Demucs
from .utils import deserialize_model
logg... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/denoiser/pretrained.py |
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# author: adefossez
import math
import torch as th
from torch.nn import functional as F
def sinc(t):
"""sinc.
:... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/denoiser/resample.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.
| EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/denoiser/__init__.py |
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# author: adefossez
import functools
import logging
from contextlib import contextmanager
import inspect
import time
logge... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/denoiser/utils.py |
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
# author: adefossez
import math
import time
import torch as th
from torch import nn
from torch.nn import functional as F
... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/denoiser/demucs.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 collections
import contextlib
import wave
try:
import webrtcvad
except ImportError:
raise ImportError("Please install py-webr... | EXA-1-master | exa/libraries/fairseq/examples/speech_synthesis/preprocessing/vad/__init__.py |
from . import criterions, models, tasks # noqa
| EXA-1-master | exa/libraries/fairseq/examples/discriminative_reranking_nmt/__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.
"""
Score raw text with a trained model.
"""
from collections import namedtuple
import logging
from multiprocessing ... | EXA-1-master | exa/libraries/fairseq/examples/discriminative_reranking_nmt/drnmt_rerank.py |
from .discriminative_reranking_task import DiscriminativeRerankingNMTTask
__all__ = [
"DiscriminativeRerankingNMTTask",
]
| EXA-1-master | exa/libraries/fairseq/examples/discriminative_reranking_nmt/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.
from dataclasses import dataclass, field
import itertools
import logging
import os
import numpy as np
import torch
from fairseq.logging imp... | EXA-1-master | exa/libraries/fairseq/examples/discriminative_reranking_nmt/tasks/discriminative_reranking_task.py |
from .discriminative_reranking_model import DiscriminativeNMTReranker
__all__ = [
"DiscriminativeNMTReranker",
]
| EXA-1-master | exa/libraries/fairseq/examples/discriminative_reranking_nmt/models/__init__.py |
from dataclasses import dataclass, field
import os
import torch
import torch.nn as nn
from fairseq import utils
from fairseq.dataclass import ChoiceEnum, FairseqDataclass
from fairseq.models import (
BaseFairseqModel,
register_model,
)
from fairseq.models.roberta.model import RobertaClassificationHead
from ... | EXA-1-master | exa/libraries/fairseq/examples/discriminative_reranking_nmt/models/discriminative_reranking_model.py |
#!/usr/bin/env python
import argparse
from multiprocessing import Pool
from pathlib import Path
import sacrebleu
import sentencepiece as spm
def read_text_file(filename):
with open(filename, "r") as f:
output = [line.strip() for line in f]
return output
def get_bleu(in_sent, target_sent):
ble... | EXA-1-master | exa/libraries/fairseq/examples/discriminative_reranking_nmt/scripts/prep_data.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
from dataclasses import dataclass, field
import torch
import torch.nn.functional as F
from fairseq import utils
from fairseq.log... | EXA-1-master | exa/libraries/fairseq/examples/discriminative_reranking_nmt/criterions/discriminative_reranking_criterion.py |
from .discriminative_reranking_criterion import KLDivergenceRerankingCriterion
__all__ = [
"KLDivergenceRerankingCriterion",
]
| EXA-1-master | exa/libraries/fairseq/examples/discriminative_reranking_nmt/criterions/__init__.py |
import sys
from SPARQLWrapper import SPARQLWrapper, JSON
endpoint_url = "https://query.wikidata.org/sparql"
with open("/your/urls/here") as f:
data = f.readlines()
urls = [i.strip() for i in data]
def get_results(endpoint_url, URL):
query = f"""SELECT ?uriLabel ?occupation ?occupationLabel ?dob ?dobLabel WHE... | EXA-1-master | exa/libraries/fairseq/examples/womens_bios/query_occupations_from_wikidata.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 json
import collections
import argparse
import shutil
import subprocess
import sys
import tempfile
from multiprocessing impor... | EXA-1-master | exa/libraries/fairseq/examples/xmod/preprocess_nli.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.
"""
Translate pre-processed data with a trained model.
"""
import numpy as np
import torch
from fairseq import check... | EXA-1-master | exa/libraries/fairseq/examples/criss/save_encoder.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 glob
from subprocess import check_call
try:
import faiss
has_faiss = True
except Imp... | EXA-1-master | exa/libraries/fairseq/examples/criss/mining/mine.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 glob
import numpy as np
DIM = 1024
def compute_dist(source_embs, target_embs, k=5, return... | EXA-1-master | exa/libraries/fairseq/examples/criss/sentence_retrieval/encoder_analysis.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.search import Search
class NoisyChannelBeamSearch(Search):
def __init__(self, tgt_dict):
super().__in... | EXA-1-master | exa/libraries/fairseq/examples/fast_noisy_channel/noisy_channel_beam_search.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 noisy_channel_translation # noqa
from . import noisy_channel_sequence_generator # noqa
from . import noisy_channel_beam_search... | EXA-1-master | exa/libraries/fairseq/examples/fast_noisy_channel/__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 Dict, List, Optional
import math
import numpy as np
import torch
import torch.nn.functional as F
from torch import Tensor... | EXA-1-master | exa/libraries/fairseq/examples/fast_noisy_channel/noisy_channel_sequence_generator.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.tasks.translation import TranslationTask
from fairseq.tasks.language_modeling import LanguageModelingTask
from fairseq import che... | EXA-1-master | exa/libraries/fairseq/examples/fast_noisy_channel/noisy_channel_translation.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 os
import os.path as op
from collections import namedtuple
from multiprocessing import cpu_count
from typing import Li... | EXA-1-master | exa/libraries/fairseq/examples/byte_level_bpe/get_bitext.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.
# Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the r... | EXA-1-master | exa/libraries/fairseq/examples/byte_level_bpe/gru_transformer.py |
#!/usr/bin/env python
"""Helper script to compare two argparse.Namespace objects."""
from argparse import Namespace # noqa
def main():
ns1 = eval(input("Namespace 1: "))
ns2 = eval(input("Namespace 2: "))
def keys(ns):
ks = set()
for k in dir(ns):
if not k.startswith("_"):
... | EXA-1-master | exa/libraries/fairseq/scripts/compare_namespaces.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.
"""
Split a large file into a train and valid set while respecting document
boundaries. Documents should be separated by... | EXA-1-master | exa/libraries/fairseq/scripts/split_train_valid_docs.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.
"""
Use this script in order to build symmetric alignments for your translation
dataset.
This script depends on fast_align and mosesdecoder too... | EXA-1-master | exa/libraries/fairseq/scripts/build_sym_alignment.py |
#!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
... | EXA-1-master | exa/libraries/fairseq/scripts/spm_decode.py |
EXA-1-master | exa/libraries/fairseq/scripts/__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.
import argparse
import os
import re
import shutil
import sys
pt_regexp = re.compile(r"checkpoint(\d+|_\d+_\d+|_[a-z]+... | EXA-1-master | exa/libraries/fairseq/scripts/rm_pt.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.
"""
Count the number of documents and average number of lines and tokens per
document in a large file. Documents should ... | EXA-1-master | exa/libraries/fairseq/scripts/count_docs.py |
#!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
i... | EXA-1-master | exa/libraries/fairseq/scripts/spm_encode.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.
"""
Split a large file into shards while respecting document boundaries. Documents
should be separated by a single empty... | EXA-1-master | exa/libraries/fairseq/scripts/shard_docs.py |
#!/usr/bin/env python
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from __future__ import absolute_import, division, print_function, unicode_literals
import sys
impor... | EXA-1-master | exa/libraries/fairseq/scripts/spm_train.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 collections
import os
import re
import torch
from fairseq.file_io import PathManager
def ave... | EXA-1-master | exa/libraries/fairseq/scripts/average_checkpoints.py |
from pathlib import Path
import os
cwd = Path(".").resolve()
print("running 'check_installation.py' from:", cwd)
# Old versions of numpy/torch can prevent loading the .so files
import torch
print("torch:", torch.__version__)
import numpy
print("numpy:", numpy.__version__)
import fairseq
print("Fairseq installed a... | EXA-1-master | exa/libraries/fairseq/scripts/check_installation.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
from fairseq.data import Dictionary, data_utils, indexed_dataset
def get_parser():
parser = argp... | EXA-1-master | exa/libraries/fairseq/scripts/read_binarized.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 sys
"""Reads in a fairseq output file, and verifies that the constraints
(C- lines) are present in the outpu... | EXA-1-master | exa/libraries/fairseq/scripts/constraints/validate.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.
"""Extracts random constraints from reference files."""
import argparse
import random
import sys
def get_phrase(wo... | EXA-1-master | exa/libraries/fairseq/scripts/constraints/extract.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
# Follows PEP-0440 version scheme guidelines
# https://www.python.org/dev/peps/pep-0440/... | EXA-1-master | exa/libraries/multimodal-main/version.py |
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import argparse
import os
import re
import sys
from datetime import date
from setuptool... | EXA-1-master | exa/libraries/multimodal-main/setup.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import os
import random
import tempfile
from contextlib import contextmanager
from pathlib import Path
from typ... | EXA-1-master | exa/libraries/multimodal-main/tests/test_utils.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| EXA-1-master | exa/libraries/multimodal-main/tests/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
import torch
from tests.test_utils import assert_expected
from torch import nn
from torch.utils... | EXA-1-master | exa/libraries/multimodal-main/tests/utils/test_common.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import torch
from tests.test_utils import assert_expected
from torchmultimodal.utils.attention import get_causa... | EXA-1-master | exa/libraries/multimodal-main/tests/utils/test_attention_utils.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| EXA-1-master | exa/libraries/multimodal-main/tests/utils/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
import torch
from tests.test_utils import assert_expected, set_rng_seed
from torchmultimodal.m... | EXA-1-master | exa/libraries/multimodal-main/tests/utils/test_generate.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from torch import nn
from torchmultimodal.utils.common import load_module_from_url
def test_load_module_from_... | EXA-1-master | exa/libraries/multimodal-main/tests/utils/test_ckpt_load.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
from torchmultimodal.utils.assertion import assert_equal_lengths
class TestAssertEqualLengths:
... | EXA-1-master | exa/libraries/multimodal-main/tests/utils/test_assertion.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
import torch
import torch.multiprocessing as mp
from tests.test_utils import (
assert_expecte... | EXA-1-master | exa/libraries/multimodal-main/tests/utils/test_distributed.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
import torch
from tests.test_utils import assert_expected
from torchmultimodal.models.late_fusio... | EXA-1-master | exa/libraries/multimodal-main/tests/models/test_late_fusion.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
import torch
from tests.test_utils import assert_expected, assert_expected_namedtuple, set_rng_... | EXA-1-master | exa/libraries/multimodal-main/tests/models/test_vqvae.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
import torch
from tests.test_utils import assert_expected, assert_expected_namedtuple, set_rng_se... | EXA-1-master | exa/libraries/multimodal-main/tests/models/test_video_vqvae.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| EXA-1-master | exa/libraries/multimodal-main/tests/models/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from typing import List
import pytest
import torch
from tests.test_utils import assert_expected
from torch im... | EXA-1-master | exa/libraries/multimodal-main/tests/models/test_two_tower.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
import torch
from tests.test_utils import assert_expected, assert_expected_namedtuple, set_rng_... | EXA-1-master | exa/libraries/multimodal-main/tests/models/test_gpt.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
import torch
import torchmultimodal.models.omnivore as omnivore
from tests.test_utils import ass... | EXA-1-master | exa/libraries/multimodal-main/tests/models/test_omnivore.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
import torch
from tests.test_utils import assert_expected, set_rng_seed
from torchmultimodal.m... | EXA-1-master | exa/libraries/multimodal-main/tests/models/test_video_gpt.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
from functools import partial
import pytest
import torch
from tests.test_utils import assert_expected, set_rn... | EXA-1-master | exa/libraries/multimodal-main/tests/models/flava/test_text_encoder.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
| EXA-1-master | exa/libraries/multimodal-main/tests/models/flava/__init__.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
import torch
from tests.test_utils import assert_expected, set_rng_seed
from torch import nn
fro... | EXA-1-master | exa/libraries/multimodal-main/tests/models/flava/test_flava.py |
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
import pytest
import torch
from tests.test_utils import assert_expected, set_rng_seed
from torchmultimodal.mode... | EXA-1-master | exa/libraries/multimodal-main/tests/models/flava/test_checkpoint.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.