Diffusers documentation
AutoencoderKLMiniMaxH3Audio
AutoencoderKLMiniMaxH3Audio
MiniMax による MiniMax-H3 で使用されるオーディオオートエンコーダーです。波形を入力し波形を出力する構成で、mel フロントエンドも独立したボコーダもありません。DAC 系譜のストライド畳み込みエンコーダー、拡散潜在変数の幅への因果注意投影、そして BigVGAN デコーダーで構成されています。
エンコーダーは 32 kHz で 800 サンプルずつスキップするため、1 秒あたり 40 個の潜在変数(latents)になります。したがって、800 * n サンプルの波形は n 個の潜在変数にエンコードされます。ホップの整数倍でない波形は、右側をパディングします。
causal-attention の projection は attention dispatcher を通るため、set_attention_backend が適用されます。そのマスクは is_causal=True であり、_native_npu を除くすべてのバックエンドがこれを尊重します。_native_npu のカーネルは causal フラグを受け取りません。
オートエンコーダーはモノラルであり、スカラーのscaling_factorではなく、latents_mean / latents_std によってチャネルごとに潜在変数を正規化します。MiniMax-H3 はステレオを 2 つのバッチ項目として保持し、常に後方分布の平均(latent_dist.mode())を消費し、サンプリングは行いません。
import torch
from diffusers import AutoencoderKLMiniMaxH3Audio
audio_vae = AutoencoderKLMiniMaxH3Audio.from_pretrained(
"MiniMaxAI/MiniMax-H3", subfolder="audio_vae", dtype=torch.float32
).to("cuda") # or "mps", "xpu", "cpu"AutoencoderKLMiniMaxH3Audio
class diffusers.AutoencoderKLMiniMaxH3Audio
< source >( encoder_dim: int = 64encoder_rates: tuple = (2, 4, 4, 5, 5)latent_dim: int = 2048latent_channels: int = 32num_attention_heads: int = 8decoder_dim: int = 1024decoder_rates: tuple = (5, 5, 2, 2, 2, 2, 2)decoder_kernel_sizes: tuple = (9, 9, 4, 4, 4, 4, 4)resblock_kernel_sizes: tuple = (3, 7, 11)resblock_dilation_sizes: tuple = ((1, 3, 5), (1, 3, 5), (1, 3, 5))sampling_rate: int = 32000latents_mean: list[float] | None = Nonelatents_std: list[float] | None = None )
パラメータ
- encoder_dim (
int、デフォルトは64) — エンコーダーの最初の畳み込みのチャネル幅です。ダウンサンプリングの各段階で2倍になります。 - encoder_rates (
tuple[int]、デフォルトは(2, 4, 4, 5, 5)) — エンコーダーのストライドです。その積(800)がホップ長となり、32 kHz では 40 latents/s に対応します。 - latent_dim (
int、デフォルトは2048) — 潜在変数への射影の前と後における、エンコーダーのトランクおよびデコーダーの入力の幅。 - latent_channels (
int、デフォルトは32) — 拡散潜在変数の幅、すなわちmean_proj/logs_projの出力チャネル数。 - num_attention_heads (
int、デフォルトは8) — 因果注意機構の投影pre_blockにおけるヘッド数。 - decoder_dim (
int、デフォルトは1024) — BigVGAN の初期チャネル数です。各アップサンプリング段階で半分になります。 - decoder_rates (
tuple[int]、デフォルトは(5, 5, 2, 2, 2, 2, 2)) — BigVGAN のアップサンプリング率です。その積はprod(encoder_rates)と等しくなければなりません。 - decoder_kernel_sizes (
tuple[int]、デフォルトは(9, 9, 4, 4, 4, 4, 4)) — アップサンプリング各段階における転置畳み込みカーネルサイズです。 - resblock_kernel_sizes (
tuple[int]、デフォルトは(3, 7, 11)) — 各アップサンプリング段階における並列 AMP 残差ブロックのカーネルサイズです。 - resblock_dilation_sizes (
tuple[tuple[int]]、デフォルトは((1, 3, 5), (1, 3, 5), (1, 3, 5))) — AMP ブロックごとのディレーション。 - sampling_rate (
int, デフォルトは32000) — 波形のサンプリングレートです。 - latents_mean (
list[float]、任意) — パイプラインが潜変数の正規化 / 非正規化に使用する、チャネルごとの潜変数の平均値。 - latents_std (
list[float]、任意) — パイプラインが潜変数の正規化 / 非正規化に使用する、チャネルごとの潜変数の標準偏差。
MiniMax-H3で使用されるオーディオオートエンコーダー: DAC系譜の畳み込みエンコーダーとBigVGANデコーダーで構成され、モノラル32 kHzの波形を直接処理します。
このモデルは ModelMixin を継承しています。ライブラリがすべてのモデルに対して実装している汎用的なメソッド(ダウンロードや保存など)については、スーパークラスのドキュメントを参照してください。
encode
< source >( sample: Tensorreturn_dict: bool = True ) → MiniMaxH3AudioEncoderOutput or tuple
パラメータ
- sample (
torch.Tensor) —[batch_size, 1, samples]の形状を持つモノラル波形。MiniMax-H3 は、参照クリップのステレオ 2 チャンネルをbatch_size = 2として渡します。 - return_dict (
bool、デフォルトはTrue) —MiniMaxH3AudioEncoderOutputを返すか、通常のタプルを返すかを指定します。
戻り値
MiniMaxH3AudioEncoderOutput または tuple
[batch_size, latent_channels, samples / 800] に対する潜在事後分布。
波形をオーディオ潜在事後分布にエンコードします。
波形はまず hop_length(800 サンプル)の倍数になるように右パディングされます。MiniMax-H3 は常に事後分布の 平均(latent_dist.mode())を使用します。参考実装のパイプラインでは logs_proj ヘッドは評価されません。
decode
< source >( latents: Tensorreturn_dict: bool = True ) → DecoderOutput or tuple
パラメータ
- latents (
torch.Tensor) —[batch_size, latent_channels, num_frames]の形状を持つ、正規化されていない潜在変数。MiniMax-H3 は、2 つのステレオチャネルをbatch_size = 2として渡します。 - return_dict (
bool, defaults toTrue) — Whether to return a DecoderOutput instead of a plain tuple.
戻り値
DecoderOutput または tuple
[batch_size, 1, num_frames * 800] の形状の波形で、[-1, 1] にクランプされています。
オーディオの潜在変数(latents)を波形にデコードします。
forward
< source >( sample: Tensorsample_posterior: bool = Falsereturn_dict: bool = Truegenerator: typing.Optional[torch.Generator] = None ) → DecoderOutput or tuple
パラメータ
- sample (
torch.Tensor) —[batch_size, 1, samples]の形状を持つモノラル波形。 - sample_posterior (
bool、デフォルトはFalse) — モードを取るのではなく、後方分布からサンプリングするかどうか。MiniMax-H3 はモードを使用します。 - return_dict (
bool, defaults toTrue) — Whether to return a DecoderOutput instead of a plain tuple. - generator (
torch.Generator、任意) —sample_posterior=Trueの場合に使用される Generator。
戻り値
DecoderOutput または tuple
[batch_size, 1, num_frames * 800] の形状を持つ、[-1, 1] にクランプされた往復波形です。
波形をエンコードしてからデコードします。