code stringlengths 17 6.64M |
|---|
def cpc_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 cpc_url(ckpt, refresh=False, *args, **kwargs):
'\n The model from URL\n ckpt (str): URL\n '
return cpc_local(_urls_to_filepaths(ckpt), *args, **kwargs)
|
def modified_cpc(refresh=False, *args, **kwargs):
'\n The model from official repository\n '
kwargs['ckpt'] = 'https://dl.fbaipublicfiles.com/librilight/CPC_checkpoints/60k_epoch4-d0f474de.pt'
return cpc_url(*args, refresh=refresh, **kwargs)
|
def load_and_convert_fairseq_ckpt(fairseq_source: str, output_path: str):
(state, cfg) = load_fairseq_ckpt(fairseq_source)
output_state = {'task_cfg': cfg['task'], 'model_cfg': cfg['model'], 'model_weight': state['model']}
Path(output_path).parent.mkdir(exist_ok=True, parents=True)
torch.save(output_s... |
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')... |
class EMAModuleConfig():
ema_decay: float = field(default=0.9999, metadata={'help': 'decay for exponential moving average model'})
ema_fp32: bool = field(default=False, metadata={'help': 'If true, store EMA model in fp32 even if model is in fp16'})
|
class EMAModule():
'Exponential Moving Average of Fairseq Models'
def __init__(self, model, config: EMAModuleConfig, device=None, skip_keys=None):
'\n @param model model to initialize the EMA with\n @param config EMAConfig object with configuration like\n ema_decay, ema_update_fr... |
@dataclass
class Data2VecAudioConfig(Wav2Vec2Config):
loss_beta: float = field(default=0, metadata={'help': 'beta for smooth l1 loss. 0 means use l2 loss'})
loss_scale: Optional[float] = field(default=None, metadata={'help': 'scale the reconstruction loss by this constant. if None then scales by 1/sqrt(dim)'}... |
def get_annealed_rate(start, end, curr_step, total_steps):
r = (end - start)
pct_remaining = (1 - (curr_step / total_steps))
return (end - (r * pct_remaining))
|
class Data2VecAudioModel(torch.nn.Module):
def __init__(self, cfg: Data2VecAudioConfig):
super().__init__()
self.cfg = cfg
feature_enc_layers = eval(cfg.conv_feature_layers)
self.extractor_embed = feature_enc_layers[(- 1)][0]
self.ema = None
self.embed = cfg.encode... |
def data2vec_custom(ckpt: str, refresh: bool=False, **kwargs):
if ckpt.startswith('http'):
ckpt = _urls_to_filepaths(ckpt, refresh=refresh)
return _UpstreamExpert(ckpt, **kwargs)
|
def data2vec_local(*args, **kwargs):
return data2vec_custom(*args, **kwargs)
|
def data2vec_url(*args, **kwargs):
return data2vec_custom(*args, **kwargs)
|
def data2vec(refresh=False, *args, **kwargs):
'\n The default model - Base\n refresh (bool): whether to download ckpt/config again if existed\n '
return data2vec_base_960(*args, refresh=refresh, **kwargs)
|
def data2vec_base_960(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/audio_base_ls.pt'
return data2vec_custom(*args, refresh=refresh, **kwarg... |
def data2vec_large_ll60k(refresh=False, *args, **kwargs):
'\n The Large model trained on Libri-light 60k hours of data\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://huggingface.co/s3prl/converted_ckpts/resolve/main/vox_pretrained.pt'
return d... |
class CMVN(torch.jit.ScriptModule):
__constants__ = ['mode', 'dim', 'eps']
def __init__(self, mode='global', dim=2, eps=1e-10):
super(CMVN, self).__init__()
if (mode != 'global'):
raise NotImplementedError('Only support global mean variance normalization.')
self.mode = mod... |
class FeatureExtractor(nn.Module):
'Feature extractor, transforming file path to Mel spectrogram'
def __init__(self, mode='fbank', num_mel_bins=80, decode_wav=False, apply_cmvn=True, **kwargs):
super(FeatureExtractor, self).__init__()
assert (mode == 'fbank'), 'Only Mel-spectrogram implemente... |
def create_transform():
return FeatureExtractor()
|
def decoar_custom(ckpt: str, refresh=False, *args, **kwargs):
if ckpt.startswith('http'):
ckpt = _urls_to_filepaths(ckpt, refresh=refresh)
return _UpstreamExpert(ckpt, *args, **kwargs)
|
def decoar_local(*args, **kwargs):
return decoar_custom(*args, **kwargs)
|
def decoar_url(*args, **kwargs):
return decoar_custom(*args, **kwargs)
|
def decoar(refresh=False, *args, **kwargs):
kwargs['ckpt'] = 'https://huggingface.co/s3prl/converted_ckpts/resolve/main/checkpoint_decoar.pt'
return decoar_url(*args, refresh=refresh, **kwargs)
|
def decoar2_custom(ckpt: str, refresh=False, *args, **kwargs):
if ckpt.startswith('http'):
ckpt = _urls_to_filepaths(ckpt, refresh=refresh)
return _UpstreamExpert(ckpt, *args, **kwargs)
|
def decoar2_local(*args, **kwargs):
"\n The model from local ckpt\n ckpt (str): PATH\n feature_selection (str): 'c' (default) or 'z'\n "
return decoar2_custom(*args, **kwargs)
|
def decoar2_url(*args, **kwargs):
'\n The model from URL\n ckpt (str): URL\n '
return decoar2_custom(*args, **kwargs)
|
def decoar2(*args, refresh=False, **kwargs):
'\n The apc standard model on 360hr\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://huggingface.co/s3prl/converted_ckpts/resolve/main/checkpoint_decoar2.pt'
return decoar2_url(*args, refresh=refresh,... |
class CMVN(torch.jit.ScriptModule):
__constants__ = ['mode', 'dim', 'eps']
def __init__(self, mode='global', dim=2, eps=1e-10):
super(CMVN, self).__init__()
if (mode != 'global'):
raise NotImplementedError('Only support global mean variance normalization.')
self.mode = mod... |
class FeatureExtractor(nn.Module):
'Feature extractor, transforming file path to Mel spectrogram'
def __init__(self, mode='fbank', num_mel_bins=80, decode_wav=False, apply_cmvn=True, **kwargs):
super(FeatureExtractor, self).__init__()
assert (mode == 'fbank'), 'Only Mel-spectrogram implemente... |
def create_transform():
return FeatureExtractor()
|
def decoar_layers_custom(ckpt: str, refresh=False, *args, **kwargs):
if ckpt.startswith('http'):
ckpt = _urls_to_filepaths(ckpt, refresh=refresh)
return _UpstreamExpert(ckpt, *args, **kwargs)
|
def decoar_layers_local(*args, **kwargs):
return decoar_layers_custom(*args, **kwargs)
|
def decoar_layers_url(*args, **kwargs):
return decoar_layers_custom(*args, **kwargs)
|
def decoar_layers(*args, refresh=False, **kwargs):
'\n The apc standard model on 360hr\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://huggingface.co/s3prl/converted_ckpts/resolve/main/checkpoint_decoar.pt'
return decoar_layers_url(*args, refre... |
class UpstreamExpert(UpstreamBase):
'\n The Distiller wrapper\n '
def __init__(self, ckpt, model_config=None, **kwargs):
super().__init__(**kwargs)
if (model_config is not None):
print('[UpstreamExpert] - Using upstream expert config file from:', model_config)
wi... |
def distiller_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 distiller_url(ckpt, refresh=False, *args, **kwargs):
'\n The model from url\n ckpt (str): URL\n refresh (bool): whether to download ckpt/config again if existed\n '
return distiller_local(_urls_to_filepaths(ckpt, refresh=refresh), *args, **kwargs)
|
def distilhubert(refresh=False, *args, **kwargs):
'\n DistilHuBERT\n '
return distilhubert_base(*args, refresh=refresh, **kwargs)
|
def distilhubert_base(refresh=False, *args, **kwargs):
'\n DistilHuBERT Base\n Default model in https://arxiv.org/abs/2110.01900\n '
kwargs['ckpt'] = 'https://huggingface.co/leo19941227/distilhubert/resolve/main/distilhubert_ls960_4-8-12.ckpt'
return distiller_url(*args, refresh=refresh, **kwargs... |
def init_bert_params(module):
'\n Initialize the weights specific to the BERT Model.\n This overrides the default initializations depending on the specified arguments.\n 1. If normal_init_linear_weights is set then weights of linear\n layer will be initialized using the normal distribution ... |
class SplitLinear(nn.Module):
'Split Linear Layer'
def __init__(self, in_dim, in_split, out_dim):
super().__init__()
self.in_dim = in_dim
self.in_split = in_split
self.out_dim = out_dim
if (in_split > 1):
weight = torch.zeros((self.in_split, self.in_dim, se... |
class TransformerSentenceEncoderLayer(nn.Module):
'\n Implements a Transformer Encoder Layer used in BERT/XLM style pre-trained\n models.\n '
def __init__(self, embedding_dim: float=768, ffn_embedding_dim: float=3072, num_attention_heads: float=8, dropout: float=0.1, attention_dropout: float=0.1, ac... |
class TransformerEncoder(nn.Module):
def __init__(self, args):
super().__init__()
self.dropout = args.dropout
self.embedding_dim = args.encoder_embed_dim
self.pos_conv = nn.Conv1d(self.embedding_dim, self.embedding_dim, kernel_size=args.conv_pos, padding=(args.conv_pos // 2), grou... |
class UpstreamExpert(torch.nn.Module):
def __init__(self, ckpt, config=None, **kwargs):
super().__init__()
device = ('cuda' if torch.cuda.is_available() else 'cpu')
assert (HubertTask is not None), 'ESPnet is not installed, run `external_tools/install_espnet.sh` to install'
(huber... |
def espnet_hubert_custom(ckpt, *args, config=None, **kwargs):
return _UpstreamExpert(ckpt, *args, **kwargs)
|
def espnet_hubert_local(*args, **kwargs):
return espnet_hubert_custom(*args, **kwargs)
|
def cvhubert(*args, refresh=False, **kwargs):
url = 'https://huggingface.co/espnet/espnet_cvhubert/resolve/main/exp/hubert_iter2_train_ssl_torchaudiohubert_base_960h_pretrain_it2_raw/latest.pth'
config_url = 'https://huggingface.co/espnet/espnet_cvhubert/raw/main/exp/hubert_iter2_train_ssl_torchaudiohubert_ba... |
def wavlablm_ek_40k(*args, refresh=False, **kwargs):
url = 'https://huggingface.co/espnet/WavLabLM-EK-40k/resolve/main/exp_li/hubert_iter2_train_ssl_torchaudiohubert_large_960h_pretrain_it2_cont_raw_layer_9/5epoch.pth'
config_url = 'https://huggingface.co/espnet/WavLabLM-EK-40k/raw/main/exp_li/hubert_iter2_tr... |
def wavlablm_ms_40k(*args, refresh=False, **kwargs):
url = 'https://huggingface.co/espnet/WavLabLM-MS-40k/resolve/main/exp_babel/hubert_iter2_train_ssl_torchaudiohubert_large_960h_pretrain_it2_wavlm_babel_light_raw_layer_9/5epoch.pth'
config_url = 'https://huggingface.co/espnet/WavLabLM-MS-40k/raw/main/exp_ba... |
def wavlablm_mk_40k(*args, refresh=False, **kwargs):
url = 'https://huggingface.co/espnet/WavLabLM-MK-40k/resolve/main/exp_li/hubert_iter2_train_ssl_torchaudiohubert_large_960h_pretrain_it2_wavlm_raw_layer_9/valid.acc_m.ave_10best.pth'
config_url = 'https://huggingface.co/espnet/WavLabLM-MK-40k/raw/main/exp_l... |
def espnet_hubert_base_iter1(*args, refresh=False, **kwargs):
url = 'https://huggingface.co/espnet/simpleoier_librispeech_hubert_iter1_train_ssl_torchaudiohubert_base_960h_pretrain_it1_raw/resolve/main/exp/hubert_iter1_train_ssl_torchaudiohubert_base_960h_pretrain_it1_raw/valid.loss.ave.pth'
config_url = 'htt... |
def espnet_hubert_base_iter0(*args, refresh=False, **kwargs):
url = 'https://huggingface.co/espnet/simpleoier_librispeech_hubert_iter0_train_ssl_torchaudiohubert_base_960h_pretrain_it0_raw/resolve/main/exp/hubert_iter0_train_ssl_torchaudiohubert_base_960h_pretrain_it0_raw/valid.loss.ave.pth'
config_url = 'htt... |
def espnet_hubert_large_gs_ll60k(*args, refresh=False, **kwargs):
url = 'https://huggingface.co/espnet/hubert_large_gs_16_librilight60k/resolve/main/mnt/datastore/exp/hubert_iter1_train_ssl_torchaudiohubert_large_960h_pretrain_it2_bins_raw/valid.loss.ave_10best.pth'
config_url = 'https://huggingface.co/espnet... |
class UpstreamExpert(nn.Module):
def __init__(self, ckpt: str=None, model_config: str=None, **kwargs):
'\n Args:\n ckpt:\n The checkpoint path for loading your pretrained weights.\n Can be assigned by the -k option in run_downstream.py\n\n model_... |
def customized_upstream(*args, **kwargs):
"\n To enable your customized pretrained model, you only need to implement\n upstream/example/expert.py and leave this file as is. This file is\n used to register the UpstreamExpert in upstream/example/expert.py\n The following is a brief introduction of the r... |
class UpstreamExpert(torch.nn.Module):
def __init__(self, ckpt, **kwds):
super().__init__()
try:
self.extracter = Wav2Vec2FeatureExtractor.from_pretrained(ckpt)
except:
if ('base' in ckpt):
alter_extractor = 'facebook/hubert-base-ls960'
... |
def hf_hubert_custom(ckpt, *args, **kwargs):
return _UpstreamExpert(ckpt, *args, **kwargs)
|
class UpstreamExpert(torch.nn.Module):
def __init__(self, ckpt, **kwds):
super().__init__()
self.extracter = Wav2Vec2FeatureExtractor.from_pretrained(ckpt)
self.model = Wav2Vec2Model.from_pretrained(ckpt)
def get_downsample_rates(self, key: str=None) -> int:
return 320
d... |
def hf_wav2vec2_custom(ckpt, *args, **kwargs):
return _UpstreamExpert(ckpt, *args, **kwargs)
|
def load_and_convert_fairseq_ckpt(fairseq_source: str, output_path: str=None):
from fairseq.data.dictionary import Dictionary
(state, cfg) = load_fairseq_ckpt(fairseq_source)
dicts: List[Dictionary] = state['task_state']['dictionaries']
symbols = [dictionary.symbols for dictionary in dicts]
output... |
def load_converted_model(ckpt: str):
ckpt_state = torch.load(ckpt, map_location='cpu')
for required_key in ['task_cfg', 'model_cfg', 'model_weight', 'dictionaries_symbols']:
if (required_key not in ckpt_state):
raise ValueError(f'{ckpt} is not a valid checkpoint since the required key: {re... |
def hubert_custom(ckpt: str, legacy: bool=False, fairseq: bool=False, refresh: bool=False, **kwargs):
assert (not (legacy and fairseq)), "The option 'legacy' will directly load a fairseq checkpoint, while the option 'fairseq' will first convert the fairseq checkpoint to be fairseq indenpendent and then load the c... |
def hubert_local(*args, **kwargs):
return hubert_custom(*args, **kwargs)
|
def hubert_url(*args, **kwargs):
return hubert_custom(*args, **kwargs)
|
def hubert(refresh=False, *args, **kwargs):
'\n The default model - Base\n refresh (bool): whether to download ckpt/config again if existed\n '
return hubert_base(*args, refresh=refresh, **kwargs)
|
def hubert_base(refresh=False, legacy=False, **kwargs):
'\n The Base model\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://dl.fbaipublicfiles.com/hubert/hubert_base_ls960.pt'
if (not legacy):
kwargs['ckpt'] = 'https://huggingface.co/s3p... |
def hubert_large_ll60k(refresh=False, legacy=False, **kwargs):
'\n The Large model\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://dl.fbaipublicfiles.com/hubert/hubert_large_ll60k.pt'
if (not legacy):
kwargs['ckpt'] = 'https://huggingfa... |
def hubert_base_robust_mgr(refresh=False, legacy=False, **kwargs):
'\n The Base model, continually trained with Libri 960 hr with Musan noise, Gaussian noise and Reverberation.\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://huggingface.co/kphuang6... |
def mhubert_base_vp_en_es_fr_it3(refresh=False, **kwds):
kwds['ckpt'] = 'https://huggingface.co/s3prl/converted_ckpts/resolve/main/mhubert_base_vp_en_es_fr_it3.pt'
return hubert_custom(refresh=refresh, **kwds)
|
def contentvec(refresh=False, **kwds):
kwds['ckpt'] = 'https://huggingface.co/s3prl/converted_ckpts/resolve/main/contentvec_km100.pt'
return hubert_custom(refresh=refresh, **kwds)
|
def contentvec_km100(refresh=False, **kwds):
kwds['ckpt'] = 'https://huggingface.co/s3prl/converted_ckpts/resolve/main/contentvec_km100.pt'
return hubert_custom(refresh=refresh, **kwds)
|
def contentvec_km500(refresh=False, **kwds):
kwds['ckpt'] = 'https://huggingface.co/s3prl/converted_ckpts/resolve/main/contentvec_km500.pt'
return hubert_custom(refresh=refresh, **kwds)
|
class Hook():
def __init__(self, module_path, transform, unique_identifier=None):
self.module_path = module_path
self.transform = transform
self.unique_identifier = (unique_identifier or module_path)
self.handler = None
assert isinstance(self.module_path, str)
asse... |
class initHook(type):
def __call__(cls, *args, **kwargs):
instance = super().__call__(*args, **kwargs)
for hook in instance.hooks:
if (hook.handler is None):
instance._register_hook_handler(hook)
return instance
|
class UpstreamBase(nn.Module, metaclass=initHook):
def __init__(self, hooks: List[Tuple]=None, hook_postprocess: Callable[([List[Tuple[(str, Tensor)]]], List[Tuple[(str, Tensor)]])]=None, **kwargs):
'\n Args:\n hooks: each Tuple is an argument list for the Hook initializer\n '
... |
class Featurizer(nn.Module):
def __init__(self, upstream: UpstreamBase, feature_selection: str='hidden_states', upstream_device: str='cuda', layer_selection: int=None, normalize: bool=False, **kwargs):
super().__init__()
self.name = 'Featurizer'
upstream.eval()
paired_wavs = [torc... |
class UpstreamExpert(torch.nn.Module):
def __init__(self, ckpt, **kwds):
super().__init__()
checkpoint = torch.load(ckpt)
assert (checkpoint['cfg']['model']['_name'] in ['hubert_pruner', 'student_hubert'])
self.cfg = LightHuBERTConfig(checkpoint['cfg']['model'])
if (checkp... |
def lighthubert_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 lighthubert_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 lighthubert_local(_urls_to_filepaths(ckpt, refresh=refresh), *args, **kwargs)
|
def lighthubert(refresh=False, *args, **kargs):
'\n The default model - Small\n refresh (bool): whether to download ckpt/config again if existed\n '
return lighthubert_small(*args, refresh=refresh, **kargs)
|
def lighthubert_small(refresh=False, *args, **kwargs):
'\n The small model\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://huggingface.co/mechanicalsea/lighthubert/resolve/main/lighthubert_small.pt'
return lighthubert_url(*args, refresh=refresh... |
def lighthubert_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/mechanicalsea/lighthubert/resolve/main/lighthubert_base.pt'
return lighthubert_url(*args, refresh=refresh, *... |
def lighthubert_stage1(refresh=False, *args, **kwargs):
'\n The Stage1 model\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://huggingface.co/mechanicalsea/lighthubert/resolve/main/lighthubert_stage1.pt'
return lighthubert_url(*args, refresh=refr... |
def is_xla_tensor(tensor):
return (torch.is_tensor(tensor) and (tensor.device.type == 'xla'))
|
def index_put(tensor, indices, value):
if is_xla_tensor(tensor):
for _ in range(indices.dim(), tensor.dim()):
indices = indices.unsqueeze((- 1))
if (indices.size((- 1)) < tensor.size((- 1))):
indices = indices.expand_as(tensor)
tensor = (torch.mul(tensor, (~ indices... |
def pad_to_multiple(x, multiple, dim=(- 1), value=0):
if (x is None):
return (None, 0)
tsz = x.size(dim)
m = (tsz / multiple)
remainder = ((math.ceil(m) * multiple) - tsz)
if m.is_integer():
return (x, 0)
pad_offset = (((0,) * ((- 1) - dim)) * 2)
return (F.pad(x, (*pad_offs... |
def gelu_accurate(x):
if (not hasattr(gelu_accurate, '_a')):
gelu_accurate._a = math.sqrt((2 / math.pi))
return ((0.5 * x) * (1 + torch.tanh((gelu_accurate._a * (x + (0.044715 * torch.pow(x, 3)))))))
|
def gelu(x: torch.Tensor) -> torch.Tensor:
return torch.nn.functional.gelu(x.float()).type_as(x)
|
def relu_squared(x: torch.Tensor):
return F.relu(x).pow(2)
|
def deprecation_warning(message, stacklevel=3):
warnings.warn(message, stacklevel=stacklevel)
|
def get_activation_fn(activation: str) -> Callable:
'Returns the activation function corresponding to `activation`'
def gelu_accurate(x):
if (not hasattr(gelu_accurate, '_a')):
gelu_accurate._a = math.sqrt((2 / math.pi))
return ((0.5 * x) * (1 + torch.tanh((gelu_accurate._a * (x +... |
class SLayerNorm(nn.LayerNorm):
'LayerNorm: variable 1-D size\n __base__: torch.nn.LayerNorm\n '
def __init__(self, normalized_shape: int, eps: float=1e-05, elementwise_affine: bool=True) -> None:
super(SLayerNorm, self).__init__(normalized_shape, eps, elementwise_affine)
self.staticize... |
class ConvFeatureExtractionModel(nn.Module):
def __init__(self, conv_layers: List[Tuple[(int, int, int)]], dropout: float=0.0, mode: str='default', conv_bias: bool=False):
super().__init__()
assert (mode in {'default', 'layer_norm'})
def block(n_in, n_out, k, stride, is_layer_norm=False,... |
class Spectrogram(nn.Module):
def __init__(self, cfg, **kwargs):
super(Spectrogram, self).__init__()
self.eps = 1e-08
self.cfg = cfg
self.n_fft = cfg['spectrogram']['n_fft']
self.hop_length = cfg['spectrogram']['hop_length']
self.win_length = cfg['spectrogram']['wi... |
class UpstreamExpert(nn.Module):
'\n Extract spectrogram features from wavforms with torchaudio\n '
def __init__(self, model_config=None, **kwargs):
super(UpstreamExpert, self).__init__()
with open(model_config, 'r') as file:
self.config = yaml.load(file, Loader=yaml.FullLoa... |
def stft_mag(model_config, *args, **kwargs):
assert os.path.isfile(model_config)
return _UpstreamExpert(model_config, *args, **kwargs)
|
def mae_ast_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 mae_ast_url(ckpt, refresh=False, *args, **kwargs):
'\n The model from URL\n ckpt (str): URL\n '
return mae_ast_local(_urls_to_filepaths(ckpt, refresh=refresh), *args, **kwargs)
|
def mae_ast_frame(refresh=False, *args, **kwargs):
'\n The MAE-AST Frame model, 12-layered, random masking\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://www.cs.utexas.edu/~harwath/model_checkpoints/mae_ast/random_frame_75_12LayerEncoder.pt'
r... |
def mae_ast_patch(refresh=False, *args, **kwargs):
'\n The MAE-AST Patch model, 12-layered, chunked masking\n refresh (bool): whether to download ckpt/config again if existed\n '
kwargs['ckpt'] = 'https://www.cs.utexas.edu/~harwath/model_checkpoints/mae_ast/chunk_patch_75_12LayerEncoder.pt'
r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.