xinference 1.0.1__py3-none-any.whl → 1.2.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/_compat.py +2 -0
- xinference/_version.py +3 -3
- xinference/api/restful_api.py +77 -71
- xinference/core/chat_interface.py +6 -1
- xinference/core/model.py +79 -19
- xinference/core/supervisor.py +172 -10
- xinference/core/utils.py +12 -8
- xinference/core/worker.py +102 -4
- xinference/deploy/cmdline.py +3 -1
- xinference/deploy/test/test_cmdline.py +56 -0
- xinference/isolation.py +24 -0
- xinference/model/audio/core.py +16 -0
- xinference/model/audio/cosyvoice.py +39 -6
- xinference/model/audio/f5tts.py +200 -0
- xinference/model/audio/f5tts_mlx.py +260 -0
- xinference/model/audio/fish_speech.py +36 -111
- xinference/model/audio/melotts.py +110 -0
- xinference/model/audio/model_spec.json +99 -3
- xinference/model/audio/model_spec_modelscope.json +27 -0
- xinference/model/audio/utils.py +32 -0
- xinference/model/audio/whisper.py +35 -10
- xinference/model/embedding/core.py +203 -142
- xinference/model/embedding/model_spec.json +7 -0
- xinference/model/embedding/model_spec_modelscope.json +8 -0
- xinference/model/image/core.py +69 -1
- xinference/model/image/model_spec.json +145 -4
- xinference/model/image/model_spec_modelscope.json +150 -4
- xinference/model/image/stable_diffusion/core.py +45 -13
- xinference/model/llm/__init__.py +4 -2
- xinference/model/llm/llm_family.json +536 -53
- xinference/model/llm/llm_family.py +15 -36
- xinference/model/llm/llm_family_modelscope.json +454 -20
- xinference/model/llm/memory.py +1 -1
- xinference/model/llm/mlx/core.py +248 -52
- xinference/model/llm/sglang/core.py +1 -0
- xinference/model/llm/transformers/chatglm.py +9 -5
- xinference/model/llm/transformers/cogagent.py +272 -0
- xinference/model/llm/transformers/core.py +2 -0
- xinference/model/llm/transformers/qwen2_vl.py +12 -1
- xinference/model/llm/transformers/utils.py +16 -8
- xinference/model/llm/utils.py +36 -4
- xinference/model/llm/vllm/core.py +53 -10
- xinference/model/llm/vllm/xavier/__init__.py +13 -0
- xinference/model/llm/vllm/xavier/allocator.py +74 -0
- xinference/model/llm/vllm/xavier/block.py +111 -0
- xinference/model/llm/vllm/xavier/block_manager.py +71 -0
- xinference/model/llm/vllm/xavier/block_tracker.py +129 -0
- xinference/model/llm/vllm/xavier/collective.py +74 -0
- xinference/model/llm/vllm/xavier/collective_manager.py +147 -0
- xinference/model/llm/vllm/xavier/engine.py +247 -0
- xinference/model/llm/vllm/xavier/executor.py +134 -0
- xinference/model/llm/vllm/xavier/scheduler.py +438 -0
- xinference/model/llm/vllm/xavier/test/__init__.py +13 -0
- xinference/model/llm/vllm/xavier/test/test_xavier.py +147 -0
- xinference/model/llm/vllm/xavier/transfer.py +319 -0
- xinference/model/video/diffusers.py +14 -0
- xinference/model/video/model_spec.json +15 -0
- xinference/model/video/model_spec_modelscope.json +16 -0
- xinference/thirdparty/cosyvoice/bin/average_model.py +92 -0
- xinference/thirdparty/cosyvoice/bin/export_jit.py +12 -2
- xinference/thirdparty/cosyvoice/bin/export_onnx.py +112 -0
- xinference/thirdparty/cosyvoice/bin/export_trt.sh +9 -0
- xinference/thirdparty/cosyvoice/bin/inference.py +5 -7
- xinference/thirdparty/cosyvoice/bin/spk2info.pt +0 -0
- xinference/thirdparty/cosyvoice/bin/train.py +42 -8
- xinference/thirdparty/cosyvoice/cli/cosyvoice.py +96 -25
- xinference/thirdparty/cosyvoice/cli/frontend.py +77 -30
- xinference/thirdparty/cosyvoice/cli/model.py +330 -80
- xinference/thirdparty/cosyvoice/dataset/dataset.py +6 -2
- xinference/thirdparty/cosyvoice/dataset/processor.py +76 -14
- xinference/thirdparty/cosyvoice/flow/decoder.py +92 -13
- xinference/thirdparty/cosyvoice/flow/flow.py +99 -9
- xinference/thirdparty/cosyvoice/flow/flow_matching.py +110 -13
- xinference/thirdparty/cosyvoice/flow/length_regulator.py +5 -4
- xinference/thirdparty/cosyvoice/hifigan/discriminator.py +140 -0
- xinference/thirdparty/cosyvoice/hifigan/generator.py +58 -42
- xinference/thirdparty/cosyvoice/hifigan/hifigan.py +67 -0
- xinference/thirdparty/cosyvoice/llm/llm.py +139 -6
- xinference/thirdparty/cosyvoice/tokenizer/assets/multilingual_zh_ja_yue_char_del.tiktoken +58836 -0
- xinference/thirdparty/cosyvoice/tokenizer/tokenizer.py +279 -0
- xinference/thirdparty/cosyvoice/transformer/embedding.py +2 -2
- xinference/thirdparty/cosyvoice/transformer/encoder_layer.py +7 -7
- xinference/thirdparty/cosyvoice/transformer/upsample_encoder.py +318 -0
- xinference/thirdparty/cosyvoice/utils/common.py +28 -1
- xinference/thirdparty/cosyvoice/utils/executor.py +69 -7
- xinference/thirdparty/cosyvoice/utils/file_utils.py +2 -12
- xinference/thirdparty/cosyvoice/utils/frontend_utils.py +9 -5
- xinference/thirdparty/cosyvoice/utils/losses.py +20 -0
- xinference/thirdparty/cosyvoice/utils/scheduler.py +1 -2
- xinference/thirdparty/cosyvoice/utils/train_utils.py +101 -45
- xinference/thirdparty/f5_tts/api.py +166 -0
- xinference/thirdparty/f5_tts/configs/E2TTS_Base_train.yaml +44 -0
- xinference/thirdparty/f5_tts/configs/E2TTS_Small_train.yaml +44 -0
- xinference/thirdparty/f5_tts/configs/F5TTS_Base_train.yaml +46 -0
- xinference/thirdparty/f5_tts/configs/F5TTS_Small_train.yaml +46 -0
- xinference/thirdparty/f5_tts/eval/README.md +49 -0
- xinference/thirdparty/f5_tts/eval/ecapa_tdnn.py +330 -0
- xinference/thirdparty/f5_tts/eval/eval_infer_batch.py +207 -0
- xinference/thirdparty/f5_tts/eval/eval_infer_batch.sh +13 -0
- xinference/thirdparty/f5_tts/eval/eval_librispeech_test_clean.py +84 -0
- xinference/thirdparty/f5_tts/eval/eval_seedtts_testset.py +84 -0
- xinference/thirdparty/f5_tts/eval/utils_eval.py +405 -0
- xinference/thirdparty/f5_tts/infer/README.md +191 -0
- xinference/thirdparty/f5_tts/infer/SHARED.md +74 -0
- xinference/thirdparty/f5_tts/infer/examples/basic/basic.toml +11 -0
- xinference/thirdparty/f5_tts/infer/examples/basic/basic_ref_en.wav +0 -0
- xinference/thirdparty/f5_tts/infer/examples/basic/basic_ref_zh.wav +0 -0
- xinference/thirdparty/f5_tts/infer/examples/multi/country.flac +0 -0
- xinference/thirdparty/f5_tts/infer/examples/multi/main.flac +0 -0
- xinference/thirdparty/f5_tts/infer/examples/multi/story.toml +19 -0
- xinference/thirdparty/f5_tts/infer/examples/multi/story.txt +1 -0
- xinference/thirdparty/f5_tts/infer/examples/multi/town.flac +0 -0
- xinference/thirdparty/f5_tts/infer/examples/vocab.txt +2545 -0
- xinference/thirdparty/f5_tts/infer/infer_cli.py +226 -0
- xinference/thirdparty/f5_tts/infer/infer_gradio.py +851 -0
- xinference/thirdparty/f5_tts/infer/speech_edit.py +193 -0
- xinference/thirdparty/f5_tts/infer/utils_infer.py +538 -0
- xinference/thirdparty/f5_tts/model/__init__.py +10 -0
- xinference/thirdparty/f5_tts/model/backbones/README.md +20 -0
- xinference/thirdparty/f5_tts/model/backbones/dit.py +163 -0
- xinference/thirdparty/f5_tts/model/backbones/mmdit.py +146 -0
- xinference/thirdparty/f5_tts/model/backbones/unett.py +219 -0
- xinference/thirdparty/f5_tts/model/cfm.py +285 -0
- xinference/thirdparty/f5_tts/model/dataset.py +319 -0
- xinference/thirdparty/f5_tts/model/modules.py +658 -0
- xinference/thirdparty/f5_tts/model/trainer.py +366 -0
- xinference/thirdparty/f5_tts/model/utils.py +185 -0
- xinference/thirdparty/f5_tts/scripts/count_max_epoch.py +33 -0
- xinference/thirdparty/f5_tts/scripts/count_params_gflops.py +39 -0
- xinference/thirdparty/f5_tts/socket_server.py +159 -0
- xinference/thirdparty/f5_tts/train/README.md +77 -0
- xinference/thirdparty/f5_tts/train/datasets/prepare_csv_wavs.py +139 -0
- xinference/thirdparty/f5_tts/train/datasets/prepare_emilia.py +230 -0
- xinference/thirdparty/f5_tts/train/datasets/prepare_libritts.py +92 -0
- xinference/thirdparty/f5_tts/train/datasets/prepare_ljspeech.py +65 -0
- xinference/thirdparty/f5_tts/train/datasets/prepare_wenetspeech4tts.py +125 -0
- xinference/thirdparty/f5_tts/train/finetune_cli.py +174 -0
- xinference/thirdparty/f5_tts/train/finetune_gradio.py +1846 -0
- xinference/thirdparty/f5_tts/train/train.py +75 -0
- xinference/thirdparty/fish_speech/fish_speech/conversation.py +94 -83
- xinference/thirdparty/fish_speech/fish_speech/models/text2semantic/llama.py +63 -20
- xinference/thirdparty/fish_speech/fish_speech/text/clean.py +1 -26
- xinference/thirdparty/fish_speech/fish_speech/text/spliter.py +1 -1
- xinference/thirdparty/fish_speech/fish_speech/tokenizer.py +152 -0
- xinference/thirdparty/fish_speech/fish_speech/train.py +2 -2
- xinference/thirdparty/fish_speech/fish_speech/webui/manage.py +1 -1
- xinference/thirdparty/fish_speech/tools/{post_api.py → api_client.py} +7 -13
- xinference/thirdparty/fish_speech/tools/api_server.py +98 -0
- xinference/thirdparty/fish_speech/tools/download_models.py +5 -5
- xinference/thirdparty/fish_speech/tools/fish_e2e.py +2 -2
- xinference/thirdparty/fish_speech/tools/inference_engine/__init__.py +192 -0
- xinference/thirdparty/fish_speech/tools/inference_engine/reference_loader.py +125 -0
- xinference/thirdparty/fish_speech/tools/inference_engine/utils.py +39 -0
- xinference/thirdparty/fish_speech/tools/inference_engine/vq_manager.py +57 -0
- xinference/thirdparty/fish_speech/tools/llama/eval_in_context.py +2 -2
- xinference/thirdparty/fish_speech/tools/llama/generate.py +117 -89
- xinference/thirdparty/fish_speech/tools/run_webui.py +104 -0
- xinference/thirdparty/fish_speech/tools/schema.py +11 -28
- xinference/thirdparty/fish_speech/tools/server/agent/__init__.py +57 -0
- xinference/thirdparty/fish_speech/tools/server/agent/generate.py +119 -0
- xinference/thirdparty/fish_speech/tools/server/agent/generation_utils.py +122 -0
- xinference/thirdparty/fish_speech/tools/server/agent/pre_generation_utils.py +72 -0
- xinference/thirdparty/fish_speech/tools/server/api_utils.py +75 -0
- xinference/thirdparty/fish_speech/tools/server/exception_handler.py +27 -0
- xinference/thirdparty/fish_speech/tools/server/inference.py +45 -0
- xinference/thirdparty/fish_speech/tools/server/model_manager.py +122 -0
- xinference/thirdparty/fish_speech/tools/server/model_utils.py +129 -0
- xinference/thirdparty/fish_speech/tools/server/views.py +246 -0
- xinference/thirdparty/fish_speech/tools/webui/__init__.py +173 -0
- xinference/thirdparty/fish_speech/tools/webui/inference.py +91 -0
- xinference/thirdparty/fish_speech/tools/webui/variables.py +14 -0
- xinference/thirdparty/matcha/utils/utils.py +2 -2
- xinference/thirdparty/melo/api.py +135 -0
- xinference/thirdparty/melo/app.py +61 -0
- xinference/thirdparty/melo/attentions.py +459 -0
- xinference/thirdparty/melo/commons.py +160 -0
- xinference/thirdparty/melo/configs/config.json +94 -0
- xinference/thirdparty/melo/data/example/metadata.list +20 -0
- xinference/thirdparty/melo/data_utils.py +413 -0
- xinference/thirdparty/melo/download_utils.py +67 -0
- xinference/thirdparty/melo/infer.py +25 -0
- xinference/thirdparty/melo/init_downloads.py +14 -0
- xinference/thirdparty/melo/losses.py +58 -0
- xinference/thirdparty/melo/main.py +36 -0
- xinference/thirdparty/melo/mel_processing.py +174 -0
- xinference/thirdparty/melo/models.py +1030 -0
- xinference/thirdparty/melo/modules.py +598 -0
- xinference/thirdparty/melo/monotonic_align/__init__.py +16 -0
- xinference/thirdparty/melo/monotonic_align/core.py +46 -0
- xinference/thirdparty/melo/preprocess_text.py +135 -0
- xinference/thirdparty/melo/split_utils.py +174 -0
- xinference/thirdparty/melo/text/__init__.py +35 -0
- xinference/thirdparty/melo/text/chinese.py +199 -0
- xinference/thirdparty/melo/text/chinese_bert.py +107 -0
- xinference/thirdparty/melo/text/chinese_mix.py +253 -0
- xinference/thirdparty/melo/text/cleaner.py +36 -0
- xinference/thirdparty/melo/text/cleaner_multiling.py +110 -0
- xinference/thirdparty/melo/text/cmudict.rep +129530 -0
- xinference/thirdparty/melo/text/cmudict_cache.pickle +0 -0
- xinference/thirdparty/melo/text/english.py +284 -0
- xinference/thirdparty/melo/text/english_bert.py +39 -0
- xinference/thirdparty/melo/text/english_utils/abbreviations.py +35 -0
- xinference/thirdparty/melo/text/english_utils/number_norm.py +97 -0
- xinference/thirdparty/melo/text/english_utils/time_norm.py +47 -0
- xinference/thirdparty/melo/text/es_phonemizer/base.py +140 -0
- xinference/thirdparty/melo/text/es_phonemizer/cleaner.py +109 -0
- xinference/thirdparty/melo/text/es_phonemizer/es_symbols.json +79 -0
- xinference/thirdparty/melo/text/es_phonemizer/es_symbols.txt +1 -0
- xinference/thirdparty/melo/text/es_phonemizer/es_symbols_v2.json +83 -0
- xinference/thirdparty/melo/text/es_phonemizer/es_to_ipa.py +12 -0
- xinference/thirdparty/melo/text/es_phonemizer/example_ipa.txt +400 -0
- xinference/thirdparty/melo/text/es_phonemizer/gruut_wrapper.py +253 -0
- xinference/thirdparty/melo/text/es_phonemizer/punctuation.py +174 -0
- xinference/thirdparty/melo/text/es_phonemizer/spanish_symbols.txt +1 -0
- xinference/thirdparty/melo/text/es_phonemizer/test.ipynb +124 -0
- xinference/thirdparty/melo/text/fr_phonemizer/base.py +140 -0
- xinference/thirdparty/melo/text/fr_phonemizer/cleaner.py +122 -0
- xinference/thirdparty/melo/text/fr_phonemizer/en_symbols.json +78 -0
- xinference/thirdparty/melo/text/fr_phonemizer/example_ipa.txt +1 -0
- xinference/thirdparty/melo/text/fr_phonemizer/fr_symbols.json +89 -0
- xinference/thirdparty/melo/text/fr_phonemizer/fr_to_ipa.py +30 -0
- xinference/thirdparty/melo/text/fr_phonemizer/french_abbreviations.py +48 -0
- xinference/thirdparty/melo/text/fr_phonemizer/french_symbols.txt +1 -0
- xinference/thirdparty/melo/text/fr_phonemizer/gruut_wrapper.py +258 -0
- xinference/thirdparty/melo/text/fr_phonemizer/punctuation.py +172 -0
- xinference/thirdparty/melo/text/french.py +94 -0
- xinference/thirdparty/melo/text/french_bert.py +39 -0
- xinference/thirdparty/melo/text/japanese.py +647 -0
- xinference/thirdparty/melo/text/japanese_bert.py +49 -0
- xinference/thirdparty/melo/text/ko_dictionary.py +44 -0
- xinference/thirdparty/melo/text/korean.py +192 -0
- xinference/thirdparty/melo/text/opencpop-strict.txt +429 -0
- xinference/thirdparty/melo/text/spanish.py +122 -0
- xinference/thirdparty/melo/text/spanish_bert.py +39 -0
- xinference/thirdparty/melo/text/symbols.py +290 -0
- xinference/thirdparty/melo/text/tone_sandhi.py +769 -0
- xinference/thirdparty/melo/train.py +635 -0
- xinference/thirdparty/melo/train.sh +19 -0
- xinference/thirdparty/melo/transforms.py +209 -0
- xinference/thirdparty/melo/utils.py +424 -0
- xinference/types.py +15 -0
- xinference/web/ui/build/asset-manifest.json +6 -6
- xinference/web/ui/build/index.html +1 -1
- xinference/web/ui/build/static/css/main.51a587ff.css +2 -0
- xinference/web/ui/build/static/css/main.51a587ff.css.map +1 -0
- xinference/web/ui/build/static/js/main.b0936c54.js +3 -0
- xinference/web/ui/build/static/js/main.b0936c54.js.map +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/03c4052f1b91f6ba0c5389bdcf49c43319b4076c08e4b8585dab312538ae290a.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/1786b83003b8e9605a0f5f855a185d4d16e38fc893dfb326a2a9cca206b4240a.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/17cbc181dd674b9150b80c73ed6a82656de0082d857f6e5f66d9716129ac0b38.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/185ceb8872d562e032b47e79df6a45670e06345b8ed70aad1a131e0476783c5c.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/26b8c9f34b0bed789b3a833767672e39302d1e0c09b4276f4d58d1df7b6bd93b.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/2b484da66c724d0d56a40849c109327408796a668b1381511b6e9e03baa48658.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/2cbbbce9b84df73330d4c42b82436ed881b3847628f2fbc346aa62e2859fd88c.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/2ec9b14431ed33ce6901bf9f27007be4e6e472709c99d6e22b50ce528e4b78ee.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/3b966db018f96be4a055d6ca205f0990d4d0b370e2980c17d8bca2c9a021819c.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/3eefb411b24c2b3ce053570ef50daccf154022f0e168be5ed0fec21394baf9f4.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/522b229e3cac219123f0d69673f5570e191c2d2a505dc65b312d336eae2279c0.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/52e45f17ba300580ea3fcc9f9228ccba194bb092b76f25e9255af311f8b05aab.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/5a0bc4631f936459afc1a3b1d3ec2420118b1f00e11f60ccac3e08088f3f27a8.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/611fa2c6c53b66039991d06dfb0473b5ab37fc63b4564e0f6e1718523768a045.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/6329bc76c406fe5eb305412383fbde5950f847bb5e43261f73f37622c365acb4.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/63c8e07687ea53a4f8a910ee5e42e0eb26cd1acbfbe820f3e3248a786ee51401.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/69b2d5001684174ec9da57e07914eed3eac4960018bceb6cbfa801d861301d7c.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/710c1acda69e561e30a933b98c6a56d50197868b15c21e2aad55ab6d46649eb6.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/720deca1fce5a1dc5056048fa8258fd138a82ea855f350b6613f104a73fb761f.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/76a23b92d26a499c57e61eea2b895fbc9771bd0849a72e66f8e633192017978b.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/858063f23b34dfe600254eb5afd85518b0002ec4b30b7386616c45600826e3b2.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/920b82c1c89124cf217109eeedbfcd3aae3b917be50c9dfb6bbb4ce26bdfd2e7.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/94d8b7aeb0076f2ce07db598cea0e87b13bc8d5614eb530b8d6e696c2daf6f88.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/9e917fe7022d01b2ccbe5cc0ce73d70bb72bee584ff293bad71bdff6695dee28.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/9f28fdb8399f1d0474f0aca86f1658dc94f5bf0c90f6146352de150692de8862.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/a0dfafa06b2bb7cba8cad41c482503f61944f759f4318139362602ef5cc47ccb.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/a3ff866acddf34917a7ee399e0e571a4dfd8ba66d5057db885f243e16a6eb17d.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/afb8084f539534cd594755ea2205ecd5bd1f62dddcfdf75a2eace59a28131278.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/b57b1438b77294c1f3f6cfce12ac487d8106c6f016975ba0aec94d98997e2e1e.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/b9917b0bf8e4d55ccbac1c334aa04d6ff3c5b6ed9e5d38b9ea2c687fa7d3f5a9.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/bbcc94b0149963d1d6f267ee1f4f03d3925b758392ce2f516c3fe8af0e0169fc.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/bdee44abeadc4abc17d41c52eb49c6e19a4b1a267b6e16876ce91bdeeebfc52d.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/beb112b70f4a56db95920a9e20efb6c97c37b68450716730217a9ee1a9ae92be.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/c88db97be0cdf440193b3995996e83510a04cb00048135485fc0e26d197e80b5.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/d49e5314d34310a62d01a03067ce1bec5da00abce84c5196aa9c6842fa79a430.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/d7664d18c4ddbad9c3a6a31b91f7c00fb0dde804608674a9860ee50f33e54708.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/d9072c318b819b7c90a0f7e9cc0b6413b4dbeb8e9859898e53d75ea882fcde99.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/db16a983bc08a05f0439cc61ca0840e49e1d8400eef678909f16c032a418a3d6.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/dc249829767b8abcbc3677e0b07b6d3ecbfdfe6d08cfe23a665eb33373a9aa9d.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/e242c583c2dbc2784f0fcf513523975f7d5df447e106c1c17e49e8578a6fc3ed.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/eac5f1296513e69e4b96f750ddccd4d0264e2bae4e4c449144e83274a48698d9.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/ed57202cb79649bb716400436590245547df241988fc7c8e1d85d132299542d2.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/f125bf72e773a14cdaebd0c343e80adb909d12e317ee5c00cd4a57442fbe2c62.json +1 -0
- xinference/web/ui/node_modules/.cache/babel-loader/f91af913d7f91c410719ab13136aaed3aaf0f8dda06652f25c42cb5231587398.json +1 -0
- xinference/web/ui/node_modules/.package-lock.json +67 -3
- xinference/web/ui/node_modules/@babel/runtime/package.json +592 -538
- xinference/web/ui/node_modules/html-parse-stringify/package.json +50 -0
- xinference/web/ui/node_modules/i18next/dist/esm/package.json +1 -0
- xinference/web/ui/node_modules/i18next/package.json +129 -0
- xinference/web/ui/node_modules/react-i18next/.eslintrc.json +74 -0
- xinference/web/ui/node_modules/react-i18next/dist/es/package.json +1 -0
- xinference/web/ui/node_modules/react-i18next/package.json +162 -0
- xinference/web/ui/node_modules/void-elements/package.json +34 -0
- xinference/web/ui/package-lock.json +69 -3
- xinference/web/ui/package.json +2 -0
- xinference/web/ui/src/locales/en.json +186 -0
- xinference/web/ui/src/locales/zh.json +186 -0
- {xinference-1.0.1.dist-info → xinference-1.2.1.dist-info}/METADATA +68 -32
- {xinference-1.0.1.dist-info → xinference-1.2.1.dist-info}/RECORD +316 -122
- xinference/thirdparty/cosyvoice/bin/export_trt.py +0 -8
- xinference/thirdparty/fish_speech/tools/api.py +0 -943
- xinference/thirdparty/fish_speech/tools/msgpack_api.py +0 -95
- xinference/thirdparty/fish_speech/tools/webui.py +0 -548
- xinference/web/ui/build/static/css/main.5061c4c3.css +0 -2
- xinference/web/ui/build/static/css/main.5061c4c3.css.map +0 -1
- xinference/web/ui/build/static/js/main.2f269bb3.js +0 -3
- xinference/web/ui/build/static/js/main.2f269bb3.js.map +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/07ce9e632e6aff24d7aa3ad8e48224433bbfeb0d633fca723453f1fcae0c9f1c.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/1130403f9e46f5738a23b45ac59b57de8f360c908c713e2c0670c2cce9bd367a.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/131091b25d26b17cdca187d7542a21475c211138d900cf667682260e76ef9463.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/1f269fb2a368363c1cb2237825f1dba093b6bdd8c44cc05954fd19ec2c1fff03.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/331312668fa8bd3d7401818f4a25fa98135d7f61371cd6bfff78b18cf4fbdd92.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/40f17338fc75ae095de7d2b4d8eae0d5ca0193a7e2bcece4ee745b22a7a2f4b7.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/4de9a6942c5f1749d6cbfdd54279699975f16016b182848bc253886f52ec2ec3.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/822586ed1077201b64b954f12f25e3f9b45678c1acbabe53d8af3ca82ca71f33.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/8d33354bd2100c8602afc3341f131a88cc36aaeecd5a4b365ed038514708e350.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/9375a35b05d56989b2755bf72161fa707c92f28569d33765a75f91a568fda6e9.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/a158a9ffa0c9b169aee53dd4a0c44501a596755b4e4f6ede7746d65a72e2a71f.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/bd6ad8159341315a1764c397621a560809f7eb7219ab5174c801fca7e969d943.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/c7bf40bab396765f67d0fed627ed3665890608b2d0edaa3e8cb7cfc96310db45.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/d6c643278a0b28320e6f33a60f5fb64c053997cbdc39a60e53ccc574688ade9e.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/e42b72d4cc1ea412ebecbb8d040dc6c6bfee462c33903c2f1f3facb602ad742e.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/e64b7e8cedcf43d4c95deba60ec1341855c887705805bb62431693118b870c69.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/f5039ddbeb815c51491a1989532006b96fc3ae49c6c60e3c097f875b4ae915ae.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/f72f011744c4649fabddca6f7a9327861ac0a315a89b1a2e62a39774e7863845.json +0 -1
- xinference/web/ui/node_modules/.cache/babel-loader/feabb04b4aa507102da0a64398a40818e878fd1df9b75dda8461b3e1e7ff3f11.json +0 -1
- /xinference/thirdparty/{cosyvoice/bin → f5_tts}/__init__.py +0 -0
- /xinference/thirdparty/{cosyvoice/flow → melo}/__init__.py +0 -0
- /xinference/thirdparty/{cosyvoice/hifigan → melo/text/english_utils}/__init__.py +0 -0
- /xinference/thirdparty/{cosyvoice/llm → melo/text/es_phonemizer}/__init__.py +0 -0
- /xinference/thirdparty/{fish_speech/tools → melo/text/fr_phonemizer}/__init__.py +0 -0
- /xinference/web/ui/build/static/js/{main.2f269bb3.js.LICENSE.txt → main.b0936c54.js.LICENSE.txt} +0 -0
- {xinference-1.0.1.dist-info → xinference-1.2.1.dist-info}/LICENSE +0 -0
- {xinference-1.0.1.dist-info → xinference-1.2.1.dist-info}/WHEEL +0 -0
- {xinference-1.0.1.dist-info → xinference-1.2.1.dist-info}/entry_points.txt +0 -0
- {xinference-1.0.1.dist-info → xinference-1.2.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import torch
|
|
3
|
+
from torch import nn
|
|
4
|
+
from torch.nn import functional as F
|
|
5
|
+
|
|
6
|
+
from . import commons
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
logger = logging.getLogger(__name__)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class LayerNorm(nn.Module):
|
|
13
|
+
def __init__(self, channels, eps=1e-5):
|
|
14
|
+
super().__init__()
|
|
15
|
+
self.channels = channels
|
|
16
|
+
self.eps = eps
|
|
17
|
+
|
|
18
|
+
self.gamma = nn.Parameter(torch.ones(channels))
|
|
19
|
+
self.beta = nn.Parameter(torch.zeros(channels))
|
|
20
|
+
|
|
21
|
+
def forward(self, x):
|
|
22
|
+
x = x.transpose(1, -1)
|
|
23
|
+
x = F.layer_norm(x, (self.channels,), self.gamma, self.beta, self.eps)
|
|
24
|
+
return x.transpose(1, -1)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@torch.jit.script
|
|
28
|
+
def fused_add_tanh_sigmoid_multiply(input_a, input_b, n_channels):
|
|
29
|
+
n_channels_int = n_channels[0]
|
|
30
|
+
in_act = input_a + input_b
|
|
31
|
+
t_act = torch.tanh(in_act[:, :n_channels_int, :])
|
|
32
|
+
s_act = torch.sigmoid(in_act[:, n_channels_int:, :])
|
|
33
|
+
acts = t_act * s_act
|
|
34
|
+
return acts
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class Encoder(nn.Module):
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
hidden_channels,
|
|
41
|
+
filter_channels,
|
|
42
|
+
n_heads,
|
|
43
|
+
n_layers,
|
|
44
|
+
kernel_size=1,
|
|
45
|
+
p_dropout=0.0,
|
|
46
|
+
window_size=4,
|
|
47
|
+
isflow=True,
|
|
48
|
+
**kwargs
|
|
49
|
+
):
|
|
50
|
+
super().__init__()
|
|
51
|
+
self.hidden_channels = hidden_channels
|
|
52
|
+
self.filter_channels = filter_channels
|
|
53
|
+
self.n_heads = n_heads
|
|
54
|
+
self.n_layers = n_layers
|
|
55
|
+
self.kernel_size = kernel_size
|
|
56
|
+
self.p_dropout = p_dropout
|
|
57
|
+
self.window_size = window_size
|
|
58
|
+
|
|
59
|
+
self.cond_layer_idx = self.n_layers
|
|
60
|
+
if "gin_channels" in kwargs:
|
|
61
|
+
self.gin_channels = kwargs["gin_channels"]
|
|
62
|
+
if self.gin_channels != 0:
|
|
63
|
+
self.spk_emb_linear = nn.Linear(self.gin_channels, self.hidden_channels)
|
|
64
|
+
self.cond_layer_idx = (
|
|
65
|
+
kwargs["cond_layer_idx"] if "cond_layer_idx" in kwargs else 2
|
|
66
|
+
)
|
|
67
|
+
assert (
|
|
68
|
+
self.cond_layer_idx < self.n_layers
|
|
69
|
+
), "cond_layer_idx should be less than n_layers"
|
|
70
|
+
self.drop = nn.Dropout(p_dropout)
|
|
71
|
+
self.attn_layers = nn.ModuleList()
|
|
72
|
+
self.norm_layers_1 = nn.ModuleList()
|
|
73
|
+
self.ffn_layers = nn.ModuleList()
|
|
74
|
+
self.norm_layers_2 = nn.ModuleList()
|
|
75
|
+
|
|
76
|
+
for i in range(self.n_layers):
|
|
77
|
+
self.attn_layers.append(
|
|
78
|
+
MultiHeadAttention(
|
|
79
|
+
hidden_channels,
|
|
80
|
+
hidden_channels,
|
|
81
|
+
n_heads,
|
|
82
|
+
p_dropout=p_dropout,
|
|
83
|
+
window_size=window_size,
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
self.norm_layers_1.append(LayerNorm(hidden_channels))
|
|
87
|
+
self.ffn_layers.append(
|
|
88
|
+
FFN(
|
|
89
|
+
hidden_channels,
|
|
90
|
+
hidden_channels,
|
|
91
|
+
filter_channels,
|
|
92
|
+
kernel_size,
|
|
93
|
+
p_dropout=p_dropout,
|
|
94
|
+
)
|
|
95
|
+
)
|
|
96
|
+
self.norm_layers_2.append(LayerNorm(hidden_channels))
|
|
97
|
+
|
|
98
|
+
def forward(self, x, x_mask, g=None):
|
|
99
|
+
attn_mask = x_mask.unsqueeze(2) * x_mask.unsqueeze(-1)
|
|
100
|
+
x = x * x_mask
|
|
101
|
+
for i in range(self.n_layers):
|
|
102
|
+
if i == self.cond_layer_idx and g is not None:
|
|
103
|
+
g = self.spk_emb_linear(g.transpose(1, 2))
|
|
104
|
+
g = g.transpose(1, 2)
|
|
105
|
+
x = x + g
|
|
106
|
+
x = x * x_mask
|
|
107
|
+
y = self.attn_layers[i](x, x, attn_mask)
|
|
108
|
+
y = self.drop(y)
|
|
109
|
+
x = self.norm_layers_1[i](x + y)
|
|
110
|
+
|
|
111
|
+
y = self.ffn_layers[i](x, x_mask)
|
|
112
|
+
y = self.drop(y)
|
|
113
|
+
x = self.norm_layers_2[i](x + y)
|
|
114
|
+
x = x * x_mask
|
|
115
|
+
return x
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class Decoder(nn.Module):
|
|
119
|
+
def __init__(
|
|
120
|
+
self,
|
|
121
|
+
hidden_channels,
|
|
122
|
+
filter_channels,
|
|
123
|
+
n_heads,
|
|
124
|
+
n_layers,
|
|
125
|
+
kernel_size=1,
|
|
126
|
+
p_dropout=0.0,
|
|
127
|
+
proximal_bias=False,
|
|
128
|
+
proximal_init=True,
|
|
129
|
+
**kwargs
|
|
130
|
+
):
|
|
131
|
+
super().__init__()
|
|
132
|
+
self.hidden_channels = hidden_channels
|
|
133
|
+
self.filter_channels = filter_channels
|
|
134
|
+
self.n_heads = n_heads
|
|
135
|
+
self.n_layers = n_layers
|
|
136
|
+
self.kernel_size = kernel_size
|
|
137
|
+
self.p_dropout = p_dropout
|
|
138
|
+
self.proximal_bias = proximal_bias
|
|
139
|
+
self.proximal_init = proximal_init
|
|
140
|
+
|
|
141
|
+
self.drop = nn.Dropout(p_dropout)
|
|
142
|
+
self.self_attn_layers = nn.ModuleList()
|
|
143
|
+
self.norm_layers_0 = nn.ModuleList()
|
|
144
|
+
self.encdec_attn_layers = nn.ModuleList()
|
|
145
|
+
self.norm_layers_1 = nn.ModuleList()
|
|
146
|
+
self.ffn_layers = nn.ModuleList()
|
|
147
|
+
self.norm_layers_2 = nn.ModuleList()
|
|
148
|
+
for i in range(self.n_layers):
|
|
149
|
+
self.self_attn_layers.append(
|
|
150
|
+
MultiHeadAttention(
|
|
151
|
+
hidden_channels,
|
|
152
|
+
hidden_channels,
|
|
153
|
+
n_heads,
|
|
154
|
+
p_dropout=p_dropout,
|
|
155
|
+
proximal_bias=proximal_bias,
|
|
156
|
+
proximal_init=proximal_init,
|
|
157
|
+
)
|
|
158
|
+
)
|
|
159
|
+
self.norm_layers_0.append(LayerNorm(hidden_channels))
|
|
160
|
+
self.encdec_attn_layers.append(
|
|
161
|
+
MultiHeadAttention(
|
|
162
|
+
hidden_channels, hidden_channels, n_heads, p_dropout=p_dropout
|
|
163
|
+
)
|
|
164
|
+
)
|
|
165
|
+
self.norm_layers_1.append(LayerNorm(hidden_channels))
|
|
166
|
+
self.ffn_layers.append(
|
|
167
|
+
FFN(
|
|
168
|
+
hidden_channels,
|
|
169
|
+
hidden_channels,
|
|
170
|
+
filter_channels,
|
|
171
|
+
kernel_size,
|
|
172
|
+
p_dropout=p_dropout,
|
|
173
|
+
causal=True,
|
|
174
|
+
)
|
|
175
|
+
)
|
|
176
|
+
self.norm_layers_2.append(LayerNorm(hidden_channels))
|
|
177
|
+
|
|
178
|
+
def forward(self, x, x_mask, h, h_mask):
|
|
179
|
+
"""
|
|
180
|
+
x: decoder input
|
|
181
|
+
h: encoder output
|
|
182
|
+
"""
|
|
183
|
+
self_attn_mask = commons.subsequent_mask(x_mask.size(2)).to(
|
|
184
|
+
device=x.device, dtype=x.dtype
|
|
185
|
+
)
|
|
186
|
+
encdec_attn_mask = h_mask.unsqueeze(2) * x_mask.unsqueeze(-1)
|
|
187
|
+
x = x * x_mask
|
|
188
|
+
for i in range(self.n_layers):
|
|
189
|
+
y = self.self_attn_layers[i](x, x, self_attn_mask)
|
|
190
|
+
y = self.drop(y)
|
|
191
|
+
x = self.norm_layers_0[i](x + y)
|
|
192
|
+
|
|
193
|
+
y = self.encdec_attn_layers[i](x, h, encdec_attn_mask)
|
|
194
|
+
y = self.drop(y)
|
|
195
|
+
x = self.norm_layers_1[i](x + y)
|
|
196
|
+
|
|
197
|
+
y = self.ffn_layers[i](x, x_mask)
|
|
198
|
+
y = self.drop(y)
|
|
199
|
+
x = self.norm_layers_2[i](x + y)
|
|
200
|
+
x = x * x_mask
|
|
201
|
+
return x
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
class MultiHeadAttention(nn.Module):
|
|
205
|
+
def __init__(
|
|
206
|
+
self,
|
|
207
|
+
channels,
|
|
208
|
+
out_channels,
|
|
209
|
+
n_heads,
|
|
210
|
+
p_dropout=0.0,
|
|
211
|
+
window_size=None,
|
|
212
|
+
heads_share=True,
|
|
213
|
+
block_length=None,
|
|
214
|
+
proximal_bias=False,
|
|
215
|
+
proximal_init=False,
|
|
216
|
+
):
|
|
217
|
+
super().__init__()
|
|
218
|
+
assert channels % n_heads == 0
|
|
219
|
+
|
|
220
|
+
self.channels = channels
|
|
221
|
+
self.out_channels = out_channels
|
|
222
|
+
self.n_heads = n_heads
|
|
223
|
+
self.p_dropout = p_dropout
|
|
224
|
+
self.window_size = window_size
|
|
225
|
+
self.heads_share = heads_share
|
|
226
|
+
self.block_length = block_length
|
|
227
|
+
self.proximal_bias = proximal_bias
|
|
228
|
+
self.proximal_init = proximal_init
|
|
229
|
+
self.attn = None
|
|
230
|
+
|
|
231
|
+
self.k_channels = channels // n_heads
|
|
232
|
+
self.conv_q = nn.Conv1d(channels, channels, 1)
|
|
233
|
+
self.conv_k = nn.Conv1d(channels, channels, 1)
|
|
234
|
+
self.conv_v = nn.Conv1d(channels, channels, 1)
|
|
235
|
+
self.conv_o = nn.Conv1d(channels, out_channels, 1)
|
|
236
|
+
self.drop = nn.Dropout(p_dropout)
|
|
237
|
+
|
|
238
|
+
if window_size is not None:
|
|
239
|
+
n_heads_rel = 1 if heads_share else n_heads
|
|
240
|
+
rel_stddev = self.k_channels**-0.5
|
|
241
|
+
self.emb_rel_k = nn.Parameter(
|
|
242
|
+
torch.randn(n_heads_rel, window_size * 2 + 1, self.k_channels)
|
|
243
|
+
* rel_stddev
|
|
244
|
+
)
|
|
245
|
+
self.emb_rel_v = nn.Parameter(
|
|
246
|
+
torch.randn(n_heads_rel, window_size * 2 + 1, self.k_channels)
|
|
247
|
+
* rel_stddev
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
nn.init.xavier_uniform_(self.conv_q.weight)
|
|
251
|
+
nn.init.xavier_uniform_(self.conv_k.weight)
|
|
252
|
+
nn.init.xavier_uniform_(self.conv_v.weight)
|
|
253
|
+
if proximal_init:
|
|
254
|
+
with torch.no_grad():
|
|
255
|
+
self.conv_k.weight.copy_(self.conv_q.weight)
|
|
256
|
+
self.conv_k.bias.copy_(self.conv_q.bias)
|
|
257
|
+
|
|
258
|
+
def forward(self, x, c, attn_mask=None):
|
|
259
|
+
q = self.conv_q(x)
|
|
260
|
+
k = self.conv_k(c)
|
|
261
|
+
v = self.conv_v(c)
|
|
262
|
+
|
|
263
|
+
x, self.attn = self.attention(q, k, v, mask=attn_mask)
|
|
264
|
+
|
|
265
|
+
x = self.conv_o(x)
|
|
266
|
+
return x
|
|
267
|
+
|
|
268
|
+
def attention(self, query, key, value, mask=None):
|
|
269
|
+
# reshape [b, d, t] -> [b, n_h, t, d_k]
|
|
270
|
+
b, d, t_s, t_t = (*key.size(), query.size(2))
|
|
271
|
+
query = query.view(b, self.n_heads, self.k_channels, t_t).transpose(2, 3)
|
|
272
|
+
key = key.view(b, self.n_heads, self.k_channels, t_s).transpose(2, 3)
|
|
273
|
+
value = value.view(b, self.n_heads, self.k_channels, t_s).transpose(2, 3)
|
|
274
|
+
|
|
275
|
+
scores = torch.matmul(query / math.sqrt(self.k_channels), key.transpose(-2, -1))
|
|
276
|
+
if self.window_size is not None:
|
|
277
|
+
assert (
|
|
278
|
+
t_s == t_t
|
|
279
|
+
), "Relative attention is only available for self-attention."
|
|
280
|
+
key_relative_embeddings = self._get_relative_embeddings(self.emb_rel_k, t_s)
|
|
281
|
+
rel_logits = self._matmul_with_relative_keys(
|
|
282
|
+
query / math.sqrt(self.k_channels), key_relative_embeddings
|
|
283
|
+
)
|
|
284
|
+
scores_local = self._relative_position_to_absolute_position(rel_logits)
|
|
285
|
+
scores = scores + scores_local
|
|
286
|
+
if self.proximal_bias:
|
|
287
|
+
assert t_s == t_t, "Proximal bias is only available for self-attention."
|
|
288
|
+
scores = scores + self._attention_bias_proximal(t_s).to(
|
|
289
|
+
device=scores.device, dtype=scores.dtype
|
|
290
|
+
)
|
|
291
|
+
if mask is not None:
|
|
292
|
+
scores = scores.masked_fill(mask == 0, -1e4)
|
|
293
|
+
if self.block_length is not None:
|
|
294
|
+
assert (
|
|
295
|
+
t_s == t_t
|
|
296
|
+
), "Local attention is only available for self-attention."
|
|
297
|
+
block_mask = (
|
|
298
|
+
torch.ones_like(scores)
|
|
299
|
+
.triu(-self.block_length)
|
|
300
|
+
.tril(self.block_length)
|
|
301
|
+
)
|
|
302
|
+
scores = scores.masked_fill(block_mask == 0, -1e4)
|
|
303
|
+
p_attn = F.softmax(scores, dim=-1) # [b, n_h, t_t, t_s]
|
|
304
|
+
p_attn = self.drop(p_attn)
|
|
305
|
+
output = torch.matmul(p_attn, value)
|
|
306
|
+
if self.window_size is not None:
|
|
307
|
+
relative_weights = self._absolute_position_to_relative_position(p_attn)
|
|
308
|
+
value_relative_embeddings = self._get_relative_embeddings(
|
|
309
|
+
self.emb_rel_v, t_s
|
|
310
|
+
)
|
|
311
|
+
output = output + self._matmul_with_relative_values(
|
|
312
|
+
relative_weights, value_relative_embeddings
|
|
313
|
+
)
|
|
314
|
+
output = (
|
|
315
|
+
output.transpose(2, 3).contiguous().view(b, d, t_t)
|
|
316
|
+
) # [b, n_h, t_t, d_k] -> [b, d, t_t]
|
|
317
|
+
return output, p_attn
|
|
318
|
+
|
|
319
|
+
def _matmul_with_relative_values(self, x, y):
|
|
320
|
+
"""
|
|
321
|
+
x: [b, h, l, m]
|
|
322
|
+
y: [h or 1, m, d]
|
|
323
|
+
ret: [b, h, l, d]
|
|
324
|
+
"""
|
|
325
|
+
ret = torch.matmul(x, y.unsqueeze(0))
|
|
326
|
+
return ret
|
|
327
|
+
|
|
328
|
+
def _matmul_with_relative_keys(self, x, y):
|
|
329
|
+
"""
|
|
330
|
+
x: [b, h, l, d]
|
|
331
|
+
y: [h or 1, m, d]
|
|
332
|
+
ret: [b, h, l, m]
|
|
333
|
+
"""
|
|
334
|
+
ret = torch.matmul(x, y.unsqueeze(0).transpose(-2, -1))
|
|
335
|
+
return ret
|
|
336
|
+
|
|
337
|
+
def _get_relative_embeddings(self, relative_embeddings, length):
|
|
338
|
+
2 * self.window_size + 1
|
|
339
|
+
# Pad first before slice to avoid using cond ops.
|
|
340
|
+
pad_length = max(length - (self.window_size + 1), 0)
|
|
341
|
+
slice_start_position = max((self.window_size + 1) - length, 0)
|
|
342
|
+
slice_end_position = slice_start_position + 2 * length - 1
|
|
343
|
+
if pad_length > 0:
|
|
344
|
+
padded_relative_embeddings = F.pad(
|
|
345
|
+
relative_embeddings,
|
|
346
|
+
commons.convert_pad_shape([[0, 0], [pad_length, pad_length], [0, 0]]),
|
|
347
|
+
)
|
|
348
|
+
else:
|
|
349
|
+
padded_relative_embeddings = relative_embeddings
|
|
350
|
+
used_relative_embeddings = padded_relative_embeddings[
|
|
351
|
+
:, slice_start_position:slice_end_position
|
|
352
|
+
]
|
|
353
|
+
return used_relative_embeddings
|
|
354
|
+
|
|
355
|
+
def _relative_position_to_absolute_position(self, x):
|
|
356
|
+
"""
|
|
357
|
+
x: [b, h, l, 2*l-1]
|
|
358
|
+
ret: [b, h, l, l]
|
|
359
|
+
"""
|
|
360
|
+
batch, heads, length, _ = x.size()
|
|
361
|
+
# Concat columns of pad to shift from relative to absolute indexing.
|
|
362
|
+
x = F.pad(x, commons.convert_pad_shape([[0, 0], [0, 0], [0, 0], [0, 1]]))
|
|
363
|
+
|
|
364
|
+
# Concat extra elements so to add up to shape (len+1, 2*len-1).
|
|
365
|
+
x_flat = x.view([batch, heads, length * 2 * length])
|
|
366
|
+
x_flat = F.pad(
|
|
367
|
+
x_flat, commons.convert_pad_shape([[0, 0], [0, 0], [0, length - 1]])
|
|
368
|
+
)
|
|
369
|
+
|
|
370
|
+
# Reshape and slice out the padded elements.
|
|
371
|
+
x_final = x_flat.view([batch, heads, length + 1, 2 * length - 1])[
|
|
372
|
+
:, :, :length, length - 1 :
|
|
373
|
+
]
|
|
374
|
+
return x_final
|
|
375
|
+
|
|
376
|
+
def _absolute_position_to_relative_position(self, x):
|
|
377
|
+
"""
|
|
378
|
+
x: [b, h, l, l]
|
|
379
|
+
ret: [b, h, l, 2*l-1]
|
|
380
|
+
"""
|
|
381
|
+
batch, heads, length, _ = x.size()
|
|
382
|
+
# pad along column
|
|
383
|
+
x = F.pad(
|
|
384
|
+
x, commons.convert_pad_shape([[0, 0], [0, 0], [0, 0], [0, length - 1]])
|
|
385
|
+
)
|
|
386
|
+
x_flat = x.view([batch, heads, length**2 + length * (length - 1)])
|
|
387
|
+
# add 0's in the beginning that will skew the elements after reshape
|
|
388
|
+
x_flat = F.pad(x_flat, commons.convert_pad_shape([[0, 0], [0, 0], [length, 0]]))
|
|
389
|
+
x_final = x_flat.view([batch, heads, length, 2 * length])[:, :, :, 1:]
|
|
390
|
+
return x_final
|
|
391
|
+
|
|
392
|
+
def _attention_bias_proximal(self, length):
|
|
393
|
+
"""Bias for self-attention to encourage attention to close positions.
|
|
394
|
+
Args:
|
|
395
|
+
length: an integer scalar.
|
|
396
|
+
Returns:
|
|
397
|
+
a Tensor with shape [1, 1, length, length]
|
|
398
|
+
"""
|
|
399
|
+
r = torch.arange(length, dtype=torch.float32)
|
|
400
|
+
diff = torch.unsqueeze(r, 0) - torch.unsqueeze(r, 1)
|
|
401
|
+
return torch.unsqueeze(torch.unsqueeze(-torch.log1p(torch.abs(diff)), 0), 0)
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
class FFN(nn.Module):
|
|
405
|
+
def __init__(
|
|
406
|
+
self,
|
|
407
|
+
in_channels,
|
|
408
|
+
out_channels,
|
|
409
|
+
filter_channels,
|
|
410
|
+
kernel_size,
|
|
411
|
+
p_dropout=0.0,
|
|
412
|
+
activation=None,
|
|
413
|
+
causal=False,
|
|
414
|
+
):
|
|
415
|
+
super().__init__()
|
|
416
|
+
self.in_channels = in_channels
|
|
417
|
+
self.out_channels = out_channels
|
|
418
|
+
self.filter_channels = filter_channels
|
|
419
|
+
self.kernel_size = kernel_size
|
|
420
|
+
self.p_dropout = p_dropout
|
|
421
|
+
self.activation = activation
|
|
422
|
+
self.causal = causal
|
|
423
|
+
|
|
424
|
+
if causal:
|
|
425
|
+
self.padding = self._causal_padding
|
|
426
|
+
else:
|
|
427
|
+
self.padding = self._same_padding
|
|
428
|
+
|
|
429
|
+
self.conv_1 = nn.Conv1d(in_channels, filter_channels, kernel_size)
|
|
430
|
+
self.conv_2 = nn.Conv1d(filter_channels, out_channels, kernel_size)
|
|
431
|
+
self.drop = nn.Dropout(p_dropout)
|
|
432
|
+
|
|
433
|
+
def forward(self, x, x_mask):
|
|
434
|
+
x = self.conv_1(self.padding(x * x_mask))
|
|
435
|
+
if self.activation == "gelu":
|
|
436
|
+
x = x * torch.sigmoid(1.702 * x)
|
|
437
|
+
else:
|
|
438
|
+
x = torch.relu(x)
|
|
439
|
+
x = self.drop(x)
|
|
440
|
+
x = self.conv_2(self.padding(x * x_mask))
|
|
441
|
+
return x * x_mask
|
|
442
|
+
|
|
443
|
+
def _causal_padding(self, x):
|
|
444
|
+
if self.kernel_size == 1:
|
|
445
|
+
return x
|
|
446
|
+
pad_l = self.kernel_size - 1
|
|
447
|
+
pad_r = 0
|
|
448
|
+
padding = [[0, 0], [0, 0], [pad_l, pad_r]]
|
|
449
|
+
x = F.pad(x, commons.convert_pad_shape(padding))
|
|
450
|
+
return x
|
|
451
|
+
|
|
452
|
+
def _same_padding(self, x):
|
|
453
|
+
if self.kernel_size == 1:
|
|
454
|
+
return x
|
|
455
|
+
pad_l = (self.kernel_size - 1) // 2
|
|
456
|
+
pad_r = self.kernel_size // 2
|
|
457
|
+
padding = [[0, 0], [0, 0], [pad_l, pad_r]]
|
|
458
|
+
x = F.pad(x, commons.convert_pad_shape(padding))
|
|
459
|
+
return x
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import math
|
|
2
|
+
import torch
|
|
3
|
+
from torch.nn import functional as F
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def init_weights(m, mean=0.0, std=0.01):
|
|
7
|
+
classname = m.__class__.__name__
|
|
8
|
+
if classname.find("Conv") != -1:
|
|
9
|
+
m.weight.data.normal_(mean, std)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def get_padding(kernel_size, dilation=1):
|
|
13
|
+
return int((kernel_size * dilation - dilation) / 2)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def convert_pad_shape(pad_shape):
|
|
17
|
+
layer = pad_shape[::-1]
|
|
18
|
+
pad_shape = [item for sublist in layer for item in sublist]
|
|
19
|
+
return pad_shape
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def intersperse(lst, item):
|
|
23
|
+
result = [item] * (len(lst) * 2 + 1)
|
|
24
|
+
result[1::2] = lst
|
|
25
|
+
return result
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def kl_divergence(m_p, logs_p, m_q, logs_q):
|
|
29
|
+
"""KL(P||Q)"""
|
|
30
|
+
kl = (logs_q - logs_p) - 0.5
|
|
31
|
+
kl += (
|
|
32
|
+
0.5 * (torch.exp(2.0 * logs_p) + ((m_p - m_q) ** 2)) * torch.exp(-2.0 * logs_q)
|
|
33
|
+
)
|
|
34
|
+
return kl
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def rand_gumbel(shape):
|
|
38
|
+
"""Sample from the Gumbel distribution, protect from overflows."""
|
|
39
|
+
uniform_samples = torch.rand(shape) * 0.99998 + 0.00001
|
|
40
|
+
return -torch.log(-torch.log(uniform_samples))
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def rand_gumbel_like(x):
|
|
44
|
+
g = rand_gumbel(x.size()).to(dtype=x.dtype, device=x.device)
|
|
45
|
+
return g
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def slice_segments(x, ids_str, segment_size=4):
|
|
49
|
+
ret = torch.zeros_like(x[:, :, :segment_size])
|
|
50
|
+
for i in range(x.size(0)):
|
|
51
|
+
idx_str = ids_str[i]
|
|
52
|
+
idx_end = idx_str + segment_size
|
|
53
|
+
ret[i] = x[i, :, idx_str:idx_end]
|
|
54
|
+
return ret
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def rand_slice_segments(x, x_lengths=None, segment_size=4):
|
|
58
|
+
b, d, t = x.size()
|
|
59
|
+
if x_lengths is None:
|
|
60
|
+
x_lengths = t
|
|
61
|
+
ids_str_max = x_lengths - segment_size + 1
|
|
62
|
+
ids_str = (torch.rand([b]).to(device=x.device) * ids_str_max).to(dtype=torch.long)
|
|
63
|
+
ret = slice_segments(x, ids_str, segment_size)
|
|
64
|
+
return ret, ids_str
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def get_timing_signal_1d(length, channels, min_timescale=1.0, max_timescale=1.0e4):
|
|
68
|
+
position = torch.arange(length, dtype=torch.float)
|
|
69
|
+
num_timescales = channels // 2
|
|
70
|
+
log_timescale_increment = math.log(float(max_timescale) / float(min_timescale)) / (
|
|
71
|
+
num_timescales - 1
|
|
72
|
+
)
|
|
73
|
+
inv_timescales = min_timescale * torch.exp(
|
|
74
|
+
torch.arange(num_timescales, dtype=torch.float) * -log_timescale_increment
|
|
75
|
+
)
|
|
76
|
+
scaled_time = position.unsqueeze(0) * inv_timescales.unsqueeze(1)
|
|
77
|
+
signal = torch.cat([torch.sin(scaled_time), torch.cos(scaled_time)], 0)
|
|
78
|
+
signal = F.pad(signal, [0, 0, 0, channels % 2])
|
|
79
|
+
signal = signal.view(1, channels, length)
|
|
80
|
+
return signal
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def add_timing_signal_1d(x, min_timescale=1.0, max_timescale=1.0e4):
|
|
84
|
+
b, channels, length = x.size()
|
|
85
|
+
signal = get_timing_signal_1d(length, channels, min_timescale, max_timescale)
|
|
86
|
+
return x + signal.to(dtype=x.dtype, device=x.device)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def cat_timing_signal_1d(x, min_timescale=1.0, max_timescale=1.0e4, axis=1):
|
|
90
|
+
b, channels, length = x.size()
|
|
91
|
+
signal = get_timing_signal_1d(length, channels, min_timescale, max_timescale)
|
|
92
|
+
return torch.cat([x, signal.to(dtype=x.dtype, device=x.device)], axis)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def subsequent_mask(length):
|
|
96
|
+
mask = torch.tril(torch.ones(length, length)).unsqueeze(0).unsqueeze(0)
|
|
97
|
+
return mask
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@torch.jit.script
|
|
101
|
+
def fused_add_tanh_sigmoid_multiply(input_a, input_b, n_channels):
|
|
102
|
+
n_channels_int = n_channels[0]
|
|
103
|
+
in_act = input_a + input_b
|
|
104
|
+
t_act = torch.tanh(in_act[:, :n_channels_int, :])
|
|
105
|
+
s_act = torch.sigmoid(in_act[:, n_channels_int:, :])
|
|
106
|
+
acts = t_act * s_act
|
|
107
|
+
return acts
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def convert_pad_shape(pad_shape):
|
|
111
|
+
layer = pad_shape[::-1]
|
|
112
|
+
pad_shape = [item for sublist in layer for item in sublist]
|
|
113
|
+
return pad_shape
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def shift_1d(x):
|
|
117
|
+
x = F.pad(x, convert_pad_shape([[0, 0], [0, 0], [1, 0]]))[:, :, :-1]
|
|
118
|
+
return x
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def sequence_mask(length, max_length=None):
|
|
122
|
+
if max_length is None:
|
|
123
|
+
max_length = length.max()
|
|
124
|
+
x = torch.arange(max_length, dtype=length.dtype, device=length.device)
|
|
125
|
+
return x.unsqueeze(0) < length.unsqueeze(1)
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def generate_path(duration, mask):
|
|
129
|
+
"""
|
|
130
|
+
duration: [b, 1, t_x]
|
|
131
|
+
mask: [b, 1, t_y, t_x]
|
|
132
|
+
"""
|
|
133
|
+
|
|
134
|
+
b, _, t_y, t_x = mask.shape
|
|
135
|
+
cum_duration = torch.cumsum(duration, -1)
|
|
136
|
+
|
|
137
|
+
cum_duration_flat = cum_duration.view(b * t_x)
|
|
138
|
+
path = sequence_mask(cum_duration_flat, t_y).to(mask.dtype)
|
|
139
|
+
path = path.view(b, t_x, t_y)
|
|
140
|
+
path = path - F.pad(path, convert_pad_shape([[0, 0], [1, 0], [0, 0]]))[:, :-1]
|
|
141
|
+
path = path.unsqueeze(1).transpose(2, 3) * mask
|
|
142
|
+
return path
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def clip_grad_value_(parameters, clip_value, norm_type=2):
|
|
146
|
+
if isinstance(parameters, torch.Tensor):
|
|
147
|
+
parameters = [parameters]
|
|
148
|
+
parameters = list(filter(lambda p: p.grad is not None, parameters))
|
|
149
|
+
norm_type = float(norm_type)
|
|
150
|
+
if clip_value is not None:
|
|
151
|
+
clip_value = float(clip_value)
|
|
152
|
+
|
|
153
|
+
total_norm = 0
|
|
154
|
+
for p in parameters:
|
|
155
|
+
param_norm = p.grad.data.norm(norm_type)
|
|
156
|
+
total_norm += param_norm.item() ** norm_type
|
|
157
|
+
if clip_value is not None:
|
|
158
|
+
p.grad.data.clamp_(min=-clip_value, max=clip_value)
|
|
159
|
+
total_norm = total_norm ** (1.0 / norm_type)
|
|
160
|
+
return total_norm
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
{
|
|
2
|
+
"train": {
|
|
3
|
+
"log_interval": 200,
|
|
4
|
+
"eval_interval": 1000,
|
|
5
|
+
"seed": 52,
|
|
6
|
+
"epochs": 10000,
|
|
7
|
+
"learning_rate": 0.0003,
|
|
8
|
+
"betas": [
|
|
9
|
+
0.8,
|
|
10
|
+
0.99
|
|
11
|
+
],
|
|
12
|
+
"eps": 1e-09,
|
|
13
|
+
"batch_size": 6,
|
|
14
|
+
"fp16_run": false,
|
|
15
|
+
"lr_decay": 0.999875,
|
|
16
|
+
"segment_size": 16384,
|
|
17
|
+
"init_lr_ratio": 1,
|
|
18
|
+
"warmup_epochs": 0,
|
|
19
|
+
"c_mel": 45,
|
|
20
|
+
"c_kl": 1.0,
|
|
21
|
+
"skip_optimizer": true
|
|
22
|
+
},
|
|
23
|
+
"data": {
|
|
24
|
+
"training_files": "",
|
|
25
|
+
"validation_files": "",
|
|
26
|
+
"max_wav_value": 32768.0,
|
|
27
|
+
"sampling_rate": 44100,
|
|
28
|
+
"filter_length": 2048,
|
|
29
|
+
"hop_length": 512,
|
|
30
|
+
"win_length": 2048,
|
|
31
|
+
"n_mel_channels": 128,
|
|
32
|
+
"mel_fmin": 0.0,
|
|
33
|
+
"mel_fmax": null,
|
|
34
|
+
"add_blank": true,
|
|
35
|
+
"n_speakers": 256,
|
|
36
|
+
"cleaned_text": true,
|
|
37
|
+
"spk2id": {}
|
|
38
|
+
},
|
|
39
|
+
"model": {
|
|
40
|
+
"use_spk_conditioned_encoder": true,
|
|
41
|
+
"use_noise_scaled_mas": true,
|
|
42
|
+
"use_mel_posterior_encoder": false,
|
|
43
|
+
"use_duration_discriminator": true,
|
|
44
|
+
"inter_channels": 192,
|
|
45
|
+
"hidden_channels": 192,
|
|
46
|
+
"filter_channels": 768,
|
|
47
|
+
"n_heads": 2,
|
|
48
|
+
"n_layers": 6,
|
|
49
|
+
"n_layers_trans_flow": 3,
|
|
50
|
+
"kernel_size": 3,
|
|
51
|
+
"p_dropout": 0.1,
|
|
52
|
+
"resblock": "1",
|
|
53
|
+
"resblock_kernel_sizes": [
|
|
54
|
+
3,
|
|
55
|
+
7,
|
|
56
|
+
11
|
|
57
|
+
],
|
|
58
|
+
"resblock_dilation_sizes": [
|
|
59
|
+
[
|
|
60
|
+
1,
|
|
61
|
+
3,
|
|
62
|
+
5
|
|
63
|
+
],
|
|
64
|
+
[
|
|
65
|
+
1,
|
|
66
|
+
3,
|
|
67
|
+
5
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
1,
|
|
71
|
+
3,
|
|
72
|
+
5
|
|
73
|
+
]
|
|
74
|
+
],
|
|
75
|
+
"upsample_rates": [
|
|
76
|
+
8,
|
|
77
|
+
8,
|
|
78
|
+
2,
|
|
79
|
+
2,
|
|
80
|
+
2
|
|
81
|
+
],
|
|
82
|
+
"upsample_initial_channel": 512,
|
|
83
|
+
"upsample_kernel_sizes": [
|
|
84
|
+
16,
|
|
85
|
+
16,
|
|
86
|
+
8,
|
|
87
|
+
2,
|
|
88
|
+
2
|
|
89
|
+
],
|
|
90
|
+
"n_layers_q": 3,
|
|
91
|
+
"use_spectral_norm": false,
|
|
92
|
+
"gin_channels": 256
|
|
93
|
+
}
|
|
94
|
+
}
|