xinference 1.9.1__py3-none-any.whl → 1.10.1__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 +400 -3
- xinference/client/restful/async_restful_client.py +20 -3
- xinference/client/restful/restful_client.py +20 -3
- xinference/constants.py +2 -0
- xinference/core/supervisor.py +111 -49
- xinference/core/worker.py +10 -0
- xinference/deploy/cmdline.py +15 -0
- xinference/model/audio/core.py +26 -6
- xinference/model/audio/indextts2.py +166 -0
- xinference/model/audio/kokoro.py +1 -1
- xinference/model/audio/kokoro_zh.py +124 -0
- xinference/model/audio/model_spec.json +58 -1
- xinference/model/embedding/sentence_transformers/core.py +4 -4
- xinference/model/embedding/vllm/core.py +7 -1
- xinference/model/image/model_spec.json +71 -3
- xinference/model/image/stable_diffusion/core.py +13 -4
- xinference/model/llm/__init__.py +4 -0
- xinference/model/llm/core.py +10 -0
- xinference/model/llm/llama_cpp/core.py +1 -0
- xinference/model/llm/llm_family.json +503 -21
- xinference/model/llm/llm_family.py +1 -0
- xinference/model/llm/mlx/core.py +52 -33
- xinference/model/llm/sglang/core.py +32 -55
- xinference/model/llm/tool_parsers/__init__.py +58 -0
- xinference/model/llm/tool_parsers/abstract_tool_parser.py +33 -0
- xinference/model/llm/tool_parsers/deepseek_r1_tool_parser.py +190 -0
- xinference/model/llm/tool_parsers/deepseek_v3_tool_parser.py +145 -0
- xinference/model/llm/tool_parsers/glm4_tool_parser.py +123 -0
- xinference/model/llm/tool_parsers/llama3_tool_parser.py +77 -0
- xinference/model/llm/tool_parsers/qwen_tool_parser.py +320 -0
- xinference/model/llm/transformers/core.py +1 -1
- xinference/model/llm/transformers/multimodal/qwen2_vl.py +34 -8
- xinference/model/llm/utils.py +138 -53
- xinference/model/llm/vllm/core.py +95 -78
- 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/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/types.py +105 -2
- 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.d192c4f3.js +3 -0
- xinference/ui/web/ui/build/static/js/{main.1086c759.js.LICENSE.txt → main.d192c4f3.js.LICENSE.txt} +0 -7
- xinference/ui/web/ui/build/static/js/main.d192c4f3.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/f05535160a508b2a312de546a6de234776c613db276479ea4253c0b1bdeeb7d6.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/f09ba9e11106bd59a0de10cc85c55084097729dcab575f43dfcf07375961ed87.json +1 -0
- xinference/ui/web/ui/node_modules/.cache/babel-loader/f995a2425dfb0822fd07127f66ffe9b026883bc156b402eb8bd0b83d52460a93.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.9.1.dist-info → xinference-1.10.1.dist-info}/METADATA +24 -4
- {xinference-1.9.1.dist-info → xinference-1.10.1.dist-info}/RECORD +302 -76
- 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.9.1.dist-info → xinference-1.10.1.dist-info}/WHEEL +0 -0
- {xinference-1.9.1.dist-info → xinference-1.10.1.dist-info}/entry_points.txt +0 -0
- {xinference-1.9.1.dist-info → xinference-1.10.1.dist-info}/licenses/LICENSE +0 -0
- {xinference-1.9.1.dist-info → xinference-1.10.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Copyright (c) 2023 Amphion.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
# This code is modified from https://github.com/sh-lee-prml/HierSpeechpp/blob/main/ttv_v1/styleencoder.py
|
|
7
|
+
|
|
8
|
+
from . import attentions
|
|
9
|
+
from torch import nn
|
|
10
|
+
import torch
|
|
11
|
+
from torch.nn import functional as F
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class Mish(nn.Module):
|
|
15
|
+
def __init__(self):
|
|
16
|
+
super(Mish, self).__init__()
|
|
17
|
+
|
|
18
|
+
def forward(self, x):
|
|
19
|
+
return x * torch.tanh(F.softplus(x))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class Conv1dGLU(nn.Module):
|
|
23
|
+
"""
|
|
24
|
+
Conv1d + GLU(Gated Linear Unit) with residual connection.
|
|
25
|
+
For GLU refer to https://arxiv.org/abs/1612.08083 paper.
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
def __init__(self, in_channels, out_channels, kernel_size, dropout):
|
|
29
|
+
super(Conv1dGLU, self).__init__()
|
|
30
|
+
self.out_channels = out_channels
|
|
31
|
+
self.conv1 = nn.Conv1d(
|
|
32
|
+
in_channels, 2 * out_channels, kernel_size=kernel_size, padding=2
|
|
33
|
+
)
|
|
34
|
+
self.dropout = nn.Dropout(dropout)
|
|
35
|
+
|
|
36
|
+
def forward(self, x):
|
|
37
|
+
residual = x
|
|
38
|
+
x = self.conv1(x)
|
|
39
|
+
x1, x2 = torch.split(x, split_size_or_sections=self.out_channels, dim=1)
|
|
40
|
+
x = x1 * torch.sigmoid(x2)
|
|
41
|
+
x = residual + self.dropout(x)
|
|
42
|
+
return x
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class StyleEncoder(torch.nn.Module):
|
|
46
|
+
def __init__(self, in_dim=513, hidden_dim=128, out_dim=256):
|
|
47
|
+
|
|
48
|
+
super().__init__()
|
|
49
|
+
|
|
50
|
+
self.in_dim = in_dim # Linear 513 wav2vec 2.0 1024
|
|
51
|
+
self.hidden_dim = hidden_dim
|
|
52
|
+
self.out_dim = out_dim
|
|
53
|
+
self.kernel_size = 5
|
|
54
|
+
self.n_head = 2
|
|
55
|
+
self.dropout = 0.1
|
|
56
|
+
|
|
57
|
+
self.spectral = nn.Sequential(
|
|
58
|
+
nn.Conv1d(self.in_dim, self.hidden_dim, 1),
|
|
59
|
+
Mish(),
|
|
60
|
+
nn.Dropout(self.dropout),
|
|
61
|
+
nn.Conv1d(self.hidden_dim, self.hidden_dim, 1),
|
|
62
|
+
Mish(),
|
|
63
|
+
nn.Dropout(self.dropout),
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
self.temporal = nn.Sequential(
|
|
67
|
+
Conv1dGLU(self.hidden_dim, self.hidden_dim, self.kernel_size, self.dropout),
|
|
68
|
+
Conv1dGLU(self.hidden_dim, self.hidden_dim, self.kernel_size, self.dropout),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
self.slf_attn = attentions.MultiHeadAttention(
|
|
72
|
+
self.hidden_dim,
|
|
73
|
+
self.hidden_dim,
|
|
74
|
+
self.n_head,
|
|
75
|
+
p_dropout=self.dropout,
|
|
76
|
+
proximal_bias=False,
|
|
77
|
+
proximal_init=True,
|
|
78
|
+
)
|
|
79
|
+
self.atten_drop = nn.Dropout(self.dropout)
|
|
80
|
+
self.fc = nn.Conv1d(self.hidden_dim, self.out_dim, 1)
|
|
81
|
+
|
|
82
|
+
def forward(self, x, mask=None):
|
|
83
|
+
|
|
84
|
+
# spectral
|
|
85
|
+
x = self.spectral(x) * mask
|
|
86
|
+
# temporal
|
|
87
|
+
x = self.temporal(x) * mask
|
|
88
|
+
|
|
89
|
+
# self-attention
|
|
90
|
+
attn_mask = mask.unsqueeze(2) * mask.unsqueeze(-1)
|
|
91
|
+
y = self.slf_attn(x, x, attn_mask=attn_mask)
|
|
92
|
+
x = x + self.atten_drop(y)
|
|
93
|
+
|
|
94
|
+
# fc
|
|
95
|
+
x = self.fc(x)
|
|
96
|
+
|
|
97
|
+
# temoral average pooling
|
|
98
|
+
w = self.temporal_avg_pool(x, mask=mask)
|
|
99
|
+
|
|
100
|
+
return w
|
|
101
|
+
|
|
102
|
+
def temporal_avg_pool(self, x, mask=None):
|
|
103
|
+
if mask is None:
|
|
104
|
+
out = torch.mean(x, dim=2)
|
|
105
|
+
else:
|
|
106
|
+
len_ = mask.sum(dim=2)
|
|
107
|
+
x = x.sum(dim=2)
|
|
108
|
+
|
|
109
|
+
out = torch.div(x, len_)
|
|
110
|
+
return out
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
# Copyright (c) 2023 Amphion.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
# This code is modified from https://github.com/sh-lee-prml/HierSpeechpp/blob/main/ttv_v1/modules.py
|
|
7
|
+
|
|
8
|
+
import math
|
|
9
|
+
import torch
|
|
10
|
+
from torch import nn
|
|
11
|
+
from torch.nn import functional as F
|
|
12
|
+
|
|
13
|
+
from modules.dac.model.encodec import SConv1d
|
|
14
|
+
|
|
15
|
+
from . import commons
|
|
16
|
+
|
|
17
|
+
LRELU_SLOPE = 0.1
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class LayerNorm(nn.Module):
|
|
21
|
+
def __init__(self, channels, eps=1e-5):
|
|
22
|
+
super().__init__()
|
|
23
|
+
self.channels = channels
|
|
24
|
+
self.eps = eps
|
|
25
|
+
|
|
26
|
+
self.gamma = nn.Parameter(torch.ones(channels))
|
|
27
|
+
self.beta = nn.Parameter(torch.zeros(channels))
|
|
28
|
+
|
|
29
|
+
def forward(self, x):
|
|
30
|
+
x = x.transpose(1, -1)
|
|
31
|
+
x = F.layer_norm(x, (self.channels,), self.gamma, self.beta, self.eps)
|
|
32
|
+
return x.transpose(1, -1)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class ConvReluNorm(nn.Module):
|
|
36
|
+
def __init__(
|
|
37
|
+
self,
|
|
38
|
+
in_channels,
|
|
39
|
+
hidden_channels,
|
|
40
|
+
out_channels,
|
|
41
|
+
kernel_size,
|
|
42
|
+
n_layers,
|
|
43
|
+
p_dropout,
|
|
44
|
+
):
|
|
45
|
+
super().__init__()
|
|
46
|
+
self.in_channels = in_channels
|
|
47
|
+
self.hidden_channels = hidden_channels
|
|
48
|
+
self.out_channels = out_channels
|
|
49
|
+
self.kernel_size = kernel_size
|
|
50
|
+
self.n_layers = n_layers
|
|
51
|
+
self.p_dropout = p_dropout
|
|
52
|
+
assert n_layers > 1, "Number of layers should be larger than 0."
|
|
53
|
+
|
|
54
|
+
self.conv_layers = nn.ModuleList()
|
|
55
|
+
self.norm_layers = nn.ModuleList()
|
|
56
|
+
self.conv_layers.append(
|
|
57
|
+
nn.Conv1d(
|
|
58
|
+
in_channels, hidden_channels, kernel_size, padding=kernel_size // 2
|
|
59
|
+
)
|
|
60
|
+
)
|
|
61
|
+
self.norm_layers.append(LayerNorm(hidden_channels))
|
|
62
|
+
self.relu_drop = nn.Sequential(nn.ReLU(), nn.Dropout(p_dropout))
|
|
63
|
+
for _ in range(n_layers - 1):
|
|
64
|
+
self.conv_layers.append(
|
|
65
|
+
nn.Conv1d(
|
|
66
|
+
hidden_channels,
|
|
67
|
+
hidden_channels,
|
|
68
|
+
kernel_size,
|
|
69
|
+
padding=kernel_size // 2,
|
|
70
|
+
)
|
|
71
|
+
)
|
|
72
|
+
self.norm_layers.append(LayerNorm(hidden_channels))
|
|
73
|
+
self.proj = nn.Conv1d(hidden_channels, out_channels, 1)
|
|
74
|
+
self.proj.weight.data.zero_()
|
|
75
|
+
self.proj.bias.data.zero_()
|
|
76
|
+
|
|
77
|
+
def forward(self, x, x_mask):
|
|
78
|
+
x_org = x
|
|
79
|
+
for i in range(self.n_layers):
|
|
80
|
+
x = self.conv_layers[i](x * x_mask)
|
|
81
|
+
x = self.norm_layers[i](x)
|
|
82
|
+
x = self.relu_drop(x)
|
|
83
|
+
x = x_org + self.proj(x)
|
|
84
|
+
return x * x_mask
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class DDSConv(nn.Module):
|
|
88
|
+
"""
|
|
89
|
+
Dialted and Depth-Separable Convolution
|
|
90
|
+
"""
|
|
91
|
+
|
|
92
|
+
def __init__(self, channels, kernel_size, n_layers, p_dropout=0.0):
|
|
93
|
+
super().__init__()
|
|
94
|
+
self.channels = channels
|
|
95
|
+
self.kernel_size = kernel_size
|
|
96
|
+
self.n_layers = n_layers
|
|
97
|
+
self.p_dropout = p_dropout
|
|
98
|
+
|
|
99
|
+
self.drop = nn.Dropout(p_dropout)
|
|
100
|
+
self.convs_sep = nn.ModuleList()
|
|
101
|
+
self.convs_1x1 = nn.ModuleList()
|
|
102
|
+
self.norms_1 = nn.ModuleList()
|
|
103
|
+
self.norms_2 = nn.ModuleList()
|
|
104
|
+
for i in range(n_layers):
|
|
105
|
+
dilation = kernel_size**i
|
|
106
|
+
padding = (kernel_size * dilation - dilation) // 2
|
|
107
|
+
self.convs_sep.append(
|
|
108
|
+
nn.Conv1d(
|
|
109
|
+
channels,
|
|
110
|
+
channels,
|
|
111
|
+
kernel_size,
|
|
112
|
+
groups=channels,
|
|
113
|
+
dilation=dilation,
|
|
114
|
+
padding=padding,
|
|
115
|
+
)
|
|
116
|
+
)
|
|
117
|
+
self.convs_1x1.append(nn.Conv1d(channels, channels, 1))
|
|
118
|
+
self.norms_1.append(LayerNorm(channels))
|
|
119
|
+
self.norms_2.append(LayerNorm(channels))
|
|
120
|
+
|
|
121
|
+
def forward(self, x, x_mask, g=None):
|
|
122
|
+
if g is not None:
|
|
123
|
+
x = x + g
|
|
124
|
+
for i in range(self.n_layers):
|
|
125
|
+
y = self.convs_sep[i](x * x_mask)
|
|
126
|
+
y = self.norms_1[i](y)
|
|
127
|
+
y = F.gelu(y)
|
|
128
|
+
y = self.convs_1x1[i](y)
|
|
129
|
+
y = self.norms_2[i](y)
|
|
130
|
+
y = F.gelu(y)
|
|
131
|
+
y = self.drop(y)
|
|
132
|
+
x = x + y
|
|
133
|
+
return x * x_mask
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class WN(torch.nn.Module):
|
|
137
|
+
def __init__(
|
|
138
|
+
self,
|
|
139
|
+
hidden_channels,
|
|
140
|
+
kernel_size,
|
|
141
|
+
dilation_rate,
|
|
142
|
+
n_layers,
|
|
143
|
+
gin_channels=0,
|
|
144
|
+
p_dropout=0,
|
|
145
|
+
causal=False,
|
|
146
|
+
):
|
|
147
|
+
super(WN, self).__init__()
|
|
148
|
+
conv1d_type = SConv1d
|
|
149
|
+
assert kernel_size % 2 == 1
|
|
150
|
+
self.hidden_channels = hidden_channels
|
|
151
|
+
self.kernel_size = (kernel_size,)
|
|
152
|
+
self.dilation_rate = dilation_rate
|
|
153
|
+
self.n_layers = n_layers
|
|
154
|
+
self.gin_channels = gin_channels
|
|
155
|
+
self.p_dropout = p_dropout
|
|
156
|
+
|
|
157
|
+
self.in_layers = torch.nn.ModuleList()
|
|
158
|
+
self.res_skip_layers = torch.nn.ModuleList()
|
|
159
|
+
self.drop = nn.Dropout(p_dropout)
|
|
160
|
+
|
|
161
|
+
if gin_channels != 0:
|
|
162
|
+
self.cond_layer = conv1d_type(
|
|
163
|
+
gin_channels, 2 * hidden_channels * n_layers, 1, norm="weight_norm"
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
for i in range(n_layers):
|
|
167
|
+
dilation = dilation_rate**i
|
|
168
|
+
padding = int((kernel_size * dilation - dilation) / 2)
|
|
169
|
+
in_layer = conv1d_type(
|
|
170
|
+
hidden_channels,
|
|
171
|
+
2 * hidden_channels,
|
|
172
|
+
kernel_size,
|
|
173
|
+
dilation=dilation,
|
|
174
|
+
padding=padding,
|
|
175
|
+
norm="weight_norm",
|
|
176
|
+
causal=causal,
|
|
177
|
+
)
|
|
178
|
+
self.in_layers.append(in_layer)
|
|
179
|
+
|
|
180
|
+
# last one is not necessary
|
|
181
|
+
if i < n_layers - 1:
|
|
182
|
+
res_skip_channels = 2 * hidden_channels
|
|
183
|
+
else:
|
|
184
|
+
res_skip_channels = hidden_channels
|
|
185
|
+
|
|
186
|
+
res_skip_layer = conv1d_type(
|
|
187
|
+
hidden_channels, res_skip_channels, 1, norm="weight_norm", causal=causal
|
|
188
|
+
)
|
|
189
|
+
self.res_skip_layers.append(res_skip_layer)
|
|
190
|
+
|
|
191
|
+
def forward(self, x, x_mask, g=None, **kwargs):
|
|
192
|
+
output = torch.zeros_like(x)
|
|
193
|
+
n_channels_tensor = torch.IntTensor([self.hidden_channels])
|
|
194
|
+
|
|
195
|
+
if g is not None:
|
|
196
|
+
g = self.cond_layer(g)
|
|
197
|
+
|
|
198
|
+
for i in range(self.n_layers):
|
|
199
|
+
x_in = self.in_layers[i](x)
|
|
200
|
+
if g is not None:
|
|
201
|
+
cond_offset = i * 2 * self.hidden_channels
|
|
202
|
+
g_l = g[:, cond_offset : cond_offset + 2 * self.hidden_channels, :]
|
|
203
|
+
else:
|
|
204
|
+
g_l = torch.zeros_like(x_in)
|
|
205
|
+
|
|
206
|
+
acts = commons.fused_add_tanh_sigmoid_multiply(x_in, g_l, n_channels_tensor)
|
|
207
|
+
acts = self.drop(acts)
|
|
208
|
+
|
|
209
|
+
res_skip_acts = self.res_skip_layers[i](acts)
|
|
210
|
+
if i < self.n_layers - 1:
|
|
211
|
+
res_acts = res_skip_acts[:, : self.hidden_channels, :]
|
|
212
|
+
x = (x + res_acts) * x_mask
|
|
213
|
+
output = output + res_skip_acts[:, self.hidden_channels :, :]
|
|
214
|
+
else:
|
|
215
|
+
output = output + res_skip_acts
|
|
216
|
+
return output * x_mask
|
|
217
|
+
|
|
218
|
+
def remove_weight_norm(self):
|
|
219
|
+
if self.gin_channels != 0:
|
|
220
|
+
torch.nn.utils.remove_weight_norm(self.cond_layer)
|
|
221
|
+
for l in self.in_layers:
|
|
222
|
+
torch.nn.utils.remove_weight_norm(l)
|
|
223
|
+
for l in self.res_skip_layers:
|
|
224
|
+
torch.nn.utils.remove_weight_norm(l)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Copyright (c) 2023 Amphion.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
import os, sys
|
|
7
|
+
import os.path as osp
|
|
8
|
+
import numpy as np
|
|
9
|
+
import torch
|
|
10
|
+
from torch import nn
|
|
11
|
+
from torch.optim import Optimizer
|
|
12
|
+
from functools import reduce
|
|
13
|
+
from torch.optim import AdamW
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class MultiOptimizer:
|
|
17
|
+
def __init__(self, optimizers={}, schedulers={}):
|
|
18
|
+
self.optimizers = optimizers
|
|
19
|
+
self.schedulers = schedulers
|
|
20
|
+
self.keys = list(optimizers.keys())
|
|
21
|
+
self.param_groups = reduce(
|
|
22
|
+
lambda x, y: x + y, [v.param_groups for v in self.optimizers.values()]
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
def state_dict(self):
|
|
26
|
+
state_dicts = [(key, self.optimizers[key].state_dict()) for key in self.keys]
|
|
27
|
+
return state_dicts
|
|
28
|
+
|
|
29
|
+
def scheduler_state_dict(self):
|
|
30
|
+
state_dicts = [(key, self.schedulers[key].state_dict()) for key in self.keys]
|
|
31
|
+
return state_dicts
|
|
32
|
+
|
|
33
|
+
def load_state_dict(self, state_dict):
|
|
34
|
+
for key, val in state_dict:
|
|
35
|
+
try:
|
|
36
|
+
self.optimizers[key].load_state_dict(val)
|
|
37
|
+
except:
|
|
38
|
+
print("Unloaded %s" % key)
|
|
39
|
+
|
|
40
|
+
def load_scheduler_state_dict(self, state_dict):
|
|
41
|
+
for key, val in state_dict:
|
|
42
|
+
try:
|
|
43
|
+
self.schedulers[key].load_state_dict(val)
|
|
44
|
+
except:
|
|
45
|
+
print("Unloaded %s" % key)
|
|
46
|
+
|
|
47
|
+
def step(self, key=None, scaler=None):
|
|
48
|
+
keys = [key] if key is not None else self.keys
|
|
49
|
+
_ = [self._step(key, scaler) for key in keys]
|
|
50
|
+
|
|
51
|
+
def _step(self, key, scaler=None):
|
|
52
|
+
if scaler is not None:
|
|
53
|
+
scaler.step(self.optimizers[key])
|
|
54
|
+
scaler.update()
|
|
55
|
+
else:
|
|
56
|
+
self.optimizers[key].step()
|
|
57
|
+
|
|
58
|
+
def zero_grad(self, key=None):
|
|
59
|
+
if key is not None:
|
|
60
|
+
self.optimizers[key].zero_grad()
|
|
61
|
+
else:
|
|
62
|
+
_ = [self.optimizers[key].zero_grad() for key in self.keys]
|
|
63
|
+
|
|
64
|
+
def scheduler(self, *args, key=None):
|
|
65
|
+
if key is not None:
|
|
66
|
+
self.schedulers[key].step(*args)
|
|
67
|
+
else:
|
|
68
|
+
_ = [self.schedulers[key].step_batch(*args) for key in self.keys]
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def define_scheduler(optimizer, params):
|
|
72
|
+
scheduler = torch.optim.lr_scheduler.ExponentialLR(optimizer, gamma=params["gamma"])
|
|
73
|
+
|
|
74
|
+
return scheduler
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def build_optimizer(model_dict, scheduler_params_dict, lr, type="AdamW"):
|
|
78
|
+
optim = {}
|
|
79
|
+
for key, model in model_dict.items():
|
|
80
|
+
model_parameters = model.parameters()
|
|
81
|
+
parameters_names = []
|
|
82
|
+
parameters_names.append(
|
|
83
|
+
[name_param_pair[0] for name_param_pair in model.named_parameters()]
|
|
84
|
+
)
|
|
85
|
+
if type == "AdamW":
|
|
86
|
+
optim[key] = AdamW(
|
|
87
|
+
model_parameters,
|
|
88
|
+
lr=lr,
|
|
89
|
+
betas=(0.9, 0.98),
|
|
90
|
+
eps=1e-9,
|
|
91
|
+
weight_decay=0.1,
|
|
92
|
+
)
|
|
93
|
+
else:
|
|
94
|
+
raise ValueError("Unknown optimizer type: %s" % type)
|
|
95
|
+
|
|
96
|
+
schedulers = dict(
|
|
97
|
+
[
|
|
98
|
+
(key, torch.optim.lr_scheduler.ExponentialLR(opt, gamma=0.999996))
|
|
99
|
+
for key, opt in optim.items()
|
|
100
|
+
]
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
multi_optim = MultiOptimizer(optim, schedulers)
|
|
104
|
+
return multi_optim
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Copyright (c) 2024 Amphion.
|
|
2
|
+
#
|
|
3
|
+
# This source code is licensed under the MIT license found in the
|
|
4
|
+
# LICENSE file in the root directory of this source tree.
|
|
5
|
+
|
|
6
|
+
from concurrent.futures import ALL_COMPLETED
|
|
7
|
+
import numpy as np
|
|
8
|
+
import torch
|
|
9
|
+
import torch.nn as nn
|
|
10
|
+
|
|
11
|
+
from torch.nn import functional as F
|
|
12
|
+
from einops import rearrange, repeat
|
|
13
|
+
|
|
14
|
+
from indextts.utils.maskgct.models.codec.amphion_codec.quantize import ResidualVQ
|
|
15
|
+
from indextts.utils.maskgct.models.codec.kmeans.vocos import VocosBackbone
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def init_weights(m):
|
|
19
|
+
if isinstance(m, nn.Conv1d):
|
|
20
|
+
nn.init.trunc_normal_(m.weight, std=0.02)
|
|
21
|
+
nn.init.constant_(m.bias, 0)
|
|
22
|
+
if isinstance(m, nn.Linear):
|
|
23
|
+
nn.init.trunc_normal_(m.weight, std=0.02)
|
|
24
|
+
nn.init.constant_(m.bias, 0)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def compute_codebook_perplexity(indices, codebook_size):
|
|
28
|
+
indices = indices.flatten()
|
|
29
|
+
prob = torch.bincount(indices, minlength=codebook_size).float() / indices.size(0)
|
|
30
|
+
perp = torch.exp(-torch.sum(prob * torch.log(prob + 1e-10)))
|
|
31
|
+
return perp
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class RepCodec(nn.Module):
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
codebook_size=8192,
|
|
38
|
+
hidden_size=1024,
|
|
39
|
+
codebook_dim=8,
|
|
40
|
+
vocos_dim=384,
|
|
41
|
+
vocos_intermediate_dim=2048,
|
|
42
|
+
vocos_num_layers=12,
|
|
43
|
+
num_quantizers=1,
|
|
44
|
+
downsample_scale=1,
|
|
45
|
+
cfg=None,
|
|
46
|
+
):
|
|
47
|
+
super().__init__()
|
|
48
|
+
codebook_size = (
|
|
49
|
+
cfg.codebook_size
|
|
50
|
+
if cfg is not None and hasattr(cfg, "codebook_size")
|
|
51
|
+
else codebook_size
|
|
52
|
+
)
|
|
53
|
+
codebook_dim = (
|
|
54
|
+
cfg.codebook_dim
|
|
55
|
+
if cfg is not None and hasattr(cfg, "codebook_dim")
|
|
56
|
+
else codebook_dim
|
|
57
|
+
)
|
|
58
|
+
hidden_size = (
|
|
59
|
+
cfg.hidden_size
|
|
60
|
+
if cfg is not None and hasattr(cfg, "hidden_size")
|
|
61
|
+
else hidden_size
|
|
62
|
+
)
|
|
63
|
+
vocos_dim = (
|
|
64
|
+
cfg.vocos_dim
|
|
65
|
+
if cfg is not None and hasattr(cfg, "vocos_dim")
|
|
66
|
+
else vocos_dim
|
|
67
|
+
)
|
|
68
|
+
vocos_intermediate_dim = (
|
|
69
|
+
cfg.vocos_intermediate_dim
|
|
70
|
+
if cfg is not None and hasattr(cfg, "vocos_dim")
|
|
71
|
+
else vocos_intermediate_dim
|
|
72
|
+
)
|
|
73
|
+
vocos_num_layers = (
|
|
74
|
+
cfg.vocos_num_layers
|
|
75
|
+
if cfg is not None and hasattr(cfg, "vocos_dim")
|
|
76
|
+
else vocos_num_layers
|
|
77
|
+
)
|
|
78
|
+
num_quantizers = (
|
|
79
|
+
cfg.num_quantizers
|
|
80
|
+
if cfg is not None and hasattr(cfg, "num_quantizers")
|
|
81
|
+
else num_quantizers
|
|
82
|
+
)
|
|
83
|
+
downsample_scale = (
|
|
84
|
+
cfg.downsample_scale
|
|
85
|
+
if cfg is not None and hasattr(cfg, "downsample_scale")
|
|
86
|
+
else downsample_scale
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
self.codebook_size = codebook_size
|
|
90
|
+
self.codebook_dim = codebook_dim
|
|
91
|
+
self.hidden_size = hidden_size
|
|
92
|
+
self.vocos_dim = vocos_dim
|
|
93
|
+
self.vocos_intermediate_dim = vocos_intermediate_dim
|
|
94
|
+
self.vocos_num_layers = vocos_num_layers
|
|
95
|
+
self.num_quantizers = num_quantizers
|
|
96
|
+
self.downsample_scale = downsample_scale
|
|
97
|
+
|
|
98
|
+
if self.downsample_scale != None and self.downsample_scale > 1:
|
|
99
|
+
self.down = nn.Conv1d(
|
|
100
|
+
self.hidden_size, self.hidden_size, kernel_size=3, stride=2, padding=1
|
|
101
|
+
)
|
|
102
|
+
self.up = nn.Conv1d(
|
|
103
|
+
self.hidden_size, self.hidden_size, kernel_size=3, stride=1, padding=1
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
self.encoder = nn.Sequential(
|
|
107
|
+
VocosBackbone(
|
|
108
|
+
input_channels=self.hidden_size,
|
|
109
|
+
dim=self.vocos_dim,
|
|
110
|
+
intermediate_dim=self.vocos_intermediate_dim,
|
|
111
|
+
num_layers=self.vocos_num_layers,
|
|
112
|
+
adanorm_num_embeddings=None,
|
|
113
|
+
),
|
|
114
|
+
nn.Linear(self.vocos_dim, self.hidden_size),
|
|
115
|
+
)
|
|
116
|
+
self.decoder = nn.Sequential(
|
|
117
|
+
VocosBackbone(
|
|
118
|
+
input_channels=self.hidden_size,
|
|
119
|
+
dim=self.vocos_dim,
|
|
120
|
+
intermediate_dim=self.vocos_intermediate_dim,
|
|
121
|
+
num_layers=self.vocos_num_layers,
|
|
122
|
+
adanorm_num_embeddings=None,
|
|
123
|
+
),
|
|
124
|
+
nn.Linear(self.vocos_dim, self.hidden_size),
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
self.quantizer = ResidualVQ(
|
|
128
|
+
input_dim=hidden_size,
|
|
129
|
+
num_quantizers=num_quantizers,
|
|
130
|
+
codebook_size=codebook_size,
|
|
131
|
+
codebook_dim=codebook_dim,
|
|
132
|
+
quantizer_type="fvq",
|
|
133
|
+
quantizer_dropout=0.0,
|
|
134
|
+
commitment=0.15,
|
|
135
|
+
codebook_loss_weight=1.0,
|
|
136
|
+
use_l2_normlize=True,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
self.reset_parameters()
|
|
140
|
+
|
|
141
|
+
def forward(self, x):
|
|
142
|
+
|
|
143
|
+
# downsample
|
|
144
|
+
if self.downsample_scale != None and self.downsample_scale > 1:
|
|
145
|
+
x = x.transpose(1, 2)
|
|
146
|
+
x = self.down(x)
|
|
147
|
+
x = F.gelu(x)
|
|
148
|
+
x = x.transpose(1, 2)
|
|
149
|
+
|
|
150
|
+
# encoder
|
|
151
|
+
x = self.encoder(x.transpose(1, 2)).transpose(1, 2)
|
|
152
|
+
|
|
153
|
+
# vq
|
|
154
|
+
(
|
|
155
|
+
quantized_out,
|
|
156
|
+
all_indices,
|
|
157
|
+
all_commit_losses,
|
|
158
|
+
all_codebook_losses,
|
|
159
|
+
_,
|
|
160
|
+
) = self.quantizer(x)
|
|
161
|
+
|
|
162
|
+
# decoder
|
|
163
|
+
x = self.decoder(quantized_out)
|
|
164
|
+
|
|
165
|
+
# up
|
|
166
|
+
if self.downsample_scale != None and self.downsample_scale > 1:
|
|
167
|
+
x = x.transpose(1, 2)
|
|
168
|
+
x = F.interpolate(x, scale_factor=2, mode="nearest")
|
|
169
|
+
x_rec = self.up(x).transpose(1, 2)
|
|
170
|
+
|
|
171
|
+
codebook_loss = (all_codebook_losses + all_commit_losses).mean()
|
|
172
|
+
all_indices = all_indices
|
|
173
|
+
|
|
174
|
+
return x_rec, codebook_loss, all_indices
|
|
175
|
+
|
|
176
|
+
def quantize(self, x):
|
|
177
|
+
|
|
178
|
+
if self.downsample_scale != None and self.downsample_scale > 1:
|
|
179
|
+
x = x.transpose(1, 2)
|
|
180
|
+
x = self.down(x)
|
|
181
|
+
x = F.gelu(x)
|
|
182
|
+
x = x.transpose(1, 2)
|
|
183
|
+
|
|
184
|
+
x = self.encoder(x.transpose(1, 2)).transpose(1, 2)
|
|
185
|
+
|
|
186
|
+
(
|
|
187
|
+
quantized_out,
|
|
188
|
+
all_indices,
|
|
189
|
+
all_commit_losses,
|
|
190
|
+
all_codebook_losses,
|
|
191
|
+
_,
|
|
192
|
+
) = self.quantizer(x)
|
|
193
|
+
|
|
194
|
+
if all_indices.shape[0] == 1:
|
|
195
|
+
return all_indices.squeeze(0), quantized_out.transpose(1, 2)
|
|
196
|
+
return all_indices, quantized_out.transpose(1, 2)
|
|
197
|
+
|
|
198
|
+
def reset_parameters(self):
|
|
199
|
+
self.apply(init_weights)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
if __name__ == "__main__":
|
|
203
|
+
repcodec = RepCodec(vocos_dim=1024, downsample_scale=2)
|
|
204
|
+
print(repcodec)
|
|
205
|
+
print(sum(p.numel() for p in repcodec.parameters()) / 1e6)
|
|
206
|
+
x = torch.randn(5, 10, 1024)
|
|
207
|
+
x_rec, codebook_loss, all_indices = repcodec(x)
|
|
208
|
+
print(x_rec.shape, codebook_loss, all_indices.shape)
|
|
209
|
+
vq_id, emb = repcodec.quantize(x)
|
|
210
|
+
print(vq_id.shape, emb.shape)
|