code stringlengths 17 6.64M |
|---|
def load_model(model_path='', mode='all', **kwds):
model = get_basic_model(mode=mode, **kwds)
return model
|
def get_scene_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, model.scene_embedding_size).\n '
ret... |
def get_timestamp_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embedding... |
def get_basic_timestamp_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_emb... |
def get_basic_model(**kwargs):
mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=100, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000)
net = get_model_passt(arch='stfthop100', input_tdim=3200)
model = PasstBasicWrapper(mel=me... |
def load_model(model_path='', mode='all', **kwds):
model = get_2lvl_model(mode=mode, **kwds)
return model
|
def get_scene_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, model.scene_embedding_size).\n '
ret... |
def get_timestamp_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embedding... |
def get_2lvl_model(**kwargs):
mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=100, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000)
net = get_model_passt(arch='stfthop100', input_tdim=3200)
model = PasstBasicWrapper(mel=mel... |
def load_model(model_path='', mode='all', **kwds):
model = get_2lvl_model(mode=mode, **kwds)
return model
|
def get_scene_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, model.scene_embedding_size).\n '
ret... |
def get_timestamp_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embedding... |
def get_2lvl_model(**kwargs):
mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=100, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000)
net = get_model_passt(arch='stfthop100', input_tdim=3200)
model = PasstBasicWrapper(mel=mel... |
def load_model(model_path='', mode='all', **kwds):
model = get_basic_model(mode=mode, **kwds)
return model
|
def get_scene_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, model.scene_embedding_size).\n '
ret... |
def get_timestamp_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embedding... |
def get_basic_timestamp_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_emb... |
def get_basic_model(**kwargs):
mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=160, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000)
net = get_model_passt(arch='stfthop160', input_tdim=2000)
model = PasstBasicWrapper(mel=me... |
def load_model(model_path='', mode='all', **kwds):
model = get_2lvl_model(mode=mode, **kwds)
return model
|
def get_scene_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, model.scene_embedding_size).\n '
ret... |
def get_timestamp_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embedding... |
def get_2lvl_model(**kwargs):
mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=160, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000)
net = get_model_passt(arch='stfthop160', input_tdim=2000)
model = PasstBasicWrapper(mel=mel... |
def load_model(model_path='', mode='all', **kwds):
model = get_2lvl_model(mode=mode, **kwds)
return model
|
def get_scene_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, model.scene_embedding_size).\n '
ret... |
def get_timestamp_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embedding... |
def get_2lvl_model(**kwargs):
mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=160, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000)
net = get_model_passt(arch='stfthop160', input_tdim=2000)
model = PasstBasicWrapper(mel=mel... |
class AugmentMelSTFT(nn.Module):
def __init__(self, n_mels=128, sr=32000, win_length=800, hopsize=320, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=1, fmax_aug_range=1000):
torch.nn.Module.__init__(self)
self.win_length = win_length
self.n_mels =... |
def load_model(model_path='', mode='all', **kwds):
model = get_basic_model(mode=mode, **kwds)
return model
|
def get_scene_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, model.scene_embedding_size).\n '
ret... |
def get_timestamp_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_embedding... |
def get_basic_timestamp_embeddings(audio, model):
'\n audio: n_sounds x n_samples of mono audio in the range [-1, 1]. All sounds in a batch will be padded/trimmed to the same length.\n model: Loaded Model.\n Returns:\n embedding: A float32 Tensor with shape (n_sounds, n_timestamps, model.timestamp_emb... |
def get_basic_model(**kwargs):
mel = AugmentMelSTFT(n_mels=128, sr=32000, win_length=800, hopsize=320, n_fft=1024, freqm=48, timem=192, htk=False, fmin=0.0, fmax=None, norm=1, fmin_aug_range=10, fmax_aug_range=2000)
net = get_model_passt(arch='openmic2008', n_classes=20)
model = PasstBasicWrapper(mel=mel,... |
class PasstBasicWrapper(nn.Module):
def __init__(self, mel: nn.Module, net: nn.Module, max_model_window=10000, timestamp_window=160, timestamp_hop=50, scene_hop=2500, scene_embedding_size=1295, timestamp_embedding_size=1295, mode='all'):
'\n @param mel: spectrogram extractor\n @param net: n... |
def passt_base(**kwds):
return _UpstreamExpert('base', **kwds)
|
def passt_base2level(**kwds):
return _UpstreamExpert('base2level', **kwds)
|
def passt_base2levelmel(**kwds):
return _UpstreamExpert('base2levelmel', **kwds)
|
def passt_base20sec(**kwds):
return _UpstreamExpert('base20sec', **kwds)
|
def passt_base30sec(**kwds):
return _UpstreamExpert('base30sec', **kwds)
|
def passt_hop100base(**kwds):
return _UpstreamExpert('hop100base', **kwds)
|
def passt_hop100base2lvl(**kwds):
return _UpstreamExpert('hop100base2lvl', **kwds)
|
def passt_hop100base2lvlmel(**kwds):
return _UpstreamExpert('hop100base2lvlmel', **kwds)
|
def passt_hop160base(**kwds):
return _UpstreamExpert('hop160base', **kwds)
|
def passt_hop160base2lvl(**kwds):
return _UpstreamExpert('hop160base2lvl', **kwds)
|
def passt_hop160base2lvlmel(**kwds):
return _UpstreamExpert('hop160base2lvlmel', **kwds)
|
def load_and_convert_fairseq_ckpt(fairseq_source: str, output_path: str):
'\n Args:\n fairseq_source (str): either URL for the tar file or the untared directory path\n output_path (str): converted checkpoint path\n '
if fairseq_source.startswith('http'):
tar_file = _urls_to_filepat... |
def load_converted_model(ckpt: str):
import tempfile
ckpt_state = torch.load(ckpt, map_location='cpu')
for required_key in ['task_cfg', 'model_cfg', 'model_weight', 'text_dictionary']:
if (required_key not in ckpt_state):
raise ValueError(f'{ckpt} is not a valid checkpoint since the re... |
class _vq_wav2vec_codeids_wrapper(torch.nn.Module):
def __init__(self, vq_wav2vec):
super().__init__()
self.vq_wav2vec = vq_wav2vec
self.featurizer = _Featurizer(vq_wav2vec, 'codeids', upstream_device='cpu')
def _indices_to_string(self, sentence_idxs):
return (('<s> ' + ' '.j... |
def _roberta_local(frontend_model, model_name_or_path, checkpoint_file, **kwargs):
assert isinstance(frontend_model, torch.nn.Module)
assert os.path.exists(model_name_or_path)
return _LegacyUpstreamExpert(frontend_model, model_name_or_path, checkpoint_file, **kwargs)
|
def _vq_wav2vec_roberta(vq_wav2vec, **kwargs):
frontend_model = _vq_wav2vec_codeids_wrapper(vq_wav2vec)
return _roberta_local(frontend_model, **kwargs)
|
def vq_wav2vec_kmeans_roberta(refresh=False, legacy=False, **kwargs):
if legacy:
vq_wav2vec = getattr(s3prl.hub, f'vq_wav2vec_kmeans')(refresh=refresh)
tar_file = _urls_to_filepaths('https://dl.fbaipublicfiles.com/fairseq/wav2vec/bert_kmeans.tar', refresh=refresh)
tar_dir = os.path.join(os... |
def discretebert(*args, legacy=False, **kwargs):
return vq_wav2vec_kmeans_roberta(*args, legacy=legacy, **kwargs)
|
def spec_augment_local(ckpt, options_config=None, *args, **kwargs):
'\n The model from local ckpt\n ckpt (str): PATH\n '
assert os.path.isfile(ckpt)
return _UpstreamExpert(ckpt, *args, options_config=options_config, **kwargs)
|
def spec_augment_url(ckpt, refresh=False, *args, **kwargs):
'\n The model from URL\n ckpt (str): URL\n '
return spec_augment_local(_urls_to_filepaths(ckpt, refresh=refresh), *args, **kwargs)
|
def spec_augment(refresh=False, *args, **kwargs):
'\n The default model\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://www.dropbox.com/s/spz3yulaye8ppgr/states-100000.ckpt?dl=1'
return spec_augment_url(*args, refresh=refresh, **kwargs)
|
def ssast_frame_base(refresh: bool=False, window_secs: float=1.0, **kwargs):
ckpt = _urls_to_filepaths('https://www.dropbox.com/s/nx6nl4d4bl71sm8/SSAST-Base-Frame-400.pth?dl=1', refresh=refresh)
return _UpstreamExpert(ckpt, 'base_f', window_secs)
|
def ssast_patch_base(refresh: bool=False, window_secs: float=1.0, **kwargs):
ckpt = _urls_to_filepaths('https://www.dropbox.com/s/ewrzpco95n9jdz6/SSAST-Base-Patch-400.pth?dl=1', refresh=refresh)
return _UpstreamExpert(ckpt, 'base_p', window_secs)
|
def tera_local(ckpt, *args, **kwargs):
'\n The model from local ckpt\n ckpt (str): PATH\n feature_selection (int): -1 (default, the last layer) or an int in range(0, max_layer_num)\n '
assert os.path.isfile(ckpt)
return _UpstreamExpert(ckpt, *args, **kwargs)
|
def tera_url(ckpt, refresh=False, *args, **kwargs):
'\n The model from URL\n ckpt (str): URL\n '
return tera_local(_urls_to_filepaths(ckpt, refresh=refresh), *args, **kwargs)
|
def tera(refresh=False, *args, **kwargs):
'\n The default model\n refresh (bool): whether to download ckpt/config again if existed\n '
return tera_960hr(refresh, *args, **kwargs)
|
def tera_100hr(refresh=False, *args, **kwargs):
'\n The tera base model on 100hr\n refresh (bool): whether to download ckpt/config again if existed\n '
return tera_logMelBase_T_F_M_AdamW_b32_200k_100hr(refresh, *args, **kwargs)
|
def tera_960hr(refresh=False, *args, **kwargs):
'\n The tera base model on 960hr\n refresh (bool): whether to download ckpt/config again if existed\n '
return tera_logMelBase_T_F_M_AdamW_b32_1m_960hr_drop1(refresh, *args, **kwargs)
|
def tera_logMelBase_T_F_AdamW_b32_200k_100hr(refresh=False, *args, **kwargs):
'\n Feature: 80-dim log Mel\n Alteration: time + freq\n Optimizer: AdamW\n Batch size: 32\n Total steps: 200k\n Unlabled Speech: 100hr\n '
kwargs['ckpt'] = 'https://www.dropbox.com/s/o36qt1zgtn3tsep/states-20000... |
def tera_logMelBase_T_F_M_AdamW_b32_200k_100hr(refresh=False, *args, **kwargs):
'\n Feature: 80-dim log Mel\n Alteration: time + freq + mag\n Optimizer: AdamW\n Batch size: 32\n Total steps: 200k\n Unlabled Speech: 100hr\n '
kwargs['ckpt'] = 'https://www.dropbox.com/s/l9ryl82k64m1lsk/stat... |
def tera_logMelBase_T_F_AdamW_b32_1m_960hr(refresh=False, *args, **kwargs):
'\n Feature: 80-dim log Mel\n Alteration: time + freq\n Optimizer: AdamW\n Batch size: 32\n Total steps: 1M\n Unlabled Speech: 960hr\n '
kwargs['ckpt'] = 'https://www.dropbox.com/s/98olxex0m7oy9ta/states-1000000.c... |
def tera_logMelBase_T_F_AdamW_b32_1m_960hr_drop1(refresh=False, *args, **kwargs):
'\n Feature: 80-dim log Mel\n Alteration: time + freq\n Optimizer: AdamW\n Batch size: 32\n Total steps: 1M\n Unlabled Speech: 960hr\n Differences: Dropout of 0.1 (instead of 0.3)\n '
kwargs['ckpt'] = 'ht... |
def tera_logMelBase_T_F_AdamW_b32_1m_960hr_seq3k(refresh=False, *args, **kwargs):
'\n Feature: 80-dim log Mel\n Alteration: time + freq\n Optimizer: AdamW\n Batch size: 32\n Total steps: 1M\n Unlabled Speech: 960hr\n Differences: sequence length of 3k (instead of 1.5k)\n '
kwargs['ckpt... |
def tera_logMelBase_T_F_M_AdamW_b32_1m_960hr_drop1(refresh=False, *args, **kwargs):
'\n Feature: 80-dim log Mel\n Alteration: time + freq + mag\n Optimizer: AdamW\n Batch size: 32\n Total steps: 1M\n Unlabled Speech: 960hr\n Differences: Dropout of 0.1 (instead of 0.3)\n '
kwargs['ckpt... |
def tera_fbankBase_T_F_AdamW_b32_200k_100hr(refresh=False, *args, **kwargs):
'\n Feature: 240-dim fbank\n Alteration: time + freq\n Optimizer: AdamW\n Batch size: 32\n Total steps: 200k\n Unlabled Speech: 100hr\n '
kwargs['ckpt'] = 'https://www.dropbox.com/s/i32ob29m6afufot/states-200000.... |
class UpstreamExpert(UpstreamBase):
def __init__(self, ckpt, **kwargs):
super().__init__(**kwargs)
checkpoint = torch.load(ckpt)
self.cfg = WavLMConfig(checkpoint['cfg'])
self.model = WavLM(self.cfg)
self.model.load_state_dict(checkpoint['model'])
self.model.featur... |
def unispeech_sat_local(ckpt, *args, **kwargs):
'\n The model from local ckpt\n ckpt (str): PATH\n '
assert os.path.isfile(ckpt)
return _UpstreamExpert(ckpt, *args, **kwargs)
|
def unispeech_sat_url(ckpt, refresh=False, *args, **kwargs):
'\n The model from google drive id\n ckpt (str): URL\n refresh (bool): whether to download ckpt/config again if existed\n '
return unispeech_sat_local(_urls_to_filepaths(ckpt, refresh=refresh), *args, **kwargs)
|
def unispeech_sat(refresh=False, *args, **kwargs):
'\n The default model - Base-Plus\n refresh (bool): whether to download ckpt/config again if existed\n '
return unispeech_sat_base_plus(*args, refresh=refresh, **kwargs)
|
def unispeech_sat_base(refresh=False, *args, **kwargs):
'\n The Base model\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://huggingface.co/s3prl/converted_ckpts/resolve/main/unispeech_sat_base.pt'
return unispeech_sat_url(*args, refresh=refresh,... |
def unispeech_sat_base_plus(refresh=False, *args, **kwargs):
'\n The Base-Plus model\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://huggingface.co/s3prl/converted_ckpts/resolve/main/unispeech_sat_base_plus.pt'
return unispeech_sat_url(*args, r... |
def unispeech_sat_large(refresh=False, *args, **kwargs):
'\n The Large model\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://huggingface.co/s3prl/converted_ckpts/resolve/main/unispeech_sat_large.pt'
return unispeech_sat_url(*args, refresh=refre... |
def load_fairseq_ckpt(source: str, **override):
from fairseq.checkpoint_utils import load_checkpoint_to_cpu
from omegaconf import OmegaConf
source = str(source)
if source.startswith('http'):
fairseq_path = _urls_to_filepaths(source)
else:
fairseq_path = source
state = load_chec... |
def merge_with_parent(dc: dataclass, cfg: dict):
assert is_dataclass(dc)
assert (type(cfg) == dict)
cfg = deepcopy(cfg)
def fix_cfg(cfg):
target_keys = set(dc.__dataclass_fields__.keys())
for k in list(cfg.keys()):
if (k not in target_keys):
del cfg[k]
... |
def extract_hidden_states(model):
model.eval()
with torch.no_grad():
return model(get_pseudo_wavs())['hidden_states']
|
def are_same_models(model1, model2):
hs1 = extract_hidden_states(model1)
hs2 = extract_hidden_states(model2)
for (h1, h2) in zip(hs1, hs2):
assert torch.allclose(h1, h2)
|
def models_all_close(*models):
assert (len(models) > 1)
for model in models[1:]:
are_same_models(models[0], model)
|
class UpstreamExpert(UpstreamBase):
def __init__(self, ckpt, **kwargs):
super().__init__(**kwargs)
self.model = VGGish(ckpt, **kwargs)
def get_downsample_rates(self, key: str) -> int:
return 16000
def forward(self, wavs):
device = wavs[0].device
outputs = []
... |
def _load_state_dict_from_url(url):
path = _urls_to_filepaths(url)
return torch.load(path, map_location='cpu')
|
def _vggish_from_torch_hub(urls, *args, **kwargs):
'\n The model from `torch.hub.load`\n urls (dict): LINKS\n '
kwargs['ckpt'] = {'vggish': _load_state_dict_from_url(urls['vggish']), 'pca': _load_state_dict_from_url(urls['pca'])}
return _UpstreamExpert(*args, **kwargs)
|
def vggish(*args, **kwargs):
'\n The default model\n '
urls = {'vggish': 'https://github.com/harritaylor/torchvggish/releases/download/v0.1/vggish-10086976.pth', 'pca': 'https://github.com/harritaylor/torchvggish/releases/download/v0.1/vggish_pca_params-970ea276.pth'}
return _vggish_from_torch_hub(u... |
class VGG(nn.Module):
def __init__(self, features):
super(VGG, self).__init__()
self.features = features
self.embeddings = nn.Sequential(nn.Linear(((512 * 4) * 6), 4096), nn.ReLU(True), nn.Linear(4096, 4096), nn.ReLU(True), nn.Linear(4096, 128), nn.ReLU(True))
def forward(self, x):
... |
class Postprocessor(nn.Module):
'\n Post-processes VGGish embeddings. Returns a torch.Tensor instead of a\n numpy array in order to preserve the gradient.\n "The initial release of AudioSet included 128-D VGGish embeddings for each\n segment of AudioSet. These released embeddings were produced by appl... |
def make_layers():
layers = []
in_channels = 1
for v in [64, 'M', 128, 'M', 256, 256, 'M', 512, 512, 'M']:
if (v == 'M'):
layers += [nn.MaxPool2d(kernel_size=2, stride=2)]
else:
conv2d = nn.Conv2d(in_channels, v, kernel_size=3, padding=1)
layers += [conv... |
class VGGish(VGG):
def __init__(self, ckpt, pretrained=True, postprocess=True, progress=True, **kwargs):
super().__init__(make_layers())
if pretrained:
super().load_state_dict(ckpt['vggish'])
self.postprocess = postprocess
if self.postprocess:
self.pproc = ... |
def vq_apc(refresh=False, *args, **kwargs):
'\n The default model\n refresh (bool): whether to download ckpt/config again if existed\n '
return vq_apc_360hr(*args, refresh=refresh, **kwargs)
|
def vq_apc_360hr(refresh=False, *args, **kwargs):
'\n The vq-apc standard model on 360hr\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://huggingface.co/leo19941227/apc_series/resolve/main/vq_apc_360hr.ckpt'
return vq_apc_url(*args, refresh=refr... |
def vq_apc_960hr(refresh=False, *args, **kwargs):
'\n The vq-apc standard model on 960hr\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://huggingface.co/leo19941227/apc_series/resolve/main/vq_apc_960hr.ckpt'
return vq_apc_url(*args, refresh=refr... |
def load_and_convert_fairseq_ckpt(fairseq_source: str, output_path: str=None):
(state, cfg) = load_fairseq_ckpt(fairseq_source)
output_state = {'task_cfg': cfg['task'], 'model_cfg': cfg['model'], 'model_weight': state['model']}
if (output_path is not None):
Path(output_path).parent.mkdir(exist_ok=... |
def load_converted_model(ckpt: str):
ckpt_state = torch.load(ckpt, map_location='cpu')
for required_key in ['task_cfg', 'model_cfg', 'model_weight']:
if (required_key not in ckpt_state):
raise ValueError(f'{ckpt} is not a valid checkpoint since the required key: {required_key} is missing')... |
def vq_wav2vec_custom(ckpt: str, *args, legacy: bool=False, refresh: bool=False, **kwargs):
if ckpt.startswith('http'):
ckpt = _urls_to_filepaths(ckpt, refresh=refresh)
assert os.path.isfile(ckpt)
if legacy:
return _LegacyUpstreamExpert(ckpt, *args, **kwargs)
else:
return _Upst... |
def wav2vec2_local(*args, **kwargs):
return vq_wav2vec_custom(*args, **kwargs)
|
def wav2vec2_url(*args, **kwargs):
return vq_wav2vec_custom(*args, **kwargs)
|
def vq_wav2vec(refresh=False, *args, **kwargs):
'\n The default model - Large model with context vector\n refresh (bool): whether to download ckpt/config again if existed\n '
return vq_wav2vec_gumbel(*args, refresh=refresh, **kwargs)
|
def vq_wav2vec_gumbel(refresh=False, legacy=False, **kwargs):
'\n The Gumbel model\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://dl.fbaipublicfiles.com/fairseq/wav2vec/vq-wav2vec.pt'
if (not legacy):
kwargs['ckpt'] = 'https://huggingf... |
def vq_wav2vec_kmeans(refresh=False, legacy=False, **kwargs):
'\n The K-means model\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://dl.fbaipublicfiles.com/fairseq/wav2vec/vq-wav2vec_kmeans.pt'
if (not legacy):
kwargs['ckpt'] = 'https://... |
def load_and_convert_fairseq_ckpt(fairseq_source: str, output_path: str=None):
(state, cfg) = load_fairseq_ckpt(fairseq_source)
output_state = {'task_cfg': cfg['task'], 'model_cfg': cfg['model'], 'model_weight': state['model']}
if (output_path is not None):
Path(output_path).parent.mkdir(exist_ok=... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.