Diffusers documentation
AutoencoderKLKVAEAudio
AutoencoderKLKVAEAudio
Kandinsky LabチームがKVAE-Audioで紹介した、音声向けのKL損失付き1次元畳み込み変分オートエンコーダ(VAE)です。生データのフルバンド(48 kHz)波形をコンパクトな連続潜在変数に圧縮し、音声、音楽、一般的な音声を問わず高忠実度で再構成します。
モデルは、以下のコードスニペットで読み込むことができます。
import torch
from diffusers import AutoencoderKLKVAEAudio
vae = AutoencoderKLKVAEAudio.from_pretrained("kandinskylab/KVAE-Audio", subfolder="diffusers", dtype=torch.float32)AutoencoderKLKVAEAudio
class diffusers.AutoencoderKLKVAEAudio
< source >( encoder_dim: int = 64encoder_rates: list[int] = [2, 3, 4, 5, 8]latent_dim: int = 2048codebook_dim: int = 64decoder_dim: int = 1536decoder_rates: list[int] = [8, 5, 4, 3, 2]sample_rate: int = 48000num_channels: int = 1attn_num_heads: int = 8 )
パラメータ
- encoder_dim (
int、任意、デフォルトは 64) — エンコーダーのベースチャネル次元。ダウンサンプリングの各段階で 2 倍になります。 - encoder_rates (
list[int]、任意、デフォルトは[2, 3, 4, 5, 8]) — エンコーダーにおけるダウンサンプリングのストライドです。 - latent_dim (
int、任意、デフォルト値は 2048) — エンコーダー出力のチャネル次元(in_projボトルネックの前)。 - codebook_dim (
int、任意、デフォルトは 64)— 後方分布の潜在空間のチャネル次元(in_projボトルネックの後)。 - decoder_dim (
int、任意、デフォルト値は 1536) — デコーダーのベースチャネル次元。各アップサンプリング段階で半分になります。 - decoder_rates (
list[int]、任意、デフォルトは[8, 5, 4, 3, 2]) — デコーダーにおけるアップサンプリングのストライドです。 - sample_rate (
int、任意、デフォルトは 48000)— モデルが学習されたサンプリングレート(Hz)です。 - num_channels (
int、任意、デフォルトは 1) — オーディオデータのチャネル数(モノラルの場合は 1)。 - attn_num_heads (
int、任意、デフォルトは 8) — エンコーダーの出力に適用される自己注意ブロックのヘッド数。
生オーディオ波形を連続的な潜在変数にエンコードし、それを波形にデコードするための1次元畳み込みオートエンコーダーです。KVAE-Audioで導入されました。
このモデルは ModelMixin を継承しています。すべてのモデルに実装されている汎用的なメソッド(ダウンロードや保存など)については、スーパークラスのドキュメントを参照してください。
decode
< source >( z: Tensorreturn_dict: bool = True ) → DecoderOutput or tuple
パラメータ
- z (
torch.Tensor) — 潜在ベクトルの入力バッチ。 - return_dict (
bool、任意、デフォルトはTrue) — プレーンなタプルではなく DecoderOutput を返すかどうか。
戻り値
DecoderOutput または tuple
If return_dict is True, a DecoderOutput is returned, otherwise a plain
tuple is returned.
バッチの潜在変数(latents)をオーディオ波形にデコードします。
encode
< source >( audio_data: Tensorreturn_dict: bool = True )
オーディオ波形のバッチを潜在変数にエンコードします。
forward
< source >( sample: Tensorsample_posterior: bool = Falsereturn_dict: bool = Truegenerator: typing.Optional[torch.Generator] = None ) → DecoderOutput or tuple
パラメータ
- sample (
torch.Tensor、形状(batch_size, num_channels, num_samples)) — 生オーディオ波形の入力バッチ。 - sample_posterior (
bool、省略可能、デフォルトはFalse) — 後方分布からサンプリングするかどうか。 - return_dict (
bool、任意、デフォルトはTrue) — プレーンなタプルではなく DecoderOutput を返すかどうか。 - generator (
torch.Generator、省略可) — サンプリングを決定論的に行うためのtorch.Generator。
戻り値
DecoderOutput または tuple
return_dictがTrueの場合、DecoderOutputが返され、それ以外の場合は通常のtupleが返されます。