xinference 1.10.0__py3-none-any.whl → 1.11.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of xinference might be problematic. Click here for more details.
- xinference/_version.py +3 -3
- xinference/api/restful_api.py +473 -31
- xinference/client/restful/async_restful_client.py +178 -8
- xinference/client/restful/restful_client.py +151 -3
- xinference/core/supervisor.py +99 -53
- xinference/core/worker.py +10 -0
- xinference/deploy/cmdline.py +15 -0
- xinference/model/audio/core.py +21 -6
- xinference/model/audio/indextts2.py +166 -0
- xinference/model/audio/model_spec.json +58 -21
- xinference/model/image/model_spec.json +159 -90
- xinference/model/image/stable_diffusion/core.py +13 -4
- xinference/model/llm/__init__.py +6 -2
- xinference/model/llm/llm_family.json +1299 -174
- xinference/model/llm/mlx/distributed_models/core.py +41 -0
- xinference/model/llm/mlx/distributed_models/qwen2.py +1 -2
- xinference/model/llm/sglang/core.py +44 -11
- xinference/model/llm/tool_parsers/deepseek_r1_tool_parser.py +94 -32
- xinference/model/llm/tool_parsers/qwen_tool_parser.py +29 -4
- xinference/model/llm/transformers/chatglm.py +3 -0
- xinference/model/llm/transformers/core.py +129 -36
- xinference/model/llm/transformers/multimodal/minicpmv45.py +340 -0
- xinference/model/llm/transformers/multimodal/qwen2_vl.py +34 -8
- xinference/model/llm/transformers/utils.py +23 -0
- xinference/model/llm/utils.py +48 -32
- xinference/model/llm/vllm/core.py +207 -72
- xinference/model/utils.py +74 -31
- xinference/thirdparty/audiotools/__init__.py +10 -0
- xinference/thirdparty/audiotools/core/__init__.py +4 -0
- xinference/thirdparty/audiotools/core/audio_signal.py +1682 -0
- xinference/thirdparty/audiotools/core/display.py +194 -0
- xinference/thirdparty/audiotools/core/dsp.py +390 -0
- xinference/thirdparty/audiotools/core/effects.py +647 -0
- xinference/thirdparty/audiotools/core/ffmpeg.py +211 -0
- xinference/thirdparty/audiotools/core/loudness.py +320 -0
- xinference/thirdparty/audiotools/core/playback.py +252 -0
- xinference/thirdparty/audiotools/core/templates/__init__.py +0 -0
- xinference/thirdparty/audiotools/core/templates/headers.html +322 -0
- xinference/thirdparty/audiotools/core/templates/pandoc.css +407 -0
- xinference/thirdparty/audiotools/core/templates/widget.html +52 -0
- xinference/thirdparty/audiotools/core/util.py +671 -0
- xinference/thirdparty/audiotools/core/whisper.py +97 -0
- xinference/thirdparty/audiotools/data/__init__.py +3 -0
- xinference/thirdparty/audiotools/data/datasets.py +517 -0
- xinference/thirdparty/audiotools/data/preprocess.py +81 -0
- xinference/thirdparty/audiotools/data/transforms.py +1592 -0
- xinference/thirdparty/audiotools/metrics/__init__.py +6 -0
- xinference/thirdparty/audiotools/metrics/distance.py +131 -0
- xinference/thirdparty/audiotools/metrics/quality.py +159 -0
- xinference/thirdparty/audiotools/metrics/spectral.py +247 -0
- xinference/thirdparty/audiotools/ml/__init__.py +5 -0
- xinference/thirdparty/audiotools/ml/accelerator.py +184 -0
- xinference/thirdparty/audiotools/ml/decorators.py +440 -0
- xinference/thirdparty/audiotools/ml/experiment.py +90 -0
- xinference/thirdparty/audiotools/ml/layers/__init__.py +2 -0
- xinference/thirdparty/audiotools/ml/layers/base.py +328 -0
- xinference/thirdparty/audiotools/ml/layers/spectral_gate.py +127 -0
- xinference/thirdparty/audiotools/post.py +140 -0
- xinference/thirdparty/audiotools/preference.py +600 -0
- xinference/thirdparty/fish_speech/fish_speech/text/chn_text_norm/text.py +1 -1
- xinference/thirdparty/indextts/BigVGAN/ECAPA_TDNN.py +656 -0
- xinference/thirdparty/indextts/BigVGAN/__init__.py +0 -0
- xinference/thirdparty/indextts/BigVGAN/activations.py +122 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/__init__.py +0 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/.gitignore +1 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/__init__.py +0 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/activation1d.py +76 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/anti_alias_activation.cpp +23 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/anti_alias_activation_cuda.cu +256 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/compat.h +29 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/load.py +121 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/cuda/type_shim.h +92 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/torch/__init__.py +6 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/torch/act.py +31 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/torch/filter.py +102 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_activation/torch/resample.py +58 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_torch/__init__.py +6 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_torch/act.py +29 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_torch/filter.py +96 -0
- xinference/thirdparty/indextts/BigVGAN/alias_free_torch/resample.py +49 -0
- xinference/thirdparty/indextts/BigVGAN/bigvgan.py +534 -0
- xinference/thirdparty/indextts/BigVGAN/models.py +451 -0
- xinference/thirdparty/indextts/BigVGAN/nnet/CNN.py +546 -0
- xinference/thirdparty/indextts/BigVGAN/nnet/__init__.py +0 -0
- xinference/thirdparty/indextts/BigVGAN/nnet/linear.py +89 -0
- xinference/thirdparty/indextts/BigVGAN/nnet/normalization.py +670 -0
- xinference/thirdparty/indextts/BigVGAN/utils.py +101 -0
- xinference/thirdparty/indextts/__init__.py +0 -0
- xinference/thirdparty/indextts/cli.py +65 -0
- xinference/thirdparty/indextts/gpt/__init__.py +0 -0
- xinference/thirdparty/indextts/gpt/conformer/__init__.py +0 -0
- xinference/thirdparty/indextts/gpt/conformer/attention.py +312 -0
- xinference/thirdparty/indextts/gpt/conformer/embedding.py +163 -0
- xinference/thirdparty/indextts/gpt/conformer/subsampling.py +348 -0
- xinference/thirdparty/indextts/gpt/conformer_encoder.py +520 -0
- xinference/thirdparty/indextts/gpt/model.py +713 -0
- xinference/thirdparty/indextts/gpt/model_v2.py +747 -0
- xinference/thirdparty/indextts/gpt/perceiver.py +317 -0
- xinference/thirdparty/indextts/gpt/transformers_beam_search.py +1013 -0
- xinference/thirdparty/indextts/gpt/transformers_generation_utils.py +4747 -0
- xinference/thirdparty/indextts/gpt/transformers_gpt2.py +1878 -0
- xinference/thirdparty/indextts/gpt/transformers_modeling_utils.py +5525 -0
- xinference/thirdparty/indextts/infer.py +690 -0
- xinference/thirdparty/indextts/infer_v2.py +739 -0
- xinference/thirdparty/indextts/s2mel/dac/__init__.py +16 -0
- xinference/thirdparty/indextts/s2mel/dac/__main__.py +36 -0
- xinference/thirdparty/indextts/s2mel/dac/model/__init__.py +4 -0
- xinference/thirdparty/indextts/s2mel/dac/model/base.py +294 -0
- xinference/thirdparty/indextts/s2mel/dac/model/dac.py +400 -0
- xinference/thirdparty/indextts/s2mel/dac/model/discriminator.py +228 -0
- xinference/thirdparty/indextts/s2mel/dac/model/encodec.py +320 -0
- xinference/thirdparty/indextts/s2mel/dac/nn/__init__.py +3 -0
- xinference/thirdparty/indextts/s2mel/dac/nn/layers.py +33 -0
- xinference/thirdparty/indextts/s2mel/dac/nn/loss.py +368 -0
- xinference/thirdparty/indextts/s2mel/dac/nn/quantize.py +339 -0
- xinference/thirdparty/indextts/s2mel/dac/utils/__init__.py +123 -0
- xinference/thirdparty/indextts/s2mel/dac/utils/decode.py +95 -0
- xinference/thirdparty/indextts/s2mel/dac/utils/encode.py +94 -0
- xinference/thirdparty/indextts/s2mel/hf_utils.py +12 -0
- xinference/thirdparty/indextts/s2mel/modules/alias_free_torch/__init__.py +5 -0
- xinference/thirdparty/indextts/s2mel/modules/alias_free_torch/act.py +29 -0
- xinference/thirdparty/indextts/s2mel/modules/alias_free_torch/filter.py +96 -0
- xinference/thirdparty/indextts/s2mel/modules/alias_free_torch/resample.py +57 -0
- xinference/thirdparty/indextts/s2mel/modules/audio.py +82 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/activations.py +120 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/__init__.py +0 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/activation1d.py +77 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/anti_alias_activation.cpp +23 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/anti_alias_activation_cuda.cu +246 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/compat.h +29 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/load.py +86 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/cuda/type_shim.h +92 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/torch/__init__.py +6 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/torch/act.py +30 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/torch/filter.py +101 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/alias_free_activation/torch/resample.py +58 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/bigvgan.py +492 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/config.json +63 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/env.py +18 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/meldataset.py +354 -0
- xinference/thirdparty/indextts/s2mel/modules/bigvgan/utils.py +99 -0
- xinference/thirdparty/indextts/s2mel/modules/campplus/DTDNN.py +115 -0
- xinference/thirdparty/indextts/s2mel/modules/campplus/classifier.py +70 -0
- xinference/thirdparty/indextts/s2mel/modules/campplus/layers.py +253 -0
- xinference/thirdparty/indextts/s2mel/modules/commons.py +632 -0
- xinference/thirdparty/indextts/s2mel/modules/diffusion_transformer.py +257 -0
- xinference/thirdparty/indextts/s2mel/modules/encodec.py +292 -0
- xinference/thirdparty/indextts/s2mel/modules/flow_matching.py +171 -0
- xinference/thirdparty/indextts/s2mel/modules/gpt_fast/generate.py +436 -0
- xinference/thirdparty/indextts/s2mel/modules/gpt_fast/model.py +360 -0
- xinference/thirdparty/indextts/s2mel/modules/gpt_fast/quantize.py +622 -0
- xinference/thirdparty/indextts/s2mel/modules/hifigan/f0_predictor.py +55 -0
- xinference/thirdparty/indextts/s2mel/modules/hifigan/generator.py +454 -0
- xinference/thirdparty/indextts/s2mel/modules/layers.py +354 -0
- xinference/thirdparty/indextts/s2mel/modules/length_regulator.py +141 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/__init__.py +0 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/api.py +186 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/attentions.py +465 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/checkpoints_v2/converter/config.json +57 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/commons.py +160 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/mel_processing.py +183 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/models.py +499 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/modules.py +598 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/openvoice_app.py +275 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/se_extractor.py +153 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/transforms.py +209 -0
- xinference/thirdparty/indextts/s2mel/modules/openvoice/utils.py +194 -0
- xinference/thirdparty/indextts/s2mel/modules/quantize.py +229 -0
- xinference/thirdparty/indextts/s2mel/modules/rmvpe.py +631 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/__init__.py +4 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/heads.py +164 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/helpers.py +71 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/loss.py +114 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/models.py +118 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/modules.py +213 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/pretrained.py +51 -0
- xinference/thirdparty/indextts/s2mel/modules/vocos/spectral_ops.py +192 -0
- xinference/thirdparty/indextts/s2mel/modules/wavenet.py +174 -0
- xinference/thirdparty/indextts/s2mel/optimizers.py +96 -0
- xinference/thirdparty/indextts/s2mel/wav2vecbert_extract.py +148 -0
- xinference/thirdparty/indextts/utils/__init__.py +0 -0
- xinference/thirdparty/indextts/utils/arch_util.py +120 -0
- xinference/thirdparty/indextts/utils/checkpoint.py +34 -0
- xinference/thirdparty/indextts/utils/common.py +121 -0
- xinference/thirdparty/indextts/utils/feature_extractors.py +50 -0
- xinference/thirdparty/indextts/utils/front.py +536 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/__init__.py +0 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/codec.py +427 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/quantize/__init__.py +11 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/quantize/factorized_vector_quantize.py +150 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/quantize/lookup_free_quantize.py +77 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/quantize/residual_vq.py +177 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/quantize/vector_quantize.py +401 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/amphion_codec/vocos.py +881 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/codec_dataset.py +264 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/codec_inference.py +515 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/codec_sampler.py +126 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/codec_trainer.py +166 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/__init__.py +0 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/alias_free_torch/__init__.py +5 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/alias_free_torch/act.py +29 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/alias_free_torch/filter.py +96 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/alias_free_torch/resample.py +57 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/facodec_dataset.py +98 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/facodec_inference.py +137 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/facodec_trainer.py +776 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/JDC/__init__.py +1 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/JDC/bst.t7 +0 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/JDC/model.py +219 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/attentions.py +437 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/commons.py +331 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/gradient_reversal.py +35 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/layers.py +460 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/quantize.py +741 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/style_encoder.py +110 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/modules/wavenet.py +224 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/facodec/optimizer.py +104 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/kmeans/repcodec_model.py +210 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/kmeans/vocos.py +850 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/melvqgan/melspec.py +108 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/README.md +216 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/__init__.py +6 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/alias_free_torch/__init__.py +5 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/alias_free_torch/act.py +29 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/alias_free_torch/filter.py +96 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/alias_free_torch/resample.py +57 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/facodec.py +1222 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/gradient_reversal.py +35 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/melspec.py +102 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/quantize/__init__.py +7 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/quantize/fvq.py +116 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/quantize/rvq.py +87 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/ns3_codec/transformer.py +234 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/model.py +184 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/__init__.py +27 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/conv.py +346 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/lstm.py +46 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/norm.py +37 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/quantization/__init__.py +14 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/quantization/ac.py +317 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/quantization/core_vq.py +388 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/quantization/distrib.py +135 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/quantization/vq.py +125 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/speechtokenizer/modules/seanet.py +414 -0
- xinference/thirdparty/indextts/utils/maskgct/models/codec/vevo/vevo_repcodec.py +592 -0
- xinference/thirdparty/indextts/utils/maskgct/models/tts/maskgct/ckpt/wav2vec2bert_stats.pt +0 -0
- xinference/thirdparty/indextts/utils/maskgct/models/tts/maskgct/llama_nar.py +650 -0
- xinference/thirdparty/indextts/utils/maskgct/models/tts/maskgct/maskgct_s2a.py +503 -0
- xinference/thirdparty/indextts/utils/maskgct_utils.py +259 -0
- xinference/thirdparty/indextts/utils/text_utils.py +41 -0
- xinference/thirdparty/indextts/utils/typical_sampling.py +30 -0
- xinference/thirdparty/indextts/utils/utils.py +93 -0
- xinference/thirdparty/indextts/utils/webui_utils.py +42 -0
- xinference/thirdparty/indextts/utils/xtransformers.py +1247 -0
- xinference/thirdparty/indextts/vqvae/__init__.py +0 -0
- xinference/thirdparty/indextts/vqvae/xtts_dvae.py +395 -0
- xinference/thirdparty/melo/text/chinese_mix.py +2 -2
- xinference/types.py +9 -0
- xinference/ui/gradio/media_interface.py +66 -8
- xinference/ui/web/ui/build/asset-manifest.json +6 -6
- xinference/ui/web/ui/build/index.html +1 -1
- xinference/ui/web/ui/build/static/css/main.5ea97072.css +2 -0
- xinference/ui/web/ui/build/static/css/main.5ea97072.css.map +1 -0
- xinference/ui/web/ui/build/static/js/main.45e78536.js +3 -0
- xinference/ui/web/ui/build/static/js/{main.1086c759.js.LICENSE.txt → main.45e78536.js.LICENSE.txt} +0 -7
- xinference/ui/web/ui/build/static/js/main.45e78536.js.map +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/089c38df5f52348d212ed868dda5c518a42e0c2762caed4175487c0405830c35.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/2b6e3a5b6eb2c5c5f2d007e68cd46c372721cd52bf63508adcdb21ecf79241d8.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/2d887825fd07a56f872eda4420da25fba0b5b62a23bdcc6c6da1a5281887f618.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/4001f9c3e64e73a4f2158826650c174a59d5e3f89ddecddf17cbb6bb688cc4ca.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/4a7018a69e6b7f90fc313248c2aa86f2a8f1eb1db120df586047a8023549b44b.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/64b12aaa1c1d1bf53820ada8a63769067c0ccc5aab46b32348eb1917ae7f2a11.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/7275b67c78ec76ce38a686bb8a576d8c9cecf54e1573614c84859d538efb9be5.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/a68b6ee3b31eadc051fb95ce8f8ccb9c2e8b52c60f290dbab545a1917e065282.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/ae8771cc37693feb160fa8727231312a0c54ef2d1d1ca893be568cd70016ca7e.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/bb4e8722d2d41d87f1fce3661bc8937bffe9448e231fc5f0462630849e851592.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/be6aada1ee4adc2bbf65dbe56d17db32bb3b5478be05d6b527805a8ba6cfb2b9.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/de91c352653c233cf0cb6674e6e04049a44fd0e1156560de65d5c4620521391e.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/e85f7002fc325c83b9c9cd8a1619e5b3ebc701d30e811afc284b88e6ae710cb5.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/e8b603c78944bf3d213639078bfe155ff5c0dfa4048a93cbb967cad6a4eb4ff3.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/ea2a26361204e70cf1018d6990fb6354bed82b3ac69690391e0f100385e7abb7.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/f05535160a508b2a312de546a6de234776c613db276479ea4253c0b1bdeeb7d6.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/f09ba9e11106bd59a0de10cc85c55084097729dcab575f43dfcf07375961ed87.json +1 -0
- xinference/ui/web/ui/node_modules/.package-lock.json +0 -33
- xinference/ui/web/ui/package-lock.json +0 -34
- xinference/ui/web/ui/package.json +0 -1
- xinference/ui/web/ui/src/locales/en.json +9 -3
- xinference/ui/web/ui/src/locales/ja.json +9 -3
- xinference/ui/web/ui/src/locales/ko.json +9 -3
- xinference/ui/web/ui/src/locales/zh.json +9 -3
- {xinference-1.10.0.dist-info → xinference-1.11.0.dist-info}/METADATA +24 -6
- {xinference-1.10.0.dist-info → xinference-1.11.0.dist-info}/RECORD +296 -77
- xinference/ui/web/ui/build/static/css/main.013f296b.css +0 -2
- xinference/ui/web/ui/build/static/css/main.013f296b.css.map +0 -1
- xinference/ui/web/ui/build/static/js/main.1086c759.js +0 -3
- xinference/ui/web/ui/build/static/js/main.1086c759.js.map +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/0b0f77000cc1b482ca091cfbcae511dfe02f08916971645fad21d0b1234d04a2.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/1c5f8ff423a7c9202bea60b15680f04b1e9964b445b0da3f86c6ff70cf24e797.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/44ce7993e344980e3ed4f13e8f69237d4a5dfc60e37ca6b54f51f8ee1357bd67.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/4aec1cc414ac3ebb3481d3d915e4db597d9127de813291346eacb8554ab170d4.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/644cfec52f3c57a6e222ce60f112237a1efefe9835efd9aad857a685f53d8eed.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/663436f72af53fe0d72394f56d003fa4e0bba489e5bb4e483fd34b00f84637f7.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/69db82ca9bfe27fe417cc6cf2b1716b09be9c6f0cd198530f12bfc60e801bbcf.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/85087e27618d740c236bf159f30e0219db443ab55f0997388eed5fde6f9e90cc.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/88b07838348864aa86c672be3bbca1e9f58f6f3a2881b32070ec27f4e7b449d1.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/8b8cd408ccfbe115acef27ccfa5b233da8597131a2a5712add13e1e4d5d4504b.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/a23824fe746b9c6ca5eee9159b5764d1ff1653c1d856288c0f75c742bbb0023b.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/a3eb18af328280b139693c9092dff2a0ef8c9a967e6c8956ceee0996611f1984.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/bc1aacc65a102db325ca61bcd2f681e1ae22c36a1f1d98a6ff5e4ad49dc7544f.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/c682fd521747c19dae437d83ce3235a306ce6b68e24a117bc57c27ebb8d1f1ca.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/d5c224be7081f18cba1678b7874a9782eba895df004874ff8f243f94ba79942a.json +0 -1
- xinference/ui/web/ui/node_modules/.cache/babel-loader/f7f18bfb539b036a6a342176dd98a85df5057a884a8da978d679f2a0264883d0.json +0 -1
- xinference/ui/web/ui/node_modules/clipboard/.babelrc.json +0 -11
- xinference/ui/web/ui/node_modules/clipboard/.eslintrc.json +0 -24
- xinference/ui/web/ui/node_modules/clipboard/.prettierrc.json +0 -9
- xinference/ui/web/ui/node_modules/clipboard/bower.json +0 -18
- xinference/ui/web/ui/node_modules/clipboard/composer.json +0 -25
- xinference/ui/web/ui/node_modules/clipboard/package.json +0 -63
- xinference/ui/web/ui/node_modules/delegate/package.json +0 -31
- xinference/ui/web/ui/node_modules/good-listener/bower.json +0 -11
- xinference/ui/web/ui/node_modules/good-listener/package.json +0 -35
- xinference/ui/web/ui/node_modules/select/bower.json +0 -13
- xinference/ui/web/ui/node_modules/select/package.json +0 -29
- xinference/ui/web/ui/node_modules/tiny-emitter/package.json +0 -53
- {xinference-1.10.0.dist-info → xinference-1.11.0.dist-info}/WHEEL +0 -0
- {xinference-1.10.0.dist-info → xinference-1.11.0.dist-info}/entry_points.txt +0 -0
- {xinference-1.10.0.dist-info → xinference-1.11.0.dist-info}/licenses/LICENSE +0 -0
- {xinference-1.10.0.dist-info → xinference-1.11.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Adapted from https://github.com/junjun3518/alias-free-torch under the Apache License 2.0
|
|
2
|
+
# LICENSE is in incl_licenses directory.
|
|
3
|
+
|
|
4
|
+
import torch.nn as nn
|
|
5
|
+
from .resample import UpSample1d, DownSample1d
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Activation1d(nn.Module):
|
|
9
|
+
def __init__(
|
|
10
|
+
self,
|
|
11
|
+
activation,
|
|
12
|
+
up_ratio: int = 2,
|
|
13
|
+
down_ratio: int = 2,
|
|
14
|
+
up_kernel_size: int = 12,
|
|
15
|
+
down_kernel_size: int = 12,
|
|
16
|
+
):
|
|
17
|
+
super().__init__()
|
|
18
|
+
self.up_ratio = up_ratio
|
|
19
|
+
self.down_ratio = down_ratio
|
|
20
|
+
self.act = activation
|
|
21
|
+
self.upsample = UpSample1d(up_ratio, up_kernel_size)
|
|
22
|
+
self.downsample = DownSample1d(down_ratio, down_kernel_size)
|
|
23
|
+
|
|
24
|
+
# x: [B,C,T]
|
|
25
|
+
def forward(self, x):
|
|
26
|
+
x = self.upsample(x)
|
|
27
|
+
x = self.act(x)
|
|
28
|
+
x = self.downsample(x)
|
|
29
|
+
|
|
30
|
+
return x
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Adapted from https://github.com/junjun3518/alias-free-torch under the Apache License 2.0
|
|
2
|
+
# LICENSE is in incl_licenses directory.
|
|
3
|
+
|
|
4
|
+
import torch
|
|
5
|
+
import torch.nn as nn
|
|
6
|
+
import torch.nn.functional as F
|
|
7
|
+
import math
|
|
8
|
+
|
|
9
|
+
if "sinc" in dir(torch):
|
|
10
|
+
sinc = torch.sinc
|
|
11
|
+
else:
|
|
12
|
+
# This code is adopted from adefossez's julius.core.sinc under the MIT License
|
|
13
|
+
# https://adefossez.github.io/julius/julius/core.html
|
|
14
|
+
# LICENSE is in incl_licenses directory.
|
|
15
|
+
def sinc(x: torch.Tensor):
|
|
16
|
+
"""
|
|
17
|
+
Implementation of sinc, i.e. sin(pi * x) / (pi * x)
|
|
18
|
+
__Warning__: Different to julius.sinc, the input is multiplied by `pi`!
|
|
19
|
+
"""
|
|
20
|
+
return torch.where(
|
|
21
|
+
x == 0,
|
|
22
|
+
torch.tensor(1.0, device=x.device, dtype=x.dtype),
|
|
23
|
+
torch.sin(math.pi * x) / math.pi / x,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# This code is adopted from adefossez's julius.lowpass.LowPassFilters under the MIT License
|
|
28
|
+
# https://adefossez.github.io/julius/julius/lowpass.html
|
|
29
|
+
# LICENSE is in incl_licenses directory.
|
|
30
|
+
def kaiser_sinc_filter1d(
|
|
31
|
+
cutoff, half_width, kernel_size
|
|
32
|
+
): # return filter [1,1,kernel_size]
|
|
33
|
+
even = kernel_size % 2 == 0
|
|
34
|
+
half_size = kernel_size // 2
|
|
35
|
+
|
|
36
|
+
# For kaiser window
|
|
37
|
+
delta_f = 4 * half_width
|
|
38
|
+
A = 2.285 * (half_size - 1) * math.pi * delta_f + 7.95
|
|
39
|
+
if A > 50.0:
|
|
40
|
+
beta = 0.1102 * (A - 8.7)
|
|
41
|
+
elif A >= 21.0:
|
|
42
|
+
beta = 0.5842 * (A - 21) ** 0.4 + 0.07886 * (A - 21.0)
|
|
43
|
+
else:
|
|
44
|
+
beta = 0.0
|
|
45
|
+
window = torch.kaiser_window(kernel_size, beta=beta, periodic=False)
|
|
46
|
+
|
|
47
|
+
# ratio = 0.5/cutoff -> 2 * cutoff = 1 / ratio
|
|
48
|
+
if even:
|
|
49
|
+
time = torch.arange(-half_size, half_size) + 0.5
|
|
50
|
+
else:
|
|
51
|
+
time = torch.arange(kernel_size) - half_size
|
|
52
|
+
if cutoff == 0:
|
|
53
|
+
filter_ = torch.zeros_like(time)
|
|
54
|
+
else:
|
|
55
|
+
filter_ = 2 * cutoff * window * sinc(2 * cutoff * time)
|
|
56
|
+
"""
|
|
57
|
+
Normalize filter to have sum = 1, otherwise we will have a small leakage of the constant component in the input signal.
|
|
58
|
+
"""
|
|
59
|
+
filter_ /= filter_.sum()
|
|
60
|
+
filter = filter_.view(1, 1, kernel_size)
|
|
61
|
+
|
|
62
|
+
return filter
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class LowPassFilter1d(nn.Module):
|
|
66
|
+
def __init__(
|
|
67
|
+
self,
|
|
68
|
+
cutoff=0.5,
|
|
69
|
+
half_width=0.6,
|
|
70
|
+
stride: int = 1,
|
|
71
|
+
padding: bool = True,
|
|
72
|
+
padding_mode: str = "replicate",
|
|
73
|
+
kernel_size: int = 12,
|
|
74
|
+
):
|
|
75
|
+
"""
|
|
76
|
+
kernel_size should be even number for stylegan3 setup, in this implementation, odd number is also possible.
|
|
77
|
+
"""
|
|
78
|
+
super().__init__()
|
|
79
|
+
if cutoff < -0.0:
|
|
80
|
+
raise ValueError("Minimum cutoff must be larger than zero.")
|
|
81
|
+
if cutoff > 0.5:
|
|
82
|
+
raise ValueError("A cutoff above 0.5 does not make sense.")
|
|
83
|
+
self.kernel_size = kernel_size
|
|
84
|
+
self.even = kernel_size % 2 == 0
|
|
85
|
+
self.pad_left = kernel_size // 2 - int(self.even)
|
|
86
|
+
self.pad_right = kernel_size // 2
|
|
87
|
+
self.stride = stride
|
|
88
|
+
self.padding = padding
|
|
89
|
+
self.padding_mode = padding_mode
|
|
90
|
+
filter = kaiser_sinc_filter1d(cutoff, half_width, kernel_size)
|
|
91
|
+
self.register_buffer("filter", filter)
|
|
92
|
+
|
|
93
|
+
# Input [B, C, T]
|
|
94
|
+
def forward(self, x):
|
|
95
|
+
_, C, _ = x.shape
|
|
96
|
+
|
|
97
|
+
if self.padding:
|
|
98
|
+
x = F.pad(x, (self.pad_left, self.pad_right), mode=self.padding_mode)
|
|
99
|
+
out = F.conv1d(x, self.filter.expand(C, -1, -1), stride=self.stride, groups=C)
|
|
100
|
+
|
|
101
|
+
return out
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Adapted from https://github.com/junjun3518/alias-free-torch under the Apache License 2.0
|
|
2
|
+
# LICENSE is in incl_licenses directory.
|
|
3
|
+
|
|
4
|
+
import torch.nn as nn
|
|
5
|
+
from torch.nn import functional as F
|
|
6
|
+
from .filter import LowPassFilter1d
|
|
7
|
+
from .filter import kaiser_sinc_filter1d
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class UpSample1d(nn.Module):
|
|
11
|
+
def __init__(self, ratio=2, kernel_size=None):
|
|
12
|
+
super().__init__()
|
|
13
|
+
self.ratio = ratio
|
|
14
|
+
self.kernel_size = (
|
|
15
|
+
int(6 * ratio // 2) * 2 if kernel_size is None else kernel_size
|
|
16
|
+
)
|
|
17
|
+
self.stride = ratio
|
|
18
|
+
self.pad = self.kernel_size // ratio - 1
|
|
19
|
+
self.pad_left = self.pad * self.stride + (self.kernel_size - self.stride) // 2
|
|
20
|
+
self.pad_right = (
|
|
21
|
+
self.pad * self.stride + (self.kernel_size - self.stride + 1) // 2
|
|
22
|
+
)
|
|
23
|
+
filter = kaiser_sinc_filter1d(
|
|
24
|
+
cutoff=0.5 / ratio, half_width=0.6 / ratio, kernel_size=self.kernel_size
|
|
25
|
+
)
|
|
26
|
+
self.register_buffer("filter", filter)
|
|
27
|
+
|
|
28
|
+
# x: [B, C, T]
|
|
29
|
+
def forward(self, x):
|
|
30
|
+
_, C, _ = x.shape
|
|
31
|
+
|
|
32
|
+
x = F.pad(x, (self.pad, self.pad), mode="replicate")
|
|
33
|
+
x = self.ratio * F.conv_transpose1d(
|
|
34
|
+
x, self.filter.expand(C, -1, -1), stride=self.stride, groups=C
|
|
35
|
+
)
|
|
36
|
+
x = x[..., self.pad_left : -self.pad_right]
|
|
37
|
+
|
|
38
|
+
return x
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class DownSample1d(nn.Module):
|
|
42
|
+
def __init__(self, ratio=2, kernel_size=None):
|
|
43
|
+
super().__init__()
|
|
44
|
+
self.ratio = ratio
|
|
45
|
+
self.kernel_size = (
|
|
46
|
+
int(6 * ratio // 2) * 2 if kernel_size is None else kernel_size
|
|
47
|
+
)
|
|
48
|
+
self.lowpass = LowPassFilter1d(
|
|
49
|
+
cutoff=0.5 / ratio,
|
|
50
|
+
half_width=0.6 / ratio,
|
|
51
|
+
stride=ratio,
|
|
52
|
+
kernel_size=self.kernel_size,
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
def forward(self, x):
|
|
56
|
+
xx = self.lowpass(x)
|
|
57
|
+
|
|
58
|
+
return xx
|
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
# Copyright (c) 2024 NVIDIA CORPORATION.
|
|
2
|
+
# Licensed under the MIT license.
|
|
3
|
+
|
|
4
|
+
# Adapted from https://github.com/jik876/hifi-gan under the MIT license.
|
|
5
|
+
# LICENSE is in incl_licenses directory.
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import json
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Optional, Union, Dict
|
|
11
|
+
|
|
12
|
+
import torch
|
|
13
|
+
import torch.nn as nn
|
|
14
|
+
from torch.nn import Conv1d, ConvTranspose1d
|
|
15
|
+
from torch.nn.utils import weight_norm, remove_weight_norm
|
|
16
|
+
|
|
17
|
+
from . import activations
|
|
18
|
+
from .utils import init_weights, get_padding
|
|
19
|
+
from .alias_free_activation.torch.act import Activation1d as TorchActivation1d
|
|
20
|
+
from .env import AttrDict
|
|
21
|
+
|
|
22
|
+
from huggingface_hub import PyTorchModelHubMixin, hf_hub_download
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def load_hparams_from_json(path) -> AttrDict:
|
|
26
|
+
with open(path) as f:
|
|
27
|
+
data = f.read()
|
|
28
|
+
return AttrDict(json.loads(data))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class AMPBlock1(torch.nn.Module):
|
|
32
|
+
"""
|
|
33
|
+
AMPBlock applies Snake / SnakeBeta activation functions with trainable parameters that control periodicity, defined for each layer.
|
|
34
|
+
AMPBlock1 has additional self.convs2 that contains additional Conv1d layers with a fixed dilation=1 followed by each layer in self.convs1
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
h (AttrDict): Hyperparameters.
|
|
38
|
+
channels (int): Number of convolution channels.
|
|
39
|
+
kernel_size (int): Size of the convolution kernel. Default is 3.
|
|
40
|
+
dilation (tuple): Dilation rates for the convolutions. Each dilation layer has two convolutions. Default is (1, 3, 5).
|
|
41
|
+
activation (str): Activation function type. Should be either 'snake' or 'snakebeta'. Default is None.
|
|
42
|
+
"""
|
|
43
|
+
|
|
44
|
+
def __init__(
|
|
45
|
+
self,
|
|
46
|
+
h: AttrDict,
|
|
47
|
+
channels: int,
|
|
48
|
+
kernel_size: int = 3,
|
|
49
|
+
dilation: tuple = (1, 3, 5),
|
|
50
|
+
activation: str = None,
|
|
51
|
+
):
|
|
52
|
+
super().__init__()
|
|
53
|
+
|
|
54
|
+
self.h = h
|
|
55
|
+
|
|
56
|
+
self.convs1 = nn.ModuleList(
|
|
57
|
+
[
|
|
58
|
+
weight_norm(
|
|
59
|
+
Conv1d(
|
|
60
|
+
channels,
|
|
61
|
+
channels,
|
|
62
|
+
kernel_size,
|
|
63
|
+
stride=1,
|
|
64
|
+
dilation=d,
|
|
65
|
+
padding=get_padding(kernel_size, d),
|
|
66
|
+
)
|
|
67
|
+
)
|
|
68
|
+
for d in dilation
|
|
69
|
+
]
|
|
70
|
+
)
|
|
71
|
+
self.convs1.apply(init_weights)
|
|
72
|
+
|
|
73
|
+
self.convs2 = nn.ModuleList(
|
|
74
|
+
[
|
|
75
|
+
weight_norm(
|
|
76
|
+
Conv1d(
|
|
77
|
+
channels,
|
|
78
|
+
channels,
|
|
79
|
+
kernel_size,
|
|
80
|
+
stride=1,
|
|
81
|
+
dilation=1,
|
|
82
|
+
padding=get_padding(kernel_size, 1),
|
|
83
|
+
)
|
|
84
|
+
)
|
|
85
|
+
for _ in range(len(dilation))
|
|
86
|
+
]
|
|
87
|
+
)
|
|
88
|
+
self.convs2.apply(init_weights)
|
|
89
|
+
|
|
90
|
+
self.num_layers = len(self.convs1) + len(
|
|
91
|
+
self.convs2
|
|
92
|
+
) # Total number of conv layers
|
|
93
|
+
|
|
94
|
+
# Select which Activation1d, lazy-load cuda version to ensure backward compatibility
|
|
95
|
+
if self.h.get("use_cuda_kernel", False):
|
|
96
|
+
from .alias_free_activation.cuda.activation1d import (
|
|
97
|
+
Activation1d as CudaActivation1d,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
Activation1d = CudaActivation1d
|
|
101
|
+
else:
|
|
102
|
+
Activation1d = TorchActivation1d
|
|
103
|
+
|
|
104
|
+
# Activation functions
|
|
105
|
+
if activation == "snake":
|
|
106
|
+
self.activations = nn.ModuleList(
|
|
107
|
+
[
|
|
108
|
+
Activation1d(
|
|
109
|
+
activation=activations.Snake(
|
|
110
|
+
channels, alpha_logscale=h.snake_logscale
|
|
111
|
+
)
|
|
112
|
+
)
|
|
113
|
+
for _ in range(self.num_layers)
|
|
114
|
+
]
|
|
115
|
+
)
|
|
116
|
+
elif activation == "snakebeta":
|
|
117
|
+
self.activations = nn.ModuleList(
|
|
118
|
+
[
|
|
119
|
+
Activation1d(
|
|
120
|
+
activation=activations.SnakeBeta(
|
|
121
|
+
channels, alpha_logscale=h.snake_logscale
|
|
122
|
+
)
|
|
123
|
+
)
|
|
124
|
+
for _ in range(self.num_layers)
|
|
125
|
+
]
|
|
126
|
+
)
|
|
127
|
+
else:
|
|
128
|
+
raise NotImplementedError(
|
|
129
|
+
"activation incorrectly specified. check the config file and look for 'activation'."
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
def forward(self, x):
|
|
133
|
+
acts1, acts2 = self.activations[::2], self.activations[1::2]
|
|
134
|
+
for c1, c2, a1, a2 in zip(self.convs1, self.convs2, acts1, acts2):
|
|
135
|
+
xt = a1(x)
|
|
136
|
+
xt = c1(xt)
|
|
137
|
+
xt = a2(xt)
|
|
138
|
+
xt = c2(xt)
|
|
139
|
+
x = xt + x
|
|
140
|
+
|
|
141
|
+
return x
|
|
142
|
+
|
|
143
|
+
def remove_weight_norm(self):
|
|
144
|
+
for l in self.convs1:
|
|
145
|
+
remove_weight_norm(l)
|
|
146
|
+
for l in self.convs2:
|
|
147
|
+
remove_weight_norm(l)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
class AMPBlock2(torch.nn.Module):
|
|
151
|
+
"""
|
|
152
|
+
AMPBlock applies Snake / SnakeBeta activation functions with trainable parameters that control periodicity, defined for each layer.
|
|
153
|
+
Unlike AMPBlock1, AMPBlock2 does not contain extra Conv1d layers with fixed dilation=1
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
h (AttrDict): Hyperparameters.
|
|
157
|
+
channels (int): Number of convolution channels.
|
|
158
|
+
kernel_size (int): Size of the convolution kernel. Default is 3.
|
|
159
|
+
dilation (tuple): Dilation rates for the convolutions. Each dilation layer has two convolutions. Default is (1, 3, 5).
|
|
160
|
+
activation (str): Activation function type. Should be either 'snake' or 'snakebeta'. Default is None.
|
|
161
|
+
"""
|
|
162
|
+
|
|
163
|
+
def __init__(
|
|
164
|
+
self,
|
|
165
|
+
h: AttrDict,
|
|
166
|
+
channels: int,
|
|
167
|
+
kernel_size: int = 3,
|
|
168
|
+
dilation: tuple = (1, 3, 5),
|
|
169
|
+
activation: str = None,
|
|
170
|
+
):
|
|
171
|
+
super().__init__()
|
|
172
|
+
|
|
173
|
+
self.h = h
|
|
174
|
+
|
|
175
|
+
self.convs = nn.ModuleList(
|
|
176
|
+
[
|
|
177
|
+
weight_norm(
|
|
178
|
+
Conv1d(
|
|
179
|
+
channels,
|
|
180
|
+
channels,
|
|
181
|
+
kernel_size,
|
|
182
|
+
stride=1,
|
|
183
|
+
dilation=d,
|
|
184
|
+
padding=get_padding(kernel_size, d),
|
|
185
|
+
)
|
|
186
|
+
)
|
|
187
|
+
for d in dilation
|
|
188
|
+
]
|
|
189
|
+
)
|
|
190
|
+
self.convs.apply(init_weights)
|
|
191
|
+
|
|
192
|
+
self.num_layers = len(self.convs) # Total number of conv layers
|
|
193
|
+
|
|
194
|
+
# Select which Activation1d, lazy-load cuda version to ensure backward compatibility
|
|
195
|
+
if self.h.get("use_cuda_kernel", False):
|
|
196
|
+
from .alias_free_activation.cuda.activation1d import (
|
|
197
|
+
Activation1d as CudaActivation1d,
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
Activation1d = CudaActivation1d
|
|
201
|
+
else:
|
|
202
|
+
Activation1d = TorchActivation1d
|
|
203
|
+
|
|
204
|
+
# Activation functions
|
|
205
|
+
if activation == "snake":
|
|
206
|
+
self.activations = nn.ModuleList(
|
|
207
|
+
[
|
|
208
|
+
Activation1d(
|
|
209
|
+
activation=activations.Snake(
|
|
210
|
+
channels, alpha_logscale=h.snake_logscale
|
|
211
|
+
)
|
|
212
|
+
)
|
|
213
|
+
for _ in range(self.num_layers)
|
|
214
|
+
]
|
|
215
|
+
)
|
|
216
|
+
elif activation == "snakebeta":
|
|
217
|
+
self.activations = nn.ModuleList(
|
|
218
|
+
[
|
|
219
|
+
Activation1d(
|
|
220
|
+
activation=activations.SnakeBeta(
|
|
221
|
+
channels, alpha_logscale=h.snake_logscale
|
|
222
|
+
)
|
|
223
|
+
)
|
|
224
|
+
for _ in range(self.num_layers)
|
|
225
|
+
]
|
|
226
|
+
)
|
|
227
|
+
else:
|
|
228
|
+
raise NotImplementedError(
|
|
229
|
+
"activation incorrectly specified. check the config file and look for 'activation'."
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
def forward(self, x):
|
|
233
|
+
for c, a in zip(self.convs, self.activations):
|
|
234
|
+
xt = a(x)
|
|
235
|
+
xt = c(xt)
|
|
236
|
+
x = xt + x
|
|
237
|
+
|
|
238
|
+
def remove_weight_norm(self):
|
|
239
|
+
for l in self.convs:
|
|
240
|
+
remove_weight_norm(l)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
class BigVGAN(
|
|
244
|
+
torch.nn.Module,
|
|
245
|
+
PyTorchModelHubMixin,
|
|
246
|
+
library_name="bigvgan",
|
|
247
|
+
repo_url="https://github.com/NVIDIA/BigVGAN",
|
|
248
|
+
docs_url="https://github.com/NVIDIA/BigVGAN/blob/main/README.md",
|
|
249
|
+
pipeline_tag="audio-to-audio",
|
|
250
|
+
license="mit",
|
|
251
|
+
tags=["neural-vocoder", "audio-generation", "arxiv:2206.04658"],
|
|
252
|
+
):
|
|
253
|
+
"""
|
|
254
|
+
BigVGAN is a neural vocoder model that applies anti-aliased periodic activation for residual blocks (resblocks).
|
|
255
|
+
New in BigVGAN-v2: it can optionally use optimized CUDA kernels for AMP (anti-aliased multi-periodicity) blocks.
|
|
256
|
+
|
|
257
|
+
Args:
|
|
258
|
+
h (AttrDict): Hyperparameters.
|
|
259
|
+
use_cuda_kernel (bool): If set to True, loads optimized CUDA kernels for AMP. This should be used for inference only, as training is not supported with CUDA kernels.
|
|
260
|
+
|
|
261
|
+
Note:
|
|
262
|
+
- The `use_cuda_kernel` parameter should be used for inference only, as training with CUDA kernels is not supported.
|
|
263
|
+
- Ensure that the activation function is correctly specified in the hyperparameters (h.activation).
|
|
264
|
+
"""
|
|
265
|
+
|
|
266
|
+
def __init__(self, h: AttrDict, use_cuda_kernel: bool = False):
|
|
267
|
+
super().__init__()
|
|
268
|
+
self.h = h
|
|
269
|
+
self.h["use_cuda_kernel"] = use_cuda_kernel
|
|
270
|
+
|
|
271
|
+
# Select which Activation1d, lazy-load cuda version to ensure backward compatibility
|
|
272
|
+
if self.h.get("use_cuda_kernel", False):
|
|
273
|
+
from .alias_free_activation.cuda.activation1d import (
|
|
274
|
+
Activation1d as CudaActivation1d,
|
|
275
|
+
)
|
|
276
|
+
|
|
277
|
+
Activation1d = CudaActivation1d
|
|
278
|
+
else:
|
|
279
|
+
Activation1d = TorchActivation1d
|
|
280
|
+
|
|
281
|
+
self.num_kernels = len(h.resblock_kernel_sizes)
|
|
282
|
+
self.num_upsamples = len(h.upsample_rates)
|
|
283
|
+
|
|
284
|
+
# Pre-conv
|
|
285
|
+
self.conv_pre = weight_norm(
|
|
286
|
+
Conv1d(h.num_mels, h.upsample_initial_channel, 7, 1, padding=3)
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
# Define which AMPBlock to use. BigVGAN uses AMPBlock1 as default
|
|
290
|
+
if h.resblock == "1":
|
|
291
|
+
resblock_class = AMPBlock1
|
|
292
|
+
elif h.resblock == "2":
|
|
293
|
+
resblock_class = AMPBlock2
|
|
294
|
+
else:
|
|
295
|
+
raise ValueError(
|
|
296
|
+
f"Incorrect resblock class specified in hyperparameters. Got {h.resblock}"
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
# Transposed conv-based upsamplers. does not apply anti-aliasing
|
|
300
|
+
self.ups = nn.ModuleList()
|
|
301
|
+
for i, (u, k) in enumerate(zip(h.upsample_rates, h.upsample_kernel_sizes)):
|
|
302
|
+
self.ups.append(
|
|
303
|
+
nn.ModuleList(
|
|
304
|
+
[
|
|
305
|
+
weight_norm(
|
|
306
|
+
ConvTranspose1d(
|
|
307
|
+
h.upsample_initial_channel // (2 ** i),
|
|
308
|
+
h.upsample_initial_channel // (2 ** (i + 1)),
|
|
309
|
+
k,
|
|
310
|
+
u,
|
|
311
|
+
padding=(k - u) // 2,
|
|
312
|
+
)
|
|
313
|
+
)
|
|
314
|
+
]
|
|
315
|
+
)
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
# Residual blocks using anti-aliased multi-periodicity composition modules (AMP)
|
|
319
|
+
self.resblocks = nn.ModuleList()
|
|
320
|
+
for i in range(len(self.ups)):
|
|
321
|
+
ch = h.upsample_initial_channel // (2 ** (i + 1))
|
|
322
|
+
for j, (k, d) in enumerate(
|
|
323
|
+
zip(h.resblock_kernel_sizes, h.resblock_dilation_sizes)
|
|
324
|
+
):
|
|
325
|
+
self.resblocks.append(
|
|
326
|
+
resblock_class(h, ch, k, d, activation=h.activation)
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
# Post-conv
|
|
330
|
+
activation_post = (
|
|
331
|
+
activations.Snake(ch, alpha_logscale=h.snake_logscale)
|
|
332
|
+
if h.activation == "snake"
|
|
333
|
+
else (
|
|
334
|
+
activations.SnakeBeta(ch, alpha_logscale=h.snake_logscale)
|
|
335
|
+
if h.activation == "snakebeta"
|
|
336
|
+
else None
|
|
337
|
+
)
|
|
338
|
+
)
|
|
339
|
+
if activation_post is None:
|
|
340
|
+
raise NotImplementedError(
|
|
341
|
+
"activation incorrectly specified. check the config file and look for 'activation'."
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
self.activation_post = Activation1d(activation=activation_post)
|
|
345
|
+
|
|
346
|
+
# Whether to use bias for the final conv_post. Default to True for backward compatibility
|
|
347
|
+
self.use_bias_at_final = h.get("use_bias_at_final", True)
|
|
348
|
+
self.conv_post = weight_norm(
|
|
349
|
+
Conv1d(ch, 1, 7, 1, padding=3, bias=self.use_bias_at_final)
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
# Weight initialization
|
|
353
|
+
for i in range(len(self.ups)):
|
|
354
|
+
self.ups[i].apply(init_weights)
|
|
355
|
+
self.conv_post.apply(init_weights)
|
|
356
|
+
|
|
357
|
+
# Final tanh activation. Defaults to True for backward compatibility
|
|
358
|
+
self.use_tanh_at_final = h.get("use_tanh_at_final", True)
|
|
359
|
+
|
|
360
|
+
def forward(self, x):
|
|
361
|
+
# Pre-conv
|
|
362
|
+
x = self.conv_pre(x)
|
|
363
|
+
|
|
364
|
+
for i in range(self.num_upsamples):
|
|
365
|
+
# Upsampling
|
|
366
|
+
for i_up in range(len(self.ups[i])):
|
|
367
|
+
x = self.ups[i][i_up](x)
|
|
368
|
+
# AMP blocks
|
|
369
|
+
xs = None
|
|
370
|
+
for j in range(self.num_kernels):
|
|
371
|
+
if xs is None:
|
|
372
|
+
xs = self.resblocks[i * self.num_kernels + j](x)
|
|
373
|
+
else:
|
|
374
|
+
xs += self.resblocks[i * self.num_kernels + j](x)
|
|
375
|
+
x = xs / self.num_kernels
|
|
376
|
+
|
|
377
|
+
# Post-conv
|
|
378
|
+
x = self.activation_post(x)
|
|
379
|
+
x = self.conv_post(x)
|
|
380
|
+
# Final tanh activation
|
|
381
|
+
if self.use_tanh_at_final:
|
|
382
|
+
x = torch.tanh(x)
|
|
383
|
+
else:
|
|
384
|
+
x = torch.clamp(x, min=-1.0, max=1.0) # Bound the output to [-1, 1]
|
|
385
|
+
|
|
386
|
+
return x
|
|
387
|
+
|
|
388
|
+
def remove_weight_norm(self):
|
|
389
|
+
try:
|
|
390
|
+
print("Removing weight norm...")
|
|
391
|
+
for l in self.ups:
|
|
392
|
+
for l_i in l:
|
|
393
|
+
remove_weight_norm(l_i)
|
|
394
|
+
for l in self.resblocks:
|
|
395
|
+
l.remove_weight_norm()
|
|
396
|
+
remove_weight_norm(self.conv_pre)
|
|
397
|
+
remove_weight_norm(self.conv_post)
|
|
398
|
+
except ValueError:
|
|
399
|
+
print("[INFO] Model already removed weight norm. Skipping!")
|
|
400
|
+
pass
|
|
401
|
+
|
|
402
|
+
# Additional methods for huggingface_hub support
|
|
403
|
+
def _save_pretrained(self, save_directory: Path) -> None:
|
|
404
|
+
"""Save weights and config.json from a Pytorch model to a local directory."""
|
|
405
|
+
|
|
406
|
+
model_path = save_directory / "bigvgan_generator.pt"
|
|
407
|
+
torch.save({"generator": self.state_dict()}, model_path)
|
|
408
|
+
|
|
409
|
+
config_path = save_directory / "config.json"
|
|
410
|
+
with open(config_path, "w") as config_file:
|
|
411
|
+
json.dump(self.h, config_file, indent=4)
|
|
412
|
+
|
|
413
|
+
@classmethod
|
|
414
|
+
def _from_pretrained(
|
|
415
|
+
cls,
|
|
416
|
+
*,
|
|
417
|
+
model_id: str,
|
|
418
|
+
revision: str,
|
|
419
|
+
cache_dir: str,
|
|
420
|
+
force_download: bool,
|
|
421
|
+
proxies: Optional[Dict],
|
|
422
|
+
resume_download: bool,
|
|
423
|
+
local_files_only: bool,
|
|
424
|
+
token: Union[str, bool, None],
|
|
425
|
+
map_location: str = "cpu", # Additional argument
|
|
426
|
+
strict: bool = False, # Additional argument
|
|
427
|
+
use_cuda_kernel: bool = False,
|
|
428
|
+
**model_kwargs,
|
|
429
|
+
):
|
|
430
|
+
"""Load Pytorch pretrained weights and return the loaded model."""
|
|
431
|
+
|
|
432
|
+
# Download and load hyperparameters (h) used by BigVGAN
|
|
433
|
+
if os.path.isdir(model_id):
|
|
434
|
+
print("Loading config.json from local directory")
|
|
435
|
+
config_file = os.path.join(model_id, "config.json")
|
|
436
|
+
else:
|
|
437
|
+
config_file = hf_hub_download(
|
|
438
|
+
repo_id=model_id,
|
|
439
|
+
filename="config.json",
|
|
440
|
+
revision=revision,
|
|
441
|
+
cache_dir=cache_dir,
|
|
442
|
+
force_download=force_download,
|
|
443
|
+
proxies=proxies,
|
|
444
|
+
resume_download=resume_download,
|
|
445
|
+
token=token,
|
|
446
|
+
local_files_only=local_files_only,
|
|
447
|
+
)
|
|
448
|
+
h = load_hparams_from_json(config_file)
|
|
449
|
+
|
|
450
|
+
# instantiate BigVGAN using h
|
|
451
|
+
if use_cuda_kernel:
|
|
452
|
+
print(
|
|
453
|
+
f"[WARNING] You have specified use_cuda_kernel=True during BigVGAN.from_pretrained(). Only inference is supported (training is not implemented)!"
|
|
454
|
+
)
|
|
455
|
+
print(
|
|
456
|
+
f"[WARNING] You need nvcc and ninja installed in your system that matches your PyTorch build is using to build the kernel. If not, the model will fail to initialize or generate incorrect waveform!"
|
|
457
|
+
)
|
|
458
|
+
print(
|
|
459
|
+
f"[WARNING] For detail, see the official GitHub repository: https://github.com/NVIDIA/BigVGAN?tab=readme-ov-file#using-custom-cuda-kernel-for-synthesis"
|
|
460
|
+
)
|
|
461
|
+
model = cls(h, use_cuda_kernel=use_cuda_kernel)
|
|
462
|
+
|
|
463
|
+
# Download and load pretrained generator weight
|
|
464
|
+
if os.path.isdir(model_id):
|
|
465
|
+
print("Loading weights from local directory")
|
|
466
|
+
model_file = os.path.join(model_id, "bigvgan_generator.pt")
|
|
467
|
+
else:
|
|
468
|
+
print(f"Loading weights from {model_id}")
|
|
469
|
+
model_file = hf_hub_download(
|
|
470
|
+
repo_id=model_id,
|
|
471
|
+
filename="bigvgan_generator.pt",
|
|
472
|
+
revision=revision,
|
|
473
|
+
cache_dir=cache_dir,
|
|
474
|
+
force_download=force_download,
|
|
475
|
+
proxies=proxies,
|
|
476
|
+
resume_download=resume_download,
|
|
477
|
+
token=token,
|
|
478
|
+
local_files_only=local_files_only,
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
checkpoint_dict = torch.load(model_file, map_location=map_location)
|
|
482
|
+
|
|
483
|
+
try:
|
|
484
|
+
model.load_state_dict(checkpoint_dict["generator"])
|
|
485
|
+
except RuntimeError:
|
|
486
|
+
print(
|
|
487
|
+
f"[INFO] the pretrained checkpoint does not contain weight norm. Loading the checkpoint after removing weight norm!"
|
|
488
|
+
)
|
|
489
|
+
model.remove_weight_norm()
|
|
490
|
+
model.load_state_dict(checkpoint_dict["generator"])
|
|
491
|
+
|
|
492
|
+
return model
|