repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
MICCAI21_MMQ
MICCAI21_MMQ-main/tools/compute_softscore.py
""" This code is slightly modified from Hengyuan Hu's repository. https://github.com/hengyuan-hu/bottom-up-attention-vqa """ from __future__ import print_function import os import sys import json import numpy as np import re import _pickle as cPickle sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__fi...
10,849
36.673611
117
py
MICCAI21_MMQ
MICCAI21_MMQ-main/tools/create_dictionary.py
""" This code is from Hengyuan Hu's repository. https://github.com/hengyuan-hu/bottom-up-attention-vqa """ from __future__ import print_function import os import sys import json import numpy as np sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from dataset_VQA import Dictionary def create...
1,702
29.410714
76
py
MICCAI21_MMQ
MICCAI21_MMQ-main/mmq_maml/VQA_RAD_train.py
import torch, os import numpy as np from VQA_RAD import VQARAD_maml import scipy.stats from torch.utils.data import DataLoader import argparse import time from meta import Meta def mean_confidence_interval(accs, confidence=0.95): n = accs.shape[0] m, se = np.mean(accs), scipy.stats.sem(accs) h =...
4,249
37.990826
137
py
MICCAI21_MMQ
MICCAI21_MMQ-main/mmq_maml/VQA_RAD_fuse.py
import torch, os import numpy as np from VQA_RAD import VQARAD_maml import scipy.stats from torch.utils.data import DataLoader import argparse import time from meta import Meta import pickle as p def mean_confidence_interval(accs, confidence=0.95): n = accs.shape[0] m, se = np.mean(accs), scipy.stat...
7,237
40.597701
145
py
MICCAI21_MMQ
MICCAI21_MMQ-main/mmq_maml/pathVQA_maml.py
import os import torch from torch.utils.data import Dataset from torchvision.transforms import transforms import numpy as np from PIL import Image import random class PathVQA_maml(Dataset): """ NOTICE: meta-learning is different from general supervised learning, especially the concept of batch and set. ba...
12,430
47.74902
155
py
MICCAI21_MMQ
MICCAI21_MMQ-main/mmq_maml/learner.py
import torch from torch import nn from torch.nn import functional as F import numpy as np class Learner(nn.Module): """ """ def __init__(self, config, imgc, imgsz): """ :param config: network config file, type:list of (string, list) :param imgc: 1 or 3 :param im...
7,789
34.733945
111
py
MICCAI21_MMQ
MICCAI21_MMQ-main/mmq_maml/VQA_RAD.py
import os import torch from torch.utils.data import Dataset from torchvision.transforms import transforms import numpy as np from PIL import Image import random class VQARAD_maml(Dataset): """ NOTICE: meta-learning is different from general supervised learning, especially the concept of batch and set. bat...
11,779
46.692308
155
py
MICCAI21_MMQ
MICCAI21_MMQ-main/mmq_maml/pathVQA_maml_train.py
import torch, os import numpy as np from pathVQA_maml import PathVQA_maml import scipy.stats from torch.utils.data import DataLoader import argparse import time from meta import Meta def mean_confidence_interval(accs, confidence=0.95): n = accs.shape[0] m, se = np.mean(accs), scipy.stats.sem(accs) ...
5,532
40.291045
143
py
MICCAI21_MMQ
MICCAI21_MMQ-main/mmq_maml/pathVQA_maml_fuse.py
import torch, os import numpy as np from pathVQA_maml import PathVQA_maml import scipy.stats from torch.utils.data import DataLoader import argparse import time from meta import Meta import pickle as p def mean_confidence_interval(accs, confidence=0.95): n = accs.shape[0] m, se = np.mean(accs), scipy...
7,202
39.926136
141
py
MICCAI21_MMQ
MICCAI21_MMQ-main/mmq_maml/VQA_RAD_half.py
import torch, os import numpy as np from VQA_RAD import VQARAD_maml import scipy.stats from torch.utils.data import DataLoader import argparse import time from meta import Meta import shutil def mean_confidence_interval(accs, confidence=0.95): n = accs.shape[0] m, se = np.mean(accs), scipy.stats.sem(...
8,795
38.621622
138
py
MICCAI21_MMQ
MICCAI21_MMQ-main/mmq_maml/meta.py
import torch from torch import nn from torch import optim from torch.nn import functional as F from torch.utils.data import TensorDataset, DataLoader from torch import optim import numpy as np from learner import Learner from copy import deepcopy class Meta(nn.Module): """ Meta Learne...
12,796
34.350829
110
py
MICCAI21_MMQ
MICCAI21_MMQ-main/mmq_maml/pathVQA_maml_half.py
import torch, os import numpy as np from pathVQA_maml import PathVQA_maml import scipy.stats from torch.utils.data import DataLoader import argparse import time from meta import Meta import shutil def mean_confidence_interval(accs, confidence=0.95): n = accs.shape[0] m, se = np.mean(accs), scipy.stat...
8,907
38.591111
144
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/test.py
"""General-purpose test script for image-to-image translation. Once you have trained your model with train.py, you can use this script to test the model. It will load a saved model from '--checkpoints_dir' and save the results to '--results_dir'. It first creates model and dataset given the option. It will hard-code ...
4,545
55.123457
130
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/train.py
"""General-purpose training script for image-to-image translation. This script works for various models (with option '--model': e.g., pix2pix, cyclegan, colorization) and different datasets (with option '--dataset_mode': e.g., aligned, unaligned, single, colorization). You need to specify the dataset ('--dataroot'), e...
4,933
62.25641
186
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/options/train_options.py
from .base_options import BaseOptions class TrainOptions(BaseOptions): """This class includes training options. It also includes shared options defined in BaseOptions. """ def initialize(self, parser): parser = BaseOptions.initialize(self, parser) # visdom and HTML visualization para...
3,447
83.097561
210
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/options/base_options.py
import argparse import os from util import util import torch import models import data class BaseOptions(): """This class defines options used during both training and test time. It also implements several helper functions such as parsing, printing, and saving the options. It also gathers additional opti...
8,327
58.485714
235
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/options/__init__.py
"""This package options includes option modules: training options, test options, and basic options (used in both training and test)."""
136
67.5
135
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/options/test_options.py
from .base_options import BaseOptions class TestOptions(BaseOptions): """This class includes test options. It also includes shared options defined in BaseOptions. """ def initialize(self, parser): parser = BaseOptions.initialize(self, parser) # define shared options parser.add_argum...
1,158
47.291667
108
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/models/base_model.py
import os import torch from collections import OrderedDict from abc import ABC, abstractmethod from . import networks class BaseModel(ABC): """This class is an abstract base class (ABC) for models. To create a subclass, you need to implement the following five functions: -- <__init__>: ...
10,407
44.056277
260
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/models/colorization_model.py
from .pix2pix_model import Pix2PixModel import torch from skimage import color # used for lab2rgb import numpy as np class ColorizationModel(Pix2PixModel): """This is a subclass of Pix2PixModel for image colorization (black & white image -> colorful images). The model training requires '-dataset_model color...
3,013
42.681159
141
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/models/pix2pix_model.py
import torch from .base_model import BaseModel from . import networks class Pix2PixModel(BaseModel): """ This class implements the pix2pix model, for learning a mapping from input images to output images given paired data. The model training requires '--dataset_mode aligned' dataset. By default, it uses ...
6,519
49.9375
162
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/models/networks.py
import torch import torch.nn as nn from torch.nn import init import functools from torch.optim import lr_scheduler ############################################################################### # Helper Functions ############################################################################### class Identity(nn.Modu...
28,408
45.04376
167
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/models/template_model.py
"""Model class template This module provides a template for users to implement custom models. You can specify '--model template' to use this model. The class name should be consistent with both the filename and its model option. The filename should be <model>_dataset.py The class name should be <Model>Dataset.py It im...
5,951
58.52
177
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/models/__init__.py
"""This package contains modules related to objective functions, optimizations, and network architectures. To add a custom model class called 'dummy', you need to add a file called 'dummy_model.py' and define a subclass DummyModel inherited from BaseModel. You need to implement the following five functions: -- <__...
3,072
44.191176
250
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/models/test_model.py
from .base_model import BaseModel from . import networks class TestModel(BaseModel): """ This TesteModel can be used to generate CycleGAN results for only one direction. This model will automatically set '--dataset_mode single', which only loads the images from one collection. See the test instruction fo...
3,151
44.028571
160
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/models/cycle_gan_model.py
import torch import itertools from util.image_pool import ImagePool from .base_model import BaseModel from . import networks class CycleGANModel(BaseModel): """ This class implements the CycleGAN model, for learning image-to-image translation without paired data. The model training requires '--dataset_mo...
10,557
53.14359
362
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/util/image_pool.py
import random import torch class ImagePool(): """This class implements an image buffer that stores previously generated images. This buffer enables us to update discriminators using a history of generated images rather than the ones produced by the latest generators. """ def __init__(self, pool_...
2,226
39.490909
140
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/util/html.py
import dominate from dominate.tags import meta, h3, table, tr, td, p, a, img, br import os class HTML: """This HTML class allows us to save images and write texts into a single HTML file. It consists of functions such as <add_header> (add a text header to the HTML file), <add_images> (add a row of imag...
3,223
36.057471
157
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/util/visualizer.py
import numpy as np import os import sys import ntpath import time from . import util, html from subprocess import Popen, PIPE try: import wandb except ImportError: print('Warning: wandb package cannot be found. The option "--use_wandb" will result in error.') if sys.version_info[0] == 2: VisdomExceptionB...
11,890
45.089147
139
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/util/util.py
"""This module contains simple helper functions """ from __future__ import print_function import torch import numpy as np from PIL import Image import os def tensor2im(input_image, imtype=np.uint8): """"Converts a Tensor array into a numpy image array. Parameters: input_image (tensor) -- the input i...
3,175
29.538462
119
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/util/__init__.py
"""This package includes a miscellaneous collection of useful helper functions."""
83
41
82
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/util/get_data.py
from __future__ import print_function import os import tarfile import requests from warnings import warn from zipfile import ZipFile from bs4 import BeautifulSoup from os.path import abspath, isdir, join, basename class GetData(object): """A Python script for downloading CycleGAN or pix2pix datasets. Paramet...
3,639
31.792793
90
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/scripts/test_before_push.py
# Simple script to make sure basic usage # such as training, testing, saving and loading # runs without errors. import os def run(command): print(command) exit_status = os.system(command) if exit_status > 0: exit(1) if __name__ == '__main__': # download mini datasets if not os.path.exist...
2,722
51.365385
178
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/scripts/edges/batch_hed.py
# HED batch processing script; modified from https://github.com/s9xie/hed/blob/master/examples/hed/HED-tutorial.ipynb # Step 1: download the hed repo: https://github.com/s9xie/hed # Step 2: download the models and protoxt, and put them under {caffe_root}/examples/hed/ # Step 3: put this script under {caffe_root}/exampl...
3,521
41.95122
141
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/scripts/eval_cityscapes/evaluate.py
import os import caffe import argparse import numpy as np import scipy.misc from PIL import Image from util import segrun, fast_hist, get_scores from cityscapes import cityscapes parser = argparse.ArgumentParser() parser.add_argument("--cityscapes_dir", type=str, required=True, help="Path to the original cityscapes da...
3,403
47.628571
170
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/scripts/eval_cityscapes/cityscapes.py
# The following code is modified from https://github.com/shelhamer/clockwork-fcn import sys import os import glob import numpy as np from PIL import Image class cityscapes: def __init__(self, data_path): # data_path something like /data2/cityscapes self.dir = data_path self.classes = ['roa...
5,772
39.65493
138
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/scripts/eval_cityscapes/util.py
# The following code is modified from https://github.com/shelhamer/clockwork-fcn import numpy as np def get_out_scoremap(net): return net.blobs['score'].data[0].argmax(axis=0).astype(np.uint8) def feed_net(net, in_): """ Load prepared input into net. """ net.blobs['data'].reshape(1, *in_.shape) ...
1,051
23.465116
80
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/datasets/combine_A_and_B.py
import os import numpy as np import cv2 import argparse from multiprocessing import Pool def image_write(path_A, path_B, path_AB): im_A = cv2.imread(path_A, 1) # python2: cv2.CV_LOAD_IMAGE_COLOR; python3: cv2.IMREAD_COLOR im_B = cv2.imread(path_B, 1) # python2: cv2.CV_LOAD_IMAGE_COLOR; python3: cv2.IMREAD_COL...
3,002
43.161765
181
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/datasets/prepare_cityscapes_dataset.py
import os import glob from PIL import Image help_msg = """ The dataset can be downloaded from https://cityscapes-dataset.com. Please download the datasets [gtFine_trainvaltest.zip] and [leftImg8bit_trainvaltest.zip] and unzip them. gtFine contains the semantics segmentations. Use --gtFine_dir to specify the path to th...
4,126
40.27
142
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/datasets/make_dataset_aligned.py
import os from PIL import Image def get_file_paths(folder): image_file_paths = [] for root, dirs, filenames in os.walk(folder): filenames = sorted(filenames) for filename in filenames: input_path = os.path.abspath(root) file_path = os.path.join(input_path, filename) ...
2,257
34.28125
97
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/data/colorization_dataset.py
import os from data.base_dataset import BaseDataset, get_transform from data.image_folder import make_dataset from skimage import color # require skimage from PIL import Image import numpy as np import torchvision.transforms as transforms class ColorizationDataset(BaseDataset): """This dataset class can load a s...
2,717
38.391304
141
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/data/base_dataset.py
"""This module implements an abstract base class (ABC) 'BaseDataset' for datasets. It also includes common transformation functions (e.g., get_transform, __scale_width), which can be later used in subclasses. """ import random import numpy as np import torch.utils.data as data from PIL import Image import torchvision....
5,895
34.095238
141
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/data/unaligned_dataset.py
import os from data.base_dataset import BaseDataset, get_transform from data.image_folder import make_dataset from PIL import Image import random class UnalignedDataset(BaseDataset): """ This dataset class can load unaligned/unpaired datasets. It requires two directories to host training images from doma...
3,299
44.833333
122
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/data/image_folder.py
"""A modified image folder class We modify the official PyTorch image folder (https://github.com/pytorch/vision/blob/master/torchvision/datasets/folder.py) so that this class can load images from both current directory and its subdirectories. """ import torch.utils.data as data from PIL import Image import os IMG_E...
1,885
27.575758
122
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/data/aligned_dataset.py
import os from data.base_dataset import BaseDataset, get_params, get_transform from data.image_folder import make_dataset from PIL import Image class AlignedDataset(BaseDataset): """A dataset class for paired image dataset. It assumes that the directory '/path/to/data/train' contains image pairs in the form ...
2,497
39.95082
118
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/data/__init__.py
"""This package includes all the modules related to data loading and preprocessing To add a custom dataset class called 'dummy', you need to add a file called 'dummy_dataset.py' and define a subclass 'DummyDataset' inherited from BaseDataset. You need to implement four functions: -- <__init__>: ...
3,554
36.819149
176
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/data/template_dataset.py
"""Dataset class template This module provides a template for users to implement custom datasets. You can specify '--dataset_mode template' to use this dataset. The class name should be consistent with both the filename and its dataset_mode option. The filename should be <dataset_mode>_dataset.py The class name should...
3,506
45.144737
156
py
pytorch-CycleGAN-and-pix2pix
pytorch-CycleGAN-and-pix2pix-master/data/single_dataset.py
from data.base_dataset import BaseDataset, get_transform from data.image_folder import make_dataset from PIL import Image class SingleDataset(BaseDataset): """This dataset class can load a set of images specified by the path --dataroot /path/to/data. It can be used for generating CycleGAN results only for on...
1,495
35.487805
105
py
sign-topic
sign-topic-main/setup.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 os import subprocess import sys from setuptools import Extension, find_packages, setup if sys.version_info < (...
8,427
28.263889
92
py
sign-topic
sign-topic-main/hubconf.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. """isort:skip_file""" import functools import importlib dependencies = [ "dataclasses", "hydra", "numpy", "omegaconf", "...
2,099
27.378378
82
py
sign-topic
sign-topic-main/train.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. """ Legacy entry point. Use fairseq_cli/train.py or fairseq-train instead. """ from fairseq_cli.train import cli_mai...
366
23.466667
70
py
sign-topic
sign-topic-main/examples/__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. try: from fairseq.version import __version__ # noqa except ImportError: pass
264
25.5
65
py
sign-topic
sign-topic-main/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. import logging from dataclasses import dataclass, field from typing import Dict, List, Optional import torch from fairseq.dataclass import Fa...
5,324
33.134615
86
py
sign-topic
sign-topic-main/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. from . import transformer_xl_model, truncated_bptt_lm_task # noqa
245
34.142857
66
py
sign-topic
sign-topic-main/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 import os from dataclasses import dataclass, field from typing import List, Optional, Tuple import torch from fairseq import u...
9,995
33.951049
86
py
sign-topic
sign-topic-main/examples/linformer/linformer_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. from .models import linformer_roberta # noqa
224
31.142857
65
py
sign-topic
sign-topic-main/examples/linformer/linformer_src/modules/multihead_linear_attention.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 typing import Dict, Optional, Tuple import torch import torch.nn.functional as F from fairseq import utils from fairseq.incr...
19,151
38.73444
98
py
sign-topic
sign-topic-main/examples/linformer/linformer_src/modules/linformer_sentence_encoder.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.nn as nn from fairseq.models.transformer import TransformerEncoder from .linformer_sentence_encoder_layer import Li...
2,151
38.127273
85
py
sign-topic
sign-topic-main/examples/linformer/linformer_src/modules/__init__.py
0
0
0
py
sign-topic
sign-topic-main/examples/linformer/linformer_src/modules/linformer_sentence_encoder_layer.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.modules import TransformerEncoderLayer from .multihead_linear_attention import MultiheadL...
2,743
40.575758
85
py
sign-topic
sign-topic-main/examples/linformer/linformer_src/models/linformer_roberta.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. """ Linformer: Self-Attention with Linear Complexity """ import logging import torch from fairseq import utils from fairseq.models import reg...
4,143
33.247934
84
py
sign-topic
sign-topic-main/examples/linformer/linformer_src/models/__init__.py
0
0
0
py
sign-topic
sign-topic-main/examples/wav2vec/vq-wav2vec_featurize.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...
7,680
29.601594
99
py
sign-topic
sign-topic-main/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. """ Data pre-processing: build vocabularies and binarize training data. """ import argparse import glob import os impor...
2,513
27.568182
98
py
sign-topic
sign-topic-main/examples/wav2vec/wav2vec_featurize.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...
7,020
27.084
135
py
sign-topic
sign-topic-main/examples/wav2vec/__init__.py
0
0
0
py
sign-topic
sign-topic-main/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...
1,875
31.912281
97
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/w2vu_generate.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...
22,210
30.371469
129
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/__init__.py
0
0
0
py
sign-topic
sign-topic-main/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 dataclasses import dataclass from enum import Enum, auto import math import numpy as np from typing import Tuple, List, Optional, Dict i...
20,954
31.844828
90
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/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 .wav2vec_u import Wav2vec_U __all__ = [ "Wav2vec_U", ]
244
19.416667
65
py
sign-topic
sign-topic-main/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 sys def main(): for line in sys.stdin: print(line.replace(" ", "").replace("|", " ").strip()) ...
359
20.176471
65
py
sign-topic
sign-topic-main/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 os import os.path as osp import numpy as np import tqdm import torch import sys import faiss...
4,015
30.131783
129
py
sign-topic
sign-topic-main/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 argparse import os import os.path as osp import numpy as np import tqdm import torch import random from shuti...
3,543
29.817391
110
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/scripts/normalize_and_filter_text.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...
1,997
26.369863
114
py
sign-topic
sign-topic-main/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. """ get intervals from .vads file, specify output data, and this script removes silences and saves the audio data in...
1,927
29.125
128
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/scripts/normalize_text.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...
489
20.304348
65
py
sign-topic
sign-topic-main/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 numpy as np import sys def get_parser(): parser = argparse.ArgumentParser( desc...
2,045
23.357143
95
py
sign-topic
sign-topic-main/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 sys from fairseq.data import Dictionary def get_parser(): parser = argparse.ArgumentPa...
939
21.926829
83
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/scripts/wrd_to_ltr.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(" ", "|"))) + "...
365
20.529412
68
py
sign-topic
sign-topic-main/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 os import argparse import sys parser = argparse.ArgumentParser() parser.add_argument("--tsv", required=True...
955
24.157895
71
py
sign-topic
sign-topic-main/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. import argparse import sys from g2p_en import G2p def main(): parser = argparse.ArgumentParser() parser.a...
1,104
23.021739
81
py
sign-topic
sign-topic-main/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 os import os.path as osp import math import numpy as np import tqdm import torch from shutil ...
2,496
31.428571
114
py
sign-topic
sign-topic-main/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 argparse import gc import os import os.path as osp import random import numpy as np import tqdm import torch ...
6,315
28.933649
129
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/scripts/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 os import os.path as osp import numpy as np import faiss def get_parser(): parser = a...
1,471
26.259259
103
py
sign-topic
sign-topic-main/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 argparse import os import os.path as osp import math import numpy as np import tqdm import torch import torch...
3,187
30.88
144
py
sign-topic
sign-topic-main/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 sys for idx, line in enumerate(sys.stdin): print(f"utt{idx:010d} {line}", end="")
298
26.181818
65
py
sign-topic
sign-topic-main/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 sys from copy import deepcopy from scipy.signal import lfilter import numpy as np from tqdm...
2,569
24.959596
79
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/scripts/wav2vec_extract_features.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...
3,673
29.616667
105
py
sign-topic
sign-topic-main/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. """ Implement unsupervised metric for decoding hyperparameter selection: $$ alpha * LM_PPL + ViterbitUER(%) * 10...
2,264
26.289157
87
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/kaldi_self_train/st/local/prepare_data_from_w2v.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...
2,137
36.508772
84
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/kaldi_self_train/st/local/copy_aligned_text.py
import sys for idx, line in enumerate(sys.stdin): print(f"utt{idx:010d} {line}", end='')
93
22.5
42
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/kaldi_self_train/st/local/unsup_select.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...
4,767
34.058824
134
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/data/random_input_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):...
1,905
29.253968
78
py
sign-topic
sign-topic-main/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. from .extracted_features_dataset import ExtractedFeaturesDataset from .random_input_dataset import RandomInputDataset __all__ = [ "Extra...
370
25.5
65
py
sign-topic
sign-topic-main/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 logging import os import contextlib import numpy as np import torch from fairseq.data import FairseqDataset, data_utils logger = l...
4,170
27.765517
87
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/tasks/unpaired_audio_text.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,...
15,435
33.455357
102
py
sign-topic
sign-topic-main/examples/wav2vec/unsupervised/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 .unpaired_audio_text import UnpairedAudioText __all__ = [ "UnpairedAudioText", ]
270
21.583333
65
py
sign-topic
sign-topic-main/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. """ Translate pre-processed data with a trained model. """ import numpy as np import torch from fairseq import check...
7,473
33.762791
90
py
sign-topic
sign-topic-main/examples/criss/sentence_retrieval/encoder_analysis.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...
3,278
34.258065
82
py