repo
stringlengths
1
99
file
stringlengths
13
215
code
stringlengths
12
59.2M
file_length
int64
12
59.2M
avg_line_length
float64
3.82
1.48M
max_line_length
int64
12
2.51M
extension_type
stringclasses
1 value
Pgnet
Pgnet-main/loss_function.py
import torch class SAMLoss(torch.nn.Module): def __init__(self): super(SAMLoss, self).__init__() def forward(self, input, label): return _sam(input, label) def _sam(img1, img2): inner_product = torch.sum(img1 * img2, 0) img1_spectral_norm = torch.sqrt(torch.sum(img1 ** 2, 0)) img...
558
23.304348
107
py
Pgnet
Pgnet-main/function.py
import numpy as np import pandas as pd import os import random import time import cv2 from scipy import signal import torch import torch.nn as nn import torch.nn.functional as F import gdal device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu') def write_img_gdal(filename, im_data): # gdal数据类型包括...
8,077
35.387387
144
py
Pgnet
Pgnet-main/Pgnet_structure.py
""" @author: lsl E-mail: cug_lsl@cug.edu.cn """ import numpy as np import torch import torch.nn as nn import torch.nn.functional as F kernelsize_temp = 3 kernelsize_temp2 = 5 padding_mode = 'circular' def log(base, x): return np.log(x) / np.log(base) class simple_net(nn.Module): def __init__(self, ...
9,757
34.483636
115
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/spec.py
import torch def apply_spec_batch(batch, input_spec, device=None): result = {} for k in batch: result[k] = [] seq_type, len_mode, maxlen, minlen = None, None, None, None if k.startswith('query_'): maxlen = input_spec['qlen'] minlen = input_spec.get('qlen_min') ...
2,539
31.564103
74
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/modules/bert.py
from pytorch_transformers.modeling_bert import BertForPreTraining, BertPreTrainedModel, BertEmbeddings, BertEncoder, BertPreTrainingHeads class CustomBertModelWrapper(BertForPreTraining): def __init__(self, config, depth=None): config.output_hidden_states = True super().__init__(config) se...
2,523
41.066667
137
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/modules/rbf_kernels.py
import torch from torch import nn class RbfKernelBank(nn.Module): def __init__(self, mus=None, sigmas=None, dim=0, requires_grad=True): super().__init__() self.mus = nn.Parameter(torch.tensor(mus), requires_grad=requires_grad) self.sigmas = nn.Parameter(torch.tensor(sigmas), requires_grad=...
1,445
38.081081
92
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/modules/interaction_matrix.py
import torch from torch import nn def binmat(a, b, padding=None): BAT, A, B = a.shape[0], a.shape[1], b.shape[1] a = a.reshape(BAT, A, 1) b = b.reshape(BAT, 1, B) result = (a == b) if padding is not None: result = result & (a != padding) & (b != padding) return result.float() def cos...
2,033
34.068966
85
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/bin/perf_benchmark.py
import torch from tqdm import tqdm import onir from onir import injector, util, spec def main(): onir.rankers.base.global_memcache_enable = False context = injector.load({ 'vocab': onir.vocab, 'dataset': onir.datasets.registry.copy(default='random'), 'ranker': onir.rankers, }) ...
2,916
39.513889
113
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/predictors/reranker.py
import os import json import torch import onir from onir import util, spec, predictors, datasets from onir.interfaces import trec, plaintext @predictors.register('reranker') class Reranker(predictors.BasePredictor): name = None @staticmethod def default_config(): return { 'batch_size'...
10,042
42.288793
124
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/util/__init__.py
import os import sys import io import shutil import tempfile import json import math import zlib import random import tarfile import time from glob import glob from contextlib import contextmanager import torch import requests from tqdm import tqdm import numpy as np from scipy.stats import gaussian_kde from onir impor...
11,820
30.355438
148
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/vocab/base.py
import re from torch import nn class VocabEncoder(nn.Module): """ Encodes batches of id sequences """ def __init__(self, vocabulary): super().__init__() self.vocab = vocabulary def forward(self, toks, lens=None): """ Returns embeddings for the given toks. t...
3,954
28.962121
95
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/vocab/bert_vocab.py
import os import tempfile import torch from pytorch_transformers import BertTokenizer from onir.interfaces import bert_models from onir import vocab, util, config from onir.modules import CustomBertModelWrapper import tokenizers as tk @vocab.register('bert') class BertVocab(vocab.Vocab): @staticmethod def def...
9,295
39.417391
133
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/vocab/wordvec_vocab.py
import os import pickle import hashlib import numpy as np import torch from torch import nn from onir import vocab, util, config from onir.interfaces import wordvec _SOURCES = { 'fasttext': { 'wiki-news-300d-1M': wordvec.zip_handler('https://dl.fbaipublicfiles.com/fasttext/vectors-english/wiki-news-300d-1...
6,422
36.343023
134
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/interfaces/bert_models.py
import os import shutil from glob import glob import torch import pytorch_pretrained_bert from pytorch_pretrained_bert import BertForPreTraining, BertConfig from onir import util def _hugging_handler(name, base_path, logger): # Just use the default huggingface handler for model return name def _scibert_hand...
6,704
40.90625
150
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/rankers/drmm.py
import torch from torch import nn from onir import rankers, modules @rankers.register('drmm') class Drmm(rankers.Ranker): """ Implementation of the DRMM model from: > Jiafeng Guo, Yixing Fan, Qingyao Ai, and William Bruce Croft. 2016. A Deep Relevance > Matching Model for Ad-hoc Retrieval. In CIKM...
4,956
38.656
139
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/rankers/base.py
import torch from torch import nn class Ranker(nn.Module): name = None @staticmethod def default_config(): return { 'qlen': 20, 'dlen': 2000, 'add_runscore': False } def __init__(self, config, random): super().__init__() self.config...
2,085
29.231884
76
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/rankers/vanilla_transformer.py
import torch import torch.nn.functional as F from onir import rankers @rankers.register('vanilla_transformer') class VanillaTransformer(rankers.Ranker): """ Implementation of the Vanilla BERT model from: > Sean MacAvaney, Andrew Yates, Arman Cohan, and Nazli Goharian. 2019. CEDR: Contextualized > ...
2,789
39.434783
99
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/rankers/cedr_pacrr.py
import torch from onir import rankers @rankers.register('cedr_pacrr') class CedrPacrr(rankers.pacrr.Pacrr): """ Implementation of CEDR for the PACRR model described in: > Sean MacAvaney, Andrew Yates, Arman Cohan, and Nazli Goharian. 2019. CEDR: Contextualized > Embeddings for Document Ranking. In...
1,450
42.969697
97
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/rankers/conv_knrm.py
import torch from torch import nn from onir import rankers, modules from onir.vocab import wordvec_vocab @rankers.register('conv_knrm') class ConvKnrm(rankers.Ranker): """ Implementation of the ConvKNRM model from: > Zhuyun Dai, Chenyan Xiong, Jamie Callan, and Zhiyuan Liu. 2018. Convolutional Neural ...
6,118
47.563492
132
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/rankers/duetl.py
import torch from torch import nn from onir import rankers, modules @rankers.register('duetl') class DuetL(rankers.Ranker): """ Implementation of the local variant of the Duet model from: > Bhaskar Mitra, Fernando Diaz, and Nick Craswell. 2016. Learning to Match using Local and > Distributed Repre...
2,063
35.857143
96
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/rankers/cedr_drmm.py
import torch from torch import nn from onir import rankers @rankers.register('cedr_drmm') class CedrDrmm(rankers.drmm.Drmm): """ Implementation of CEDR for the DRMM model described in: > Sean MacAvaney, Andrew Yates, Arman Cohan, and Nazli Goharian. 2019. CEDR: Contextualized > Embeddings for Docu...
1,466
44.84375
100
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/rankers/pacrr.py
import torch from torch import nn from torch.nn import functional as F from onir import rankers, util, modules @rankers.register('pacrr') class Pacrr(rankers.Ranker): """ Implementation of the PACRR model from: > Kai Hui, Andrew Yates, Klaus Berberich, and Gerard de Melo. 2017. PACRR: A Position-Aware ...
5,772
36.487013
115
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/rankers/matchpyramid.py
import torch from torch import nn from torch.nn import functional as F from onir import rankers, util, modules @rankers.register('matchpyramid') class MatchPyramid(rankers.Ranker): """ Implementation of the MatchPyramid model for ranking from: > Liang Pang, Yanyan Lan, Jiafeng Guo, Jun Xu, and Xueqi Che...
2,253
37.20339
154
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/rankers/knrm.py
import torch from torch import nn from onir import rankers, modules @rankers.register('knrm') class Knrm(rankers.Ranker): """ Implementation of the K-NRM model from: > Chenyan Xiong, Zhuyun Dai, James P. Callan, Zhiyuan Liu, and Russell Power. 2017. End-to-End > Neural Ad-hoc Ranking with Kernel P...
2,644
39.075758
132
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/rankers/epic.py
import torch import torch.nn.functional as F from onir import rankers, util @rankers.register('epic') class EpicRanker(rankers.Ranker): """ Implementation of the EPIC model from: > Sean MacAvaney, Franco Maria Nardini, Raffaele Perego, Nicola Tonellotto, > Nazli Goharian, and Ophir Frieder. 2020. ...
5,384
42.427419
175
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/rankers/trivial.py
import torch from torch import nn from onir import rankers @rankers.register('trivial') class Trivial(rankers.Ranker): """ Trivial ranker, which just returns the initial ranking score. Used for comparisions against neural ranking approaches. Options allow the score to be inverted (neg), the individua...
2,010
27.323944
98
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/rankers/cedr_knrm.py
import torch from torch import nn from onir import rankers @rankers.register('cedr_knrm') class CedrKnrm(rankers.knrm.Knrm): """ Implementation of CEDR for the KNRM model described in: > Sean MacAvaney, Andrew Yates, Arman Cohan, and Nazli Goharian. 2019. CEDR: Contextualized > Embeddings for Docu...
1,146
39.964286
97
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/pipelines/extract_bert_weights.py
import os from collections import OrderedDict import torch from onir import pipelines, util @pipelines.register('extract_bert_weights') class ExtractBertWeights(pipelines.BasePipeline): @staticmethod def default_config(): return { 'file_path': '', 'epoch': '', 'val_...
1,626
38.682927
129
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/pipelines/epic_vectorize.py
import os import torch import numpy as np import onir from onir import pipelines, util, spec @pipelines.register('epic_vectorize') class EpicVectorize(pipelines.BasePipeline): @staticmethod def default_config(): return { 'file_path': '', 'epoch': '', 'val_metric': '...
4,160
42.34375
142
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/pipelines/epic_predict.py
import os import mmap from multiprocessing.pool import ThreadPool import numpy as np import torch import onir from onir import pipelines, util, spec from onir.interfaces import plaintext, trec logger = onir.log.easy() @pipelines.register('epic_predict') class EpicPredictionPipeline(pipelines.BasePipeline): @stat...
11,828
42.014545
157
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/trainers/base.py
from tqdm import tqdm import torch from onir import util, trainers from onir.interfaces import apex import pickle, os from shutil import copyfile class Trainer: name = None @staticmethod def default_config(): return { 'batch_size': 16, 'batches_per_epoch': 32, '...
11,351
40.28
147
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/trainers/pairwise_ewc.py
import sys import torch import torch.nn.functional as F import onir from onir import trainers, spec, util from tqdm import tqdm from onir import util, trainers from onir.interfaces import apex import pickle, os from shutil import copyfile @trainers.register('pairwise_ewc') class PairwiseEWCTrainer(trainers.Trainer): ...
17,286
42.2175
136
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/trainers/pairwise.py
import sys import torch import torch.nn.functional as F import onir from onir import trainers, spec, util @trainers.register('pairwise') class PairwiseTrainer(trainers.Trainer): @staticmethod def default_config(): result = trainers.Trainer.default_config() result.update({ 'lossfn':...
5,477
40.5
115
py
OpenNIR-Lifelong
OpenNIR-Lifelong-master/onir/trainers/pointwise.py
import sys import torch import torch.nn.functional as F from onir import trainers, spec, datasets @trainers.register('pointwise') class PointwiseTrainer(trainers.Trainer): @staticmethod def default_config(): result = trainers.Trainer.default_config() result.update({ 'source': 'run'...
4,661
46.090909
125
py
EVDI
EVDI-main/codes/Loss.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: ZhangX """ import util import torch import torch.nn as nn def blur_sharp_loss(leftB, num_leftB, rightB, num_rightB, res): ## calculate blur-sharp loss B,N,C,H,W = res.shape if B == 1: # for batch size=1 reblur_leftB = res[:, :num_leftB, :,...
4,621
38.169492
113
py
EVDI
EVDI-main/codes/Dataset.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: ZhangX """ import util import numpy as np from torch.utils.data import Dataset from skimage.morphology import remove_small_objects def adaptive_wei(ts,span_leftB,span_rightB): ## calculate weights, i.e., \omega & 1-\omega in paper right = 0 left =...
10,081
38.382813
170
py
EVDI
EVDI-main/codes/Test.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: ZhangX """ import sys # remove the path of ROS if '/opt/ros/kinetic/lib/python2.7/dist-packages' in sys.path: sys.path.remove('/opt/ros/kinetic/lib/python2.7/dist-packages') import os import cv2 import util import torch import argparse from Dataset import ...
4,518
44.19
119
py
EVDI
EVDI-main/codes/Train.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: ZhangX """ import sys # remove the path of ROS if '/opt/ros/kinetic/lib/python2.7/dist-packages' in sys.path: sys.path.remove('/opt/ros/kinetic/lib/python2.7/dist-packages') import os import cv2 import util import time import torch import argparse import n...
8,115
46.186047
156
py
EVDI
EVDI-main/codes/Networks/networks.py
############################################################################### # Code credit to team Jun-Yan Zhu from project: https://github.com/junyanz/pytorch-CycleGAN-and-pix2pix ############################################################################### import torch import torch.nn as nn from torch.nn import ...
29,432
45.42429
167
py
EVDI
EVDI-main/codes/Networks/EVDI.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: ZhangX """ import torch import torch.nn as nn from Networks.networks import ResnetBlock, get_norm_layer class ChannelAttention(nn.Module): ## channel attention block def __init__(self, in_planes, ratio=16): super(ChannelAttention, self).__ini...
10,888
38.169065
127
py
wenet
wenet-main/tools/onnx2horizonbin.py
# Copyright (c) 2022, Horizon Inc. Xingchen Song (sxc19@tsinghua.org.cn) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required...
20,867
42.026804
83
py
wenet
wenet-main/tools/compute_fbank_feats.py
# Copyright (c) 2020 Mobvoi Inc. (authors: Binbin Zhang, Chao Yang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by a...
4,792
36.155039
77
py
wenet
wenet-main/tools/wav2dur.py
#!/usr/bin/env python3 # encoding: utf-8 import sys import torchaudio torchaudio.set_audio_backend("sox_io") scp = sys.argv[1] dur_scp = sys.argv[2] with open(scp, 'r') as f, open(dur_scp, 'w') as fout: cnt = 0 total_duration = 0 for l in f: items = l.strip().split() wav_id = items[0] ...
660
23.481481
54
py
wenet
wenet-main/tools/compute_cmvn_stats.py
#!/usr/bin/env python3 # encoding: utf-8 import sys import argparse import json import codecs import yaml import torch import torchaudio import torchaudio.compliance.kaldi as kaldi from torch.utils.data import Dataset, DataLoader torchaudio.set_audio_backend("sox_io") class CollateFunc(object): ''' Collate fun...
5,095
34.887324
86
py
wenet
wenet-main/tools/make_shard_list.py
#!/usr/bin/env python3 # Copyright (c) 2021 Mobvoi Inc. (authors: Binbin Zhang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless ...
6,934
35.5
79
py
wenet
wenet-main/tools/analyze_dataset.py
#!/usr/bin/env python3 # Copyright (c) 2022 Horizon Inc. (authors: Xingchen Song) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unles...
9,747
38.148594
78
py
wenet
wenet-main/tools/latency_metrics.py
# Copyright (c) 2022 Horizon Inc. (author: Xingchen Song) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
12,873
41.488449
88
py
wenet
wenet-main/tools/k2/prepare_char.py
#!/usr/bin/env python3 # Copyright 2021 Xiaomi Corp. (authors: Fangjun Kuang, # Wei Kang) # Copyright 2022 Ximalaya Speech Team (author: Xiang Lyu) # # See ../../../../LICENSE for clarification regarding multiple authors # # Licensed under the Apache Licen...
7,540
28.11583
79
py
wenet
wenet-main/examples/vkw2021/s0/local/vkw_kws_results.py
# Copyright (c) 2021 Mobvoi Inc. (authors: Binbin Zhang) # Tencent (Yougen Yuan) # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENS...
10,641
38.857678
79
py
wenet
wenet-main/runtime/gpu/model_repo_stateful/feature_extractor/1/model.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
10,629
39.265152
84
py
wenet
wenet-main/runtime/gpu/model_repo_stateful/wenet/1/model.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
7,166
38.596685
88
py
wenet
wenet-main/runtime/gpu/model_repo_stateful/wenet/1/wenet_onnx_model.py
# Copyright (c) 2021 NVIDIA CORPORATION # 2023 58.com(Wuba) Inc AI Lab. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Un...
13,308
42.071197
87
py
wenet
wenet-main/runtime/gpu/cuda_decoders/model_repo_stateful_cuda_decoder/feature_extractor/1/model.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
10,629
39.265152
84
py
wenet
wenet-main/runtime/gpu/cuda_decoders/model_repo_stateful_cuda_decoder/scoring/1/frame_reducer.py
#!/usr/bin/env python3 # # Copyright 2022 Xiaomi Corp. (authors: Yifan Yang, # Zengwei Yao, # Wei Kang) # # See ../../../../LICENSE for clarification regarding multiple authors # # Licensed under the...
6,579
32.74359
111
py
wenet
wenet-main/runtime/gpu/cuda_decoders/model_repo_stateful_cuda_decoder/scoring/1/model.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
7,279
35.954315
82
py
wenet
wenet-main/runtime/gpu/cuda_decoders/model_repo_stateful_cuda_decoder/scoring/1/decoder.py
import os import torch from typing import List from riva.asrlib.decoder.python_decoder import ( BatchedMappedOnlineDecoderCuda, BatchedMappedDecoderCudaConfig, ) # from frame_reducer import FrameReducer def make_pad_mask(lengths: torch.Tensor, max_len: int = 0) -> torch.Tensor: """Make mask tensor contain...
5,680
36.130719
85
py
wenet
wenet-main/runtime/gpu/cuda_decoders/model_repo_cuda_decoder/feature_extractor/1/model.py
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
6,436
39.484277
88
py
wenet
wenet-main/runtime/gpu/cuda_decoders/model_repo_cuda_decoder/scoring/1/frame_reducer.py
#!/usr/bin/env python3 # # Copyright 2022 Xiaomi Corp. (authors: Yifan Yang, # Zengwei Yao, # Wei Kang) # # See ../../../../LICENSE for clarification regarding multiple authors # # Licensed under the...
6,558
32.809278
111
py
wenet
wenet-main/runtime/gpu/cuda_decoders/model_repo_cuda_decoder/scoring/1/model.py
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
10,656
41.12253
127
py
wenet
wenet-main/runtime/gpu/cuda_decoders/model_repo_cuda_decoder/scoring/1/decoder.py
import os import torch from typing import List from riva.asrlib.decoder.python_decoder import (BatchedMappedDecoderCuda, BatchedMappedDecoderCudaConfig) from frame_reducer import FrameReducer def make_pad_mask(lengths: torch.Tensor, max_len: int = 0) -> torch.Tensor: ...
6,560
46.201439
154
py
wenet
wenet-main/runtime/gpu/scripts/benchmark_onnx_throughput.py
#!/usr/bin/env python3 # # Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # #...
13,408
27.469214
107
py
wenet
wenet-main/runtime/gpu/scripts/convert.py
#!/usr/bin/env python3 # Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # U...
5,970
45.648438
84
py
wenet
wenet-main/runtime/gpu/tensorrt/export_streaming_conformer_trt.py
#!/usr/bin/env python3 # # Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # #...
10,994
30.235795
110
py
wenet
wenet-main/runtime/gpu/tensorrt/model_repo_stateful_trt/feature_extractor/1/model.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
10,629
39.265152
84
py
wenet
wenet-main/runtime/gpu/tensorrt/model_repo_stateful_trt/wenet/1/model.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
7,166
38.596685
88
py
wenet
wenet-main/runtime/gpu/tensorrt/model_repo_stateful_trt/wenet/1/wenet_onnx_model.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
11,922
41.888489
87
py
wenet
wenet-main/runtime/gpu/model_repo/feature_extractor/1/model.py
import triton_python_backend_utils as pb_utils from torch.utils.dlpack import to_dlpack import torch import numpy as np import kaldifeat import _kaldifeat from typing import List import json class Fbank(torch.nn.Module): def __init__(self, opts): super(Fbank, self).__init__() self.fbank = kaldifeat...
5,864
38.897959
88
py
wenet
wenet-main/runtime/gpu/model_repo/scoring/1/model.py
# Copyright (c) 2021 NVIDIA CORPORATION # 2023 58.com(Wuba) Inc AI Lab. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Un...
14,022
41.753049
88
py
wenet
wenet-main/runtime/gpu/tensorrt_fastertransformer/model_repo_ft/feature_extractor/1/model.py
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
6,436
39.484277
88
py
wenet
wenet-main/runtime/gpu/tensorrt_fastertransformer/model_repo_ft/scoring/1/model.py
# Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
13,298
40.046296
82
py
wenet
wenet-main/runtime/web/app.py
import json import gradio as gr import numpy as np import torch import wenetruntime as wenet torch.manual_seed(777) # for lint wenet.set_log_level(2) decoder = wenet.Decoder(lang='chs') def recognition(audio): sr, y = audio assert sr in [48000, 16000] if sr == 48000: # Optional resample to 16000 ...
601
25.173913
64
py
wenet
wenet-main/runtime/web/streaming_app.py
import json import gradio as gr import numpy as np import torch import wenetruntime as wenet torch.manual_seed(777) # for lint wenet.set_log_level(2) decoder = wenet.Decoder(lang='chs') def recognition(audio): sr, y = audio assert sr in [48000, 16000] if sr == 48000: # Optional resample to 16000 ...
1,268
30.725
79
py
wenet
wenet-main/runtime/binding/python/setup.py
#!/usr/bin/env python3 # Copyright (c) 2020 Xiaomi Corporation (author: Fangjun Kuang) # 2022 Binbin Zhang(binbzha@qq.com) import glob import os import shutil import sys import setuptools from setuptools.command.build_ext import build_ext def cmake_extension(name, *args, **kwargs) -> setuptools.Ex...
3,063
32.304348
79
py
wenet
wenet-main/docs/conf.py
# Configuration file for the Sphinx documentation builder. # # This file only contains a selection of the most common options. For a full # list see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html # -- Path setup -------------------------------------------------------------- # If ex...
2,314
31.152778
79
py
wenet
wenet-main/wenet/transducer/predictor.py
from typing import List, Optional, Tuple import torch from torch import nn from wenet.utils.common import get_activation, get_rnn def ApplyPadding(input, padding, pad_value) -> torch.Tensor: """ Args: input: [bs, max_time_step, dim] padding: [bs, max_time_step] """ return padding * ...
17,293
35.104384
78
py
wenet
wenet-main/wenet/transducer/joint.py
from typing import Optional import torch from torch import nn from wenet.utils.common import get_activation class TransducerJoint(torch.nn.Module): def __init__(self, voca_size: int, enc_output_size: int, pred_output_size: int, join_dim: int, ...
2,513
33.438356
76
py
wenet
wenet-main/wenet/transducer/transducer.py
from typing import Dict, List, Optional, Tuple, Union try: import k2 except ImportError: print('Failed to import k2 \ Notice that they are necessary for \ k2 rnnt loss training') import torch import torchaudio from torch import nn from torch.nn.utils.rnn import pad_sequence from wenet.transduc...
22,837
38.649306
88
py
wenet
wenet-main/wenet/transducer/search/greedy_search.py
from typing import List import torch def basic_greedy_search( model: torch.nn.Module, encoder_out: torch.Tensor, encoder_out_lens: torch.Tensor, n_steps: int = 64, ) -> List[List[int]]: # fake padding padding = torch.zeros(1, 1).to(encoder_out.device) # sos pred_input_step = torch.ten...
1,960
34.654545
82
py
wenet
wenet-main/wenet/transducer/search/prefix_beam_search.py
from typing import List, Tuple import torch from wenet.utils.common import log_add class Sequence(): __slots__ = {'hyp', 'score', 'cache'} def __init__( self, hyp: List[torch.Tensor], score, cache: List[torch.Tensor], ): self.hyp = hyp self.score = score ...
5,967
39.053691
81
py
wenet
wenet-main/wenet/dataset/wav_distortion.py
# Copyright (c) 2021 Mobvoi Inc (Chao Yang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
9,373
27.843077
81
py
wenet
wenet-main/wenet/dataset/dataset.py
# Copyright (c) 2021 Mobvoi Inc. (authors: Binbin Zhang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable l...
6,662
33.345361
77
py
wenet
wenet-main/wenet/dataset/processor.py
# Copyright (c) 2021 Mobvoi Inc. (authors: Binbin Zhang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable l...
20,846
31.270898
79
py
wenet
wenet-main/wenet/paraformer/utils.py
# Copyright (c) 2023 ASLP@NWPU (authors: He Wang, Fan Yu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
2,244
32.014706
76
py
wenet
wenet-main/wenet/paraformer/paraformer.py
# Copyright (c) 2020 Mobvoi Inc. (authors: Binbin Zhang, Di Wu) # 2023 ASLP@NWPU (authors: He Wang, Fan Yu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.ap...
13,905
40.020649
79
py
wenet
wenet-main/wenet/paraformer/search/ctc.py
# Copyright (c) 2023 ASLP@NWPU (authors: He Wang, Fan Yu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
5,716
31.856322
80
py
wenet
wenet-main/wenet/paraformer/search/ctc_prefix_score.py
# Copyright (c) 2023 ASLP@NWPU (authors: He Wang, Fan Yu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
14,679
38.146667
80
py
wenet
wenet-main/wenet/paraformer/search/beam_search.py
# Copyright (c) 2023 ASLP@NWPU (authors: He Wang, Fan Yu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
17,306
35.745223
80
py
wenet
wenet-main/wenet/paraformer/search/scorer_interface.py
# Copyright (c) 2023 ASLP@NWPU (authors: He Wang, Fan Yu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable la...
6,575
31.235294
80
py
wenet
wenet-main/wenet/bin/export_jit.py
# Copyright (c) 2020 Mobvoi Inc. (authors: Binbin Zhang, Di Wu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
2,357
32.211268
79
py
wenet
wenet-main/wenet/bin/average_model.py
# Copyright (c) 2020 Mobvoi Inc (Di Wu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in ...
3,484
33.166667
76
py
wenet
wenet-main/wenet/bin/export_onnx_bpu.py
# Copyright (c) 2022, Horizon Inc. Xingchen Song (sxc19@tsinghua.org.cn) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required...
41,476
39.663725
87
py
wenet
wenet-main/wenet/bin/export_onnx_gpu.py
# Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by appli...
45,863
35.632588
86
py
wenet
wenet-main/wenet/bin/export_onnx_cpu.py
# Copyright (c) 2022, Xingchen Song (sxc19@mails.tsinghua.edu.cn) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by app...
18,019
42.737864
88
py
wenet
wenet-main/wenet/bin/export_ipex.py
# Copyright (C) 2021-2023 Intel Corporation # SPDX-License-Identifier: Apache-2.0 from __future__ import print_function import argparse import os import torch import yaml from wenet.utils.checkpoint import load_checkpoint from wenet.utils.init_model import init_model import intel_extension_for_pytorch as ipex from ...
3,457
34.649485
86
py
wenet
wenet-main/wenet/bin/recognize_onnx_gpu.py
# Copyright (c) 2020 Mobvoi Inc. (authors: Binbin Zhang, Xiaoyu Chen, Di Wu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requ...
12,497
43.635714
87
py
wenet
wenet-main/wenet/bin/alignment.py
# Copyright (c) 2021 Mobvoi Inc. (authors: Di Wu) # 2022 Tinnove Inc (authors: Wei Ren) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LI...
8,894
36.690678
80
py
wenet
wenet-main/wenet/bin/recognize.py
# Copyright (c) 2020 Mobvoi Inc. (authors: Binbin Zhang, Xiaoyu Chen, Di Wu) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless requ...
17,388
44.049223
80
py
wenet
wenet-main/wenet/bin/train.py
# Copyright (c) 2021 Mobvoi Inc. (authors: Binbin Zhang) # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable l...
20,379
44.389755
103
py
wenet
wenet-main/wenet/efficient_conformer/encoder_layer.py
# Copyright (c) 2021 Mobvoi Inc (Binbin Zhang, Di Wu) # 2022 Xingchen Song (sxc19@mails.tsinghua.edu.cn) # 2022 58.com(Wuba) Inc AI Lab. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a c...
6,921
39.95858
79
py
wenet
wenet-main/wenet/efficient_conformer/subsampling.py
# Copyright (c) 2021 Mobvoi Inc (Binbin Zhang, Di Wu) # 2022 58.com(Wuba) Inc AI Lab. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENS...
2,676
33.320513
74
py