repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
fairseq | examples/speech_recognition/new/decoders/decoder.py | .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.
from typing import Union
from fairseq.data.dictionary import Dictionary
from .decoder_config import DecoderConfig, F... | 33 | 944 |
fairseq | examples/speech_recognition/tasks/speech_recognition.py | .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 re
import sys
import torch
from examples.speech_recognition.data import AsrDataset
from examples.speech_recognit... | 158 | 5,397 |
fairseq | examples/speech_recognition/tasks/__init__.py | .py | import importlib
import os
for file in sorted(os.listdir(os.path.dirname(__file__))):
if file.endswith(".py") and not file.startswith("_"):
task_name = file[: file.find(".py")]
importlib.import_module("examples.speech_recognition.tasks." + task_name)
| 9 | 273 |
fairseq | examples/speech_recognition/criterions/__init__.py | .py | import importlib
import os
# ASG loss requires flashlight bindings
files_to_skip = set()
try:
import flashlight.lib.sequence.criterion
except ImportError:
files_to_skip.add("ASG_loss.py")
for file in sorted(os.listdir(os.path.dirname(__file__))):
if file.endswith(".py") and not file.startswith("_") and f... | 18 | 510 |
fairseq | examples/speech_recognition/criterions/cross_entropy_acc.py | .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 __future__ import absolute_import, division, print_function, unicode_literals
import logging
import math
import torch
import torch.nn.f... | 131 | 5,372 |
fairseq | examples/speech_recognition/criterions/ASG_loss.py | .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 torch
from examples.speech_recognition.data.replabels import pack_replabels
from fairseq import utils
from fair... | 171 | 5,870 |
fairseq | examples/speech_recognition/kaldi/kaldi_initializer.py | .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.
from dataclasses import dataclass
import hydra
from hydra.core.config_store import ConfigStore
import logging
from ome... | 699 | 23,441 |
fairseq | examples/speech_recognition/kaldi/kaldi_decoder.py | .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.
from concurrent.futures import ThreadPoolExecutor
import logging
from omegaconf import MISSING
import os
import torch
... | 245 | 8,265 |
fairseq | examples/speech_recognition/datasets/asr_prep_json.py | .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.
from __future__ import absolute_import, division, print_function, unicode_literals
import argparse
import concurrent.f... | 126 | 3,775 |
fairseq | examples/speech_recognition/utils/wer_utils.py | .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.
from __future__ import absolute_import, division, print_function, unicode_literals
import re
from collections import ... | 382 | 11,842 |
fairseq | examples/speech_recognition/data/replabels.py | .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.
"""
Replabel transforms for use with flashlight's ASG criterion.
"""
def replabel_symbol(i):
"""
Replabel sy... | 71 | 1,970 |
fairseq | examples/speech_recognition/data/collaters.py | .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.
"""
This module contains collection of classes which implement
collate functionalities for various tasks.
Collaters should know wh... | 132 | 4,796 |
fairseq | examples/speech_recognition/data/__init__.py | .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 .asr_dataset import AsrDataset
__all__ = [
"AsrDataset",
]
| 12 | 248 |
fairseq | examples/speech_recognition/data/asr_dataset.py | .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
from fairseq.data import FairseqDataset
from . import data_utils
from .collaters import Seq2SeqCollater
class... | 123 | 3,955 |
fairseq | examples/speech_recognition/data/data_utils.py | .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
def calc_mean_invstddev(feature):
if len(feature.size()) != 2:
raise ValueError("We expect the input feature to be ... | 101 | 3,429 |
fairseq | examples/speech_recognition/models/__init__.py | .py | import importlib
import os
for file in sorted(os.listdir(os.path.dirname(__file__))):
if file.endswith(".py") and not file.startswith("_"):
model_name = file[: file.find(".py")]
importlib.import_module("examples.speech_recognition.models." + model_name)
| 9 | 276 |
fairseq | examples/speech_recognition/models/vggtransformer.py | .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 math
from collections.abc import Iterable
import torch
import torch.nn as nn
from examples.speech_recognition.data.dat... | 1,021 | 37,260 |
fairseq | examples/speech_recognition/models/w2l_conv_glu_enc.py | .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 math
import torch
import torch.nn as nn
import torch.nn.functional as F
from fairseq.models import (
Fairs... | 178 | 6,078 |
fairseq | examples/speech_synthesis/utils.py | .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... | 102 | 3,357 |
fairseq | examples/speech_synthesis/generate_waveform.py | .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... | 193 | 7,339 |
fairseq | examples/speech_synthesis/data_utils.py | .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... | 345 | 11,364 |
fairseq | examples/speech_synthesis/preprocessing/get_speaker_embedding.py | .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... | 90 | 3,116 |
fairseq | examples/speech_synthesis/preprocessing/get_vctk_audio_manifest.py | .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
... | 80 | 2,685 |
fairseq | examples/speech_synthesis/preprocessing/get_common_voice_audio_manifest.py | .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... | 141 | 5,277 |
fairseq | examples/speech_synthesis/preprocessing/denoise_and_vad_audio.py | .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... | 205 | 7,655 |
fairseq | examples/speech_synthesis/preprocessing/get_feature_manifest.py | .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,... | 263 | 11,171 |
fairseq | examples/speech_synthesis/preprocessing/get_ljspeech_audio_manifest.py | .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... | 71 | 2,288 |
fairseq | examples/speech_synthesis/preprocessing/vad/__init__.py | .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... | 193 | 7,372 |
fairseq | examples/speech_synthesis/preprocessing/denoiser/utils.py | .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... | 177 | 4,770 |
fairseq | examples/speech_synthesis/preprocessing/denoiser/pretrained.py | .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... | 82 | 2,384 |
fairseq | examples/speech_synthesis/preprocessing/denoiser/demucs.py | .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
... | 474 | 16,989 |
fairseq | examples/speech_synthesis/preprocessing/denoiser/resample.py | .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.
:... | 80 | 2,226 |
fairseq | examples/speech_synthesis/preprocessing/speaker_embedder/__init__.py | .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... | 136 | 4,103 |
fairseq | examples/speech_synthesis/evaluation/eval_sp.py | .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... | 132 | 4,149 |
fairseq | examples/speech_synthesis/evaluation/eval_f0.py | .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... | 267 | 8,334 |
fairseq | examples/speech_synthesis/evaluation/get_eval_manifest.py | .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... | 65 | 2,268 |
fairseq | examples/speech_synthesis/evaluation/eval_asr.py | .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... | 129 | 4,654 |
fairseq | examples/translation_moe/score.py | .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.
"""
Scoring script for computing pairwise BLEU and multi-ref BLEU over a set of
candidate hypotheses.
See `"Mixture Mod... | 198 | 6,127 |
fairseq | examples/translation_moe/translation_moe_src/mean_pool_gating_network.py | .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
import torch.nn.functional as F
class MeanPoolGatingNetwork(torch.nn.Module):
"""A simple mean-pooling gating network for s... | 51 | 2,011 |
fairseq | examples/translation_moe/translation_moe_src/translation_moe.py | .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 torch
from omegaconf import II
from fairseq import utils
from fairseq.logging import metrics
... | 260 | 9,534 |
fairseq | examples/translation_moe/translation_moe_src/logsumexp_moe.py | .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
class LogSumExpMoE(torch.autograd.Function):
"""Standard LogSumExp forward pass, but use *posterior* for the backward.
... | 27 | 837 |
fairseq | examples/pointer_generator/preprocess.py | .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 itertools import zip_longest
def replace_oovs(source_in, target_in, vocabulary, source_out, targ... | 103 | 3,337 |
fairseq | examples/pointer_generator/postprocess.py | .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
import sys
class OOVIndexError(IndexError):
def __init__(self, pos, source_seq, target_... | 97 | 3,266 |
fairseq | examples/pointer_generator/pointer_generator_src/transformer_pg.py | .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 Any, Dict, Optional, List, Tuple
import torch
import torch.nn as nn
from fairseq import utils
from fairseq.... | 519 | 23,439 |
fairseq | examples/attention_head_selection/src/speech_to_text_head_selection.py | .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... | 181 | 7,727 |
fairseq | examples/attention_head_selection/src/loss/attention_head_selection.py | .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... | 28 | 872 |
fairseq | examples/attention_head_selection/src/data/speech_to_text_dataset_with_domain.py | .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... | 243 | 8,439 |
fairseq | examples/attention_head_selection/src/modules/attn_head_selector.py | .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... | 82 | 3,074 |
fairseq | examples/attention_head_selection/src/modules/multihead_functional.py | .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,
... | 279 | 11,418 |
fairseq | examples/attention_head_selection/src/modules/head_selection_transformer_layer.py | .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... | 93 | 3,509 |
fairseq | examples/attention_head_selection/src/modules/multihead_attention_selection.py | .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... | 356 | 14,046 |
fairseq | examples/attention_head_selection/src/models/head_selection_s2t_transformer.py | .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... | 171 | 6,831 |
fairseq | examples/attention_head_selection/src/models/head_selection_transformer.py | .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... | 216 | 7,637 |
fairseq | examples/womens_bios/query_occupations_from_wikidata.py | .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... | 34 | 1,201 |
fairseq | examples/rxf/rxf_src/sentence_prediction_r3f.py | .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_... | 172 | 6,587 |
fairseq | examples/rxf/rxf_src/label_smoothed_cross_entropy_r3f.py | .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... | 159 | 6,136 |
fairseq | examples/multilingual/data_scripts/remove_valid_test_in_train.py | .py | import os, sys
import glob, itertools
import pandas as pd
WORKDIR_ROOT = os.environ.get('WORKDIR_ROOT', None)
if WORKDIR_ROOT is None or not WORKDIR_ROOT.strip():
print('please specify your working directory root in OS environment variable WORKDIR_ROOT. Exitting..."')
sys.exit(-1)
def load_langs(path):
... | 290 | 11,158 |
fairseq | examples/multilingual/data_scripts/check_self_overlaps.py | .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
from utils.dedup import deup
import sys
WORKDIR_ROOT = os.environ.get('WORKDIR_ROOT', None)
if WORKDI... | 104 | 3,695 |
fairseq | examples/multilingual/data_scripts/download_ted_and_extract.py | .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 os
import csv
from collections import defaultdict
from six.moves import zip
import io
import wget
import sys
from su... | 339 | 12,515 |
fairseq | examples/multilingual/data_scripts/check_valid_test_overlaps.py | .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 argparse
import pandas as pd
import sys
WORKDIR_ROOT = os.environ.get('WORKDIR_ROOT', None)
if WORKDIR_ROOT is None or n... | 125 | 4,515 |
fairseq | examples/multilingual/data_scripts/check_iswlt_test_data.py | .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, sys
import subprocess
import re
from subprocess import check_call, check_output
WORKDIR_ROOT = os.environ.get('WORKDIR_ROOT', Non... | 68 | 2,761 |
fairseq | examples/multilingual/data_scripts/binarize.py | .py | import shutil
import os, sys
from subprocess import check_call, check_output
import glob
import argparse
import shutil
import pathlib
import itertools
def call_output(cmd):
print(f"Executing: {cmd}")
ret = check_output(cmd, shell=True)
print(ret)
return ret
def call(cmd):
print(cmd)
check_call... | 201 | 6,944 |
fairseq | examples/multilingual/data_scripts/dedup_all.py | .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
from utils.dedup import deup
import sys
WORKDIR_ROOT = os.environ.get('WORKDIR_ROOT', None)
if WORKD... | 53 | 1,796 |
fairseq | examples/multilingual/data_scripts/download_wmt19_and_before.py | .py | from typing import NamedTuple, List
from urllib.parse import urlparse
import os, sys
import subprocess
from subprocess import check_call, check_output
import glob
import wget
import re
import multiprocessing as mp
from functools import partial
import pathlib
from collections import OrderedDict
WORKDIR_ROOT = os.envir... | 900 | 37,648 |
fairseq | examples/multilingual/data_scripts/utils/dedup.py | .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
def deup(src_file, tgt_file, src_file_out, tgt_file_out):
seen = set()
dup_count = 0
with open(src_file, encodin... | 42 | 1,459 |
fairseq | examples/multilingual/data_scripts/utils/fasttext_multi_filter.py | .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.
#!/bin/python
import fasttext
from multiprocessing import Pool
import contextlib
import sys
import argparse
from functools import partial
im... | 64 | 2,340 |
fairseq | examples/data2vec/fb_convert_beit_cp.py | .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 torch
from omegaconf import OmegaConf
from fairseq.criterions.model_criterion import ModelCrit... | 166 | 4,966 |
fairseq | examples/data2vec/tasks/multimodal.py | .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.
import sys
from dataclasses impor... | 166 | 5,254 |
fairseq | examples/data2vec/tasks/mae_image_pretraining.py | .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.
import logging
import sys
from ty... | 120 | 3,617 |
fairseq | examples/data2vec/tasks/image_pretraining.py | .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.
import logging
import sys
import o... | 111 | 2,929 |
fairseq | examples/data2vec/tasks/__init__.py | .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 .image_pretraining import ImagePretrainingTask, ImagePretrainingConfig
from .image_classification import ImageClassificationTask, ImageCl... | 18 | 626 |
fairseq | examples/data2vec/tasks/image_classification.py | .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.
import os.path as osp
import loggi... | 130 | 4,163 |
fairseq | examples/data2vec/tasks/mae_image_classification.py | .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.
import logging
import sys
import t... | 101 | 3,064 |
fairseq | examples/data2vec/tasks/audio_classification.py | .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.
import logging
import os
import nu... | 168 | 5,678 |
fairseq | examples/data2vec/scripts/convert_audioset_labels.py | .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
def get_parser():
parser = argparse.ArgumentParser(description="convert audioset labels... | 64 | 1,991 |
fairseq | examples/data2vec/scripts/text/unprocess_data.py | .py | import json
import os
import tqdm
from fairseq.data import Dictionary, data_utils
def load_dictionary(dict_path):
return Dictionary.load(dict_path)
def load_dataset(split_path, src_dict):
dataset = data_utils.load_indexed_dataset(
split_path,
src_dict,
combine=False, # set to true fo... | 189 | 5,745 |
fairseq | examples/data2vec/scripts/text/glue_lr.py | .py | import os.path as osp
import re
from collections import defaultdict
from valids import parser, main as valids_main
TASK_TO_METRIC = {
"cola": "mcc",
"qnli": "accuracy",
"mrpc": "acc_and_f1",
"rte": "accuracy",
"sst_2": "accuracy",
"mnli": "accuracy",
"qqp": "acc_and_f1",
"sts_b": "pea... | 144 | 5,194 |
fairseq | examples/data2vec/scripts/text/glue.py | .py | from valids import parser, main as valids_main
import os.path as osp
args = parser.parse_args()
args.target = "valid_accuracy"
args.best_biggest = True
args.best = True
args.last = 0
args.path_contains = None
res = valids_main(args, print_output=False)
grouped = {}
for k, v in res.items():
k = osp.dirname(k)
... | 35 | 868 |
fairseq | examples/data2vec/scripts/text/valids.py | .py | import os, argparse, re, json, copy, math
from collections import OrderedDict
import numpy as np
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('base', help='base log path')
parser.add_argument('--file_name', default='train.log', help='the log file name')
parser.add_argument... | 301 | 12,197 |
fairseq | examples/data2vec/data/path_dataset.py | .py | import glob
import os
from typing import List, Optional, Tuple
import logging
import numpy as np
import torchvision.transforms.functional as TF
import PIL
from PIL import Image
from torchvision.datasets import VisionDataset
logger = logging.getLogger(__name__)
class PathDataset(VisionDataset):
def __init__(
... | 65 | 1,788 |
fairseq | examples/data2vec/data/mae_finetuning_image_dataset.py | .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 numpy as np
import os
import torch
from torchvision import datasets, transforms
from timm.data import create_transf... | 136 | 3,520 |
fairseq | examples/data2vec/data/add_class_target_dataset.py | .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.data import BaseWrapperDataset, data_utils
class AddClassTargetDataset(BaseWrapperDataset):
def __init__(
... | 64 | 1,886 |
fairseq | examples/data2vec/data/__init__.py | .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 .image_dataset import ImageDataset
from .path_dataset import PathDataset
from .mae_image_dataset import MaeImageDataset
from .mae_finetun... | 17 | 481 |
fairseq | examples/data2vec/data/modality.py | .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 enum import Enum, auto
clas... | 15 | 394 |
fairseq | examples/data2vec/data/mae_image_dataset.py | .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 functools import partial
import logging
import math
import random
import time
import numpy as np
import os
import torch
from torchvis... | 419 | 13,669 |
fairseq | examples/data2vec/data/image_dataset.py | .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 numpy as np
import os
from typing import Optional, Callable, Set
import torch
from torchvision.datasets.vision impor... | 128 | 3,511 |
fairseq | examples/data2vec/models/data2vec_vision.py | .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.
# The code in this file is adapted from the BeiT implementation which can be found here:
# https://github.com/microsoft/unilm/tree/master/beit... | 728 | 25,697 |
fairseq | examples/data2vec/models/utils.py | .py | import math
import torch
def get_alibi(
max_positions: int,
attention_heads: int,
):
def get_slopes(n):
def get_slopes_power_of_2(n):
start = 2 ** (-(2 ** -(math.log2(n) - 3)))
ratio = start
return [start * ratio ** i for i in range(n)]
# In the paper, w... | 56 | 1,985 |
fairseq | examples/data2vec/models/data2vec_audio.py | .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 math
from dataclasses import dataclass, field
from typing import Optional
from omegaconf import II
import torch
import... | 538 | 17,916 |
fairseq | examples/data2vec/models/mae.py | .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.
# The code in this file is adapted from the BeiT implementation which can be found here:
# https://github.com/microsoft/unilm/tree/master/beit... | 830 | 29,461 |
fairseq | examples/data2vec/models/data2vec_image_classification.py | .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.
# The code in this file is adapted from the BeiT implementation which can be found here:
# https://github.com/microsoft/unilm/tree/master/beit... | 144 | 4,221 |
fairseq | examples/data2vec/models/data2vec2.py | .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 math
from dataclasses import dataclass, field
from typing import Optional, Callable
from functools import partial
import... | 814 | 26,779 |
fairseq | examples/data2vec/models/mae_image_classification.py | .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.
# The code in this file is adapted from the BeiT implementation which can be found here:
# https://github.com/microsoft/unilm/tree/master/beit... | 387 | 13,877 |
fairseq | examples/data2vec/models/audio_classification.py | .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 contextlib
import logging
import re
from dataclasses import dataclass, field
from typing import Any, Optional
import torch
import torc... | 615 | 22,707 |
fairseq | examples/data2vec/models/data2vec_text_classification.py | .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.
# The code in this file is adapted from the BeiT implementation which can be found here:
# https://github.com/microsoft/unilm/tree/master/beit... | 142 | 4,744 |
fairseq | examples/data2vec/models/data2vec_text.py | .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
from typing import Optional
import logging
import math
import torch
import torch.nn as nn
import tor... | 518 | 18,697 |
fairseq | examples/data2vec/models/modalities/modules.py | .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
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from dataclasses import dataclass
from fairseq.modules i... | 590 | 17,247 |
fairseq | examples/data2vec/models/modalities/images.py | .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
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
from functools import partial
from dataclasses import da... | 257 | 7,913 |
fairseq | examples/data2vec/models/modalities/text.py | .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
from functools import partial
from typing import Callable, Dict, Optional
import torch.nn as nn... | 162 | 5,514 |
fairseq | examples/data2vec/models/modalities/audio.py | .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 functools import partial
import torch
import torch.nn as nn
import numpy as np
from dataclasses import dataclass, field
from typing impor... | 193 | 6,619 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.