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,163 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ein notation:
|
|
3
|
+
b - batch
|
|
4
|
+
n - sequence
|
|
5
|
+
nt - text sequence
|
|
6
|
+
nw - raw wave length
|
|
7
|
+
d - dimension
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import torch
|
|
13
|
+
from torch import nn
|
|
14
|
+
import torch.nn.functional as F
|
|
15
|
+
|
|
16
|
+
from x_transformers.x_transformers import RotaryEmbedding
|
|
17
|
+
|
|
18
|
+
from f5_tts.model.modules import (
|
|
19
|
+
TimestepEmbedding,
|
|
20
|
+
ConvNeXtV2Block,
|
|
21
|
+
ConvPositionEmbedding,
|
|
22
|
+
DiTBlock,
|
|
23
|
+
AdaLayerNormZero_Final,
|
|
24
|
+
precompute_freqs_cis,
|
|
25
|
+
get_pos_embed_indices,
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Text embedding
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class TextEmbedding(nn.Module):
|
|
33
|
+
def __init__(self, text_num_embeds, text_dim, conv_layers=0, conv_mult=2):
|
|
34
|
+
super().__init__()
|
|
35
|
+
self.text_embed = nn.Embedding(text_num_embeds + 1, text_dim) # use 0 as filler token
|
|
36
|
+
|
|
37
|
+
if conv_layers > 0:
|
|
38
|
+
self.extra_modeling = True
|
|
39
|
+
self.precompute_max_pos = 4096 # ~44s of 24khz audio
|
|
40
|
+
self.register_buffer("freqs_cis", precompute_freqs_cis(text_dim, self.precompute_max_pos), persistent=False)
|
|
41
|
+
self.text_blocks = nn.Sequential(
|
|
42
|
+
*[ConvNeXtV2Block(text_dim, text_dim * conv_mult) for _ in range(conv_layers)]
|
|
43
|
+
)
|
|
44
|
+
else:
|
|
45
|
+
self.extra_modeling = False
|
|
46
|
+
|
|
47
|
+
def forward(self, text: int["b nt"], seq_len, drop_text=False): # noqa: F722
|
|
48
|
+
text = text + 1 # use 0 as filler token. preprocess of batch pad -1, see list_str_to_idx()
|
|
49
|
+
text = text[:, :seq_len] # curtail if character tokens are more than the mel spec tokens
|
|
50
|
+
batch, text_len = text.shape[0], text.shape[1]
|
|
51
|
+
text = F.pad(text, (0, seq_len - text_len), value=0)
|
|
52
|
+
|
|
53
|
+
if drop_text: # cfg for text
|
|
54
|
+
text = torch.zeros_like(text)
|
|
55
|
+
|
|
56
|
+
text = self.text_embed(text) # b n -> b n d
|
|
57
|
+
|
|
58
|
+
# possible extra modeling
|
|
59
|
+
if self.extra_modeling:
|
|
60
|
+
# sinus pos emb
|
|
61
|
+
batch_start = torch.zeros((batch,), dtype=torch.long)
|
|
62
|
+
pos_idx = get_pos_embed_indices(batch_start, seq_len, max_pos=self.precompute_max_pos)
|
|
63
|
+
text_pos_embed = self.freqs_cis[pos_idx]
|
|
64
|
+
text = text + text_pos_embed
|
|
65
|
+
|
|
66
|
+
# convnextv2 blocks
|
|
67
|
+
text = self.text_blocks(text)
|
|
68
|
+
|
|
69
|
+
return text
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# noised input audio and context mixing embedding
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class InputEmbedding(nn.Module):
|
|
76
|
+
def __init__(self, mel_dim, text_dim, out_dim):
|
|
77
|
+
super().__init__()
|
|
78
|
+
self.proj = nn.Linear(mel_dim * 2 + text_dim, out_dim)
|
|
79
|
+
self.conv_pos_embed = ConvPositionEmbedding(dim=out_dim)
|
|
80
|
+
|
|
81
|
+
def forward(self, x: float["b n d"], cond: float["b n d"], text_embed: float["b n d"], drop_audio_cond=False): # noqa: F722
|
|
82
|
+
if drop_audio_cond: # cfg for cond audio
|
|
83
|
+
cond = torch.zeros_like(cond)
|
|
84
|
+
|
|
85
|
+
x = self.proj(torch.cat((x, cond, text_embed), dim=-1))
|
|
86
|
+
x = self.conv_pos_embed(x) + x
|
|
87
|
+
return x
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
# Transformer backbone using DiT blocks
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class DiT(nn.Module):
|
|
94
|
+
def __init__(
|
|
95
|
+
self,
|
|
96
|
+
*,
|
|
97
|
+
dim,
|
|
98
|
+
depth=8,
|
|
99
|
+
heads=8,
|
|
100
|
+
dim_head=64,
|
|
101
|
+
dropout=0.1,
|
|
102
|
+
ff_mult=4,
|
|
103
|
+
mel_dim=100,
|
|
104
|
+
text_num_embeds=256,
|
|
105
|
+
text_dim=None,
|
|
106
|
+
conv_layers=0,
|
|
107
|
+
long_skip_connection=False,
|
|
108
|
+
):
|
|
109
|
+
super().__init__()
|
|
110
|
+
|
|
111
|
+
self.time_embed = TimestepEmbedding(dim)
|
|
112
|
+
if text_dim is None:
|
|
113
|
+
text_dim = mel_dim
|
|
114
|
+
self.text_embed = TextEmbedding(text_num_embeds, text_dim, conv_layers=conv_layers)
|
|
115
|
+
self.input_embed = InputEmbedding(mel_dim, text_dim, dim)
|
|
116
|
+
|
|
117
|
+
self.rotary_embed = RotaryEmbedding(dim_head)
|
|
118
|
+
|
|
119
|
+
self.dim = dim
|
|
120
|
+
self.depth = depth
|
|
121
|
+
|
|
122
|
+
self.transformer_blocks = nn.ModuleList(
|
|
123
|
+
[DiTBlock(dim=dim, heads=heads, dim_head=dim_head, ff_mult=ff_mult, dropout=dropout) for _ in range(depth)]
|
|
124
|
+
)
|
|
125
|
+
self.long_skip_connection = nn.Linear(dim * 2, dim, bias=False) if long_skip_connection else None
|
|
126
|
+
|
|
127
|
+
self.norm_out = AdaLayerNormZero_Final(dim) # final modulation
|
|
128
|
+
self.proj_out = nn.Linear(dim, mel_dim)
|
|
129
|
+
|
|
130
|
+
def forward(
|
|
131
|
+
self,
|
|
132
|
+
x: float["b n d"], # nosied input audio # noqa: F722
|
|
133
|
+
cond: float["b n d"], # masked cond audio # noqa: F722
|
|
134
|
+
text: int["b nt"], # text # noqa: F722
|
|
135
|
+
time: float["b"] | float[""], # time step # noqa: F821 F722
|
|
136
|
+
drop_audio_cond, # cfg for cond audio
|
|
137
|
+
drop_text, # cfg for text
|
|
138
|
+
mask: bool["b n"] | None = None, # noqa: F722
|
|
139
|
+
):
|
|
140
|
+
batch, seq_len = x.shape[0], x.shape[1]
|
|
141
|
+
if time.ndim == 0:
|
|
142
|
+
time = time.repeat(batch)
|
|
143
|
+
|
|
144
|
+
# t: conditioning time, c: context (text + masked cond audio), x: noised input audio
|
|
145
|
+
t = self.time_embed(time)
|
|
146
|
+
text_embed = self.text_embed(text, seq_len, drop_text=drop_text)
|
|
147
|
+
x = self.input_embed(x, cond, text_embed, drop_audio_cond=drop_audio_cond)
|
|
148
|
+
|
|
149
|
+
rope = self.rotary_embed.forward_from_seq_len(seq_len)
|
|
150
|
+
|
|
151
|
+
if self.long_skip_connection is not None:
|
|
152
|
+
residual = x
|
|
153
|
+
|
|
154
|
+
for block in self.transformer_blocks:
|
|
155
|
+
x = block(x, t, mask=mask, rope=rope)
|
|
156
|
+
|
|
157
|
+
if self.long_skip_connection is not None:
|
|
158
|
+
x = self.long_skip_connection(torch.cat((x, residual), dim=-1))
|
|
159
|
+
|
|
160
|
+
x = self.norm_out(x, t)
|
|
161
|
+
output = self.proj_out(x)
|
|
162
|
+
|
|
163
|
+
return output
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ein notation:
|
|
3
|
+
b - batch
|
|
4
|
+
n - sequence
|
|
5
|
+
nt - text sequence
|
|
6
|
+
nw - raw wave length
|
|
7
|
+
d - dimension
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import torch
|
|
13
|
+
from torch import nn
|
|
14
|
+
|
|
15
|
+
from x_transformers.x_transformers import RotaryEmbedding
|
|
16
|
+
|
|
17
|
+
from f5_tts.model.modules import (
|
|
18
|
+
TimestepEmbedding,
|
|
19
|
+
ConvPositionEmbedding,
|
|
20
|
+
MMDiTBlock,
|
|
21
|
+
AdaLayerNormZero_Final,
|
|
22
|
+
precompute_freqs_cis,
|
|
23
|
+
get_pos_embed_indices,
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# text embedding
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class TextEmbedding(nn.Module):
|
|
31
|
+
def __init__(self, out_dim, text_num_embeds):
|
|
32
|
+
super().__init__()
|
|
33
|
+
self.text_embed = nn.Embedding(text_num_embeds + 1, out_dim) # will use 0 as filler token
|
|
34
|
+
|
|
35
|
+
self.precompute_max_pos = 1024
|
|
36
|
+
self.register_buffer("freqs_cis", precompute_freqs_cis(out_dim, self.precompute_max_pos), persistent=False)
|
|
37
|
+
|
|
38
|
+
def forward(self, text: int["b nt"], drop_text=False) -> int["b nt d"]: # noqa: F722
|
|
39
|
+
text = text + 1
|
|
40
|
+
if drop_text:
|
|
41
|
+
text = torch.zeros_like(text)
|
|
42
|
+
text = self.text_embed(text)
|
|
43
|
+
|
|
44
|
+
# sinus pos emb
|
|
45
|
+
batch_start = torch.zeros((text.shape[0],), dtype=torch.long)
|
|
46
|
+
batch_text_len = text.shape[1]
|
|
47
|
+
pos_idx = get_pos_embed_indices(batch_start, batch_text_len, max_pos=self.precompute_max_pos)
|
|
48
|
+
text_pos_embed = self.freqs_cis[pos_idx]
|
|
49
|
+
|
|
50
|
+
text = text + text_pos_embed
|
|
51
|
+
|
|
52
|
+
return text
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# noised input & masked cond audio embedding
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class AudioEmbedding(nn.Module):
|
|
59
|
+
def __init__(self, in_dim, out_dim):
|
|
60
|
+
super().__init__()
|
|
61
|
+
self.linear = nn.Linear(2 * in_dim, out_dim)
|
|
62
|
+
self.conv_pos_embed = ConvPositionEmbedding(out_dim)
|
|
63
|
+
|
|
64
|
+
def forward(self, x: float["b n d"], cond: float["b n d"], drop_audio_cond=False): # noqa: F722
|
|
65
|
+
if drop_audio_cond:
|
|
66
|
+
cond = torch.zeros_like(cond)
|
|
67
|
+
x = torch.cat((x, cond), dim=-1)
|
|
68
|
+
x = self.linear(x)
|
|
69
|
+
x = self.conv_pos_embed(x) + x
|
|
70
|
+
return x
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# Transformer backbone using MM-DiT blocks
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class MMDiT(nn.Module):
|
|
77
|
+
def __init__(
|
|
78
|
+
self,
|
|
79
|
+
*,
|
|
80
|
+
dim,
|
|
81
|
+
depth=8,
|
|
82
|
+
heads=8,
|
|
83
|
+
dim_head=64,
|
|
84
|
+
dropout=0.1,
|
|
85
|
+
ff_mult=4,
|
|
86
|
+
text_num_embeds=256,
|
|
87
|
+
mel_dim=100,
|
|
88
|
+
):
|
|
89
|
+
super().__init__()
|
|
90
|
+
|
|
91
|
+
self.time_embed = TimestepEmbedding(dim)
|
|
92
|
+
self.text_embed = TextEmbedding(dim, text_num_embeds)
|
|
93
|
+
self.audio_embed = AudioEmbedding(mel_dim, dim)
|
|
94
|
+
|
|
95
|
+
self.rotary_embed = RotaryEmbedding(dim_head)
|
|
96
|
+
|
|
97
|
+
self.dim = dim
|
|
98
|
+
self.depth = depth
|
|
99
|
+
|
|
100
|
+
self.transformer_blocks = nn.ModuleList(
|
|
101
|
+
[
|
|
102
|
+
MMDiTBlock(
|
|
103
|
+
dim=dim,
|
|
104
|
+
heads=heads,
|
|
105
|
+
dim_head=dim_head,
|
|
106
|
+
dropout=dropout,
|
|
107
|
+
ff_mult=ff_mult,
|
|
108
|
+
context_pre_only=i == depth - 1,
|
|
109
|
+
)
|
|
110
|
+
for i in range(depth)
|
|
111
|
+
]
|
|
112
|
+
)
|
|
113
|
+
self.norm_out = AdaLayerNormZero_Final(dim) # final modulation
|
|
114
|
+
self.proj_out = nn.Linear(dim, mel_dim)
|
|
115
|
+
|
|
116
|
+
def forward(
|
|
117
|
+
self,
|
|
118
|
+
x: float["b n d"], # nosied input audio # noqa: F722
|
|
119
|
+
cond: float["b n d"], # masked cond audio # noqa: F722
|
|
120
|
+
text: int["b nt"], # text # noqa: F722
|
|
121
|
+
time: float["b"] | float[""], # time step # noqa: F821 F722
|
|
122
|
+
drop_audio_cond, # cfg for cond audio
|
|
123
|
+
drop_text, # cfg for text
|
|
124
|
+
mask: bool["b n"] | None = None, # noqa: F722
|
|
125
|
+
):
|
|
126
|
+
batch = x.shape[0]
|
|
127
|
+
if time.ndim == 0:
|
|
128
|
+
time = time.repeat(batch)
|
|
129
|
+
|
|
130
|
+
# t: conditioning (time), c: context (text + masked cond audio), x: noised input audio
|
|
131
|
+
t = self.time_embed(time)
|
|
132
|
+
c = self.text_embed(text, drop_text=drop_text)
|
|
133
|
+
x = self.audio_embed(x, cond, drop_audio_cond=drop_audio_cond)
|
|
134
|
+
|
|
135
|
+
seq_len = x.shape[1]
|
|
136
|
+
text_len = text.shape[1]
|
|
137
|
+
rope_audio = self.rotary_embed.forward_from_seq_len(seq_len)
|
|
138
|
+
rope_text = self.rotary_embed.forward_from_seq_len(text_len)
|
|
139
|
+
|
|
140
|
+
for block in self.transformer_blocks:
|
|
141
|
+
c, x = block(x, c, t, mask=mask, rope=rope_audio, c_rope=rope_text)
|
|
142
|
+
|
|
143
|
+
x = self.norm_out(x, t)
|
|
144
|
+
output = self.proj_out(x)
|
|
145
|
+
|
|
146
|
+
return output
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"""
|
|
2
|
+
ein notation:
|
|
3
|
+
b - batch
|
|
4
|
+
n - sequence
|
|
5
|
+
nt - text sequence
|
|
6
|
+
nw - raw wave length
|
|
7
|
+
d - dimension
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
from typing import Literal
|
|
12
|
+
|
|
13
|
+
import torch
|
|
14
|
+
from torch import nn
|
|
15
|
+
import torch.nn.functional as F
|
|
16
|
+
|
|
17
|
+
from x_transformers import RMSNorm
|
|
18
|
+
from x_transformers.x_transformers import RotaryEmbedding
|
|
19
|
+
|
|
20
|
+
from f5_tts.model.modules import (
|
|
21
|
+
TimestepEmbedding,
|
|
22
|
+
ConvNeXtV2Block,
|
|
23
|
+
ConvPositionEmbedding,
|
|
24
|
+
Attention,
|
|
25
|
+
AttnProcessor,
|
|
26
|
+
FeedForward,
|
|
27
|
+
precompute_freqs_cis,
|
|
28
|
+
get_pos_embed_indices,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# Text embedding
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class TextEmbedding(nn.Module):
|
|
36
|
+
def __init__(self, text_num_embeds, text_dim, conv_layers=0, conv_mult=2):
|
|
37
|
+
super().__init__()
|
|
38
|
+
self.text_embed = nn.Embedding(text_num_embeds + 1, text_dim) # use 0 as filler token
|
|
39
|
+
|
|
40
|
+
if conv_layers > 0:
|
|
41
|
+
self.extra_modeling = True
|
|
42
|
+
self.precompute_max_pos = 4096 # ~44s of 24khz audio
|
|
43
|
+
self.register_buffer("freqs_cis", precompute_freqs_cis(text_dim, self.precompute_max_pos), persistent=False)
|
|
44
|
+
self.text_blocks = nn.Sequential(
|
|
45
|
+
*[ConvNeXtV2Block(text_dim, text_dim * conv_mult) for _ in range(conv_layers)]
|
|
46
|
+
)
|
|
47
|
+
else:
|
|
48
|
+
self.extra_modeling = False
|
|
49
|
+
|
|
50
|
+
def forward(self, text: int["b nt"], seq_len, drop_text=False): # noqa: F722
|
|
51
|
+
text = text + 1 # use 0 as filler token. preprocess of batch pad -1, see list_str_to_idx()
|
|
52
|
+
text = text[:, :seq_len] # curtail if character tokens are more than the mel spec tokens
|
|
53
|
+
batch, text_len = text.shape[0], text.shape[1]
|
|
54
|
+
text = F.pad(text, (0, seq_len - text_len), value=0)
|
|
55
|
+
|
|
56
|
+
if drop_text: # cfg for text
|
|
57
|
+
text = torch.zeros_like(text)
|
|
58
|
+
|
|
59
|
+
text = self.text_embed(text) # b n -> b n d
|
|
60
|
+
|
|
61
|
+
# possible extra modeling
|
|
62
|
+
if self.extra_modeling:
|
|
63
|
+
# sinus pos emb
|
|
64
|
+
batch_start = torch.zeros((batch,), dtype=torch.long)
|
|
65
|
+
pos_idx = get_pos_embed_indices(batch_start, seq_len, max_pos=self.precompute_max_pos)
|
|
66
|
+
text_pos_embed = self.freqs_cis[pos_idx]
|
|
67
|
+
text = text + text_pos_embed
|
|
68
|
+
|
|
69
|
+
# convnextv2 blocks
|
|
70
|
+
text = self.text_blocks(text)
|
|
71
|
+
|
|
72
|
+
return text
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
# noised input audio and context mixing embedding
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class InputEmbedding(nn.Module):
|
|
79
|
+
def __init__(self, mel_dim, text_dim, out_dim):
|
|
80
|
+
super().__init__()
|
|
81
|
+
self.proj = nn.Linear(mel_dim * 2 + text_dim, out_dim)
|
|
82
|
+
self.conv_pos_embed = ConvPositionEmbedding(dim=out_dim)
|
|
83
|
+
|
|
84
|
+
def forward(self, x: float["b n d"], cond: float["b n d"], text_embed: float["b n d"], drop_audio_cond=False): # noqa: F722
|
|
85
|
+
if drop_audio_cond: # cfg for cond audio
|
|
86
|
+
cond = torch.zeros_like(cond)
|
|
87
|
+
|
|
88
|
+
x = self.proj(torch.cat((x, cond, text_embed), dim=-1))
|
|
89
|
+
x = self.conv_pos_embed(x) + x
|
|
90
|
+
return x
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
# Flat UNet Transformer backbone
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class UNetT(nn.Module):
|
|
97
|
+
def __init__(
|
|
98
|
+
self,
|
|
99
|
+
*,
|
|
100
|
+
dim,
|
|
101
|
+
depth=8,
|
|
102
|
+
heads=8,
|
|
103
|
+
dim_head=64,
|
|
104
|
+
dropout=0.1,
|
|
105
|
+
ff_mult=4,
|
|
106
|
+
mel_dim=100,
|
|
107
|
+
text_num_embeds=256,
|
|
108
|
+
text_dim=None,
|
|
109
|
+
conv_layers=0,
|
|
110
|
+
skip_connect_type: Literal["add", "concat", "none"] = "concat",
|
|
111
|
+
):
|
|
112
|
+
super().__init__()
|
|
113
|
+
assert depth % 2 == 0, "UNet-Transformer's depth should be even."
|
|
114
|
+
|
|
115
|
+
self.time_embed = TimestepEmbedding(dim)
|
|
116
|
+
if text_dim is None:
|
|
117
|
+
text_dim = mel_dim
|
|
118
|
+
self.text_embed = TextEmbedding(text_num_embeds, text_dim, conv_layers=conv_layers)
|
|
119
|
+
self.input_embed = InputEmbedding(mel_dim, text_dim, dim)
|
|
120
|
+
|
|
121
|
+
self.rotary_embed = RotaryEmbedding(dim_head)
|
|
122
|
+
|
|
123
|
+
# transformer layers & skip connections
|
|
124
|
+
|
|
125
|
+
self.dim = dim
|
|
126
|
+
self.skip_connect_type = skip_connect_type
|
|
127
|
+
needs_skip_proj = skip_connect_type == "concat"
|
|
128
|
+
|
|
129
|
+
self.depth = depth
|
|
130
|
+
self.layers = nn.ModuleList([])
|
|
131
|
+
|
|
132
|
+
for idx in range(depth):
|
|
133
|
+
is_later_half = idx >= (depth // 2)
|
|
134
|
+
|
|
135
|
+
attn_norm = RMSNorm(dim)
|
|
136
|
+
attn = Attention(
|
|
137
|
+
processor=AttnProcessor(),
|
|
138
|
+
dim=dim,
|
|
139
|
+
heads=heads,
|
|
140
|
+
dim_head=dim_head,
|
|
141
|
+
dropout=dropout,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
ff_norm = RMSNorm(dim)
|
|
145
|
+
ff = FeedForward(dim=dim, mult=ff_mult, dropout=dropout, approximate="tanh")
|
|
146
|
+
|
|
147
|
+
skip_proj = nn.Linear(dim * 2, dim, bias=False) if needs_skip_proj and is_later_half else None
|
|
148
|
+
|
|
149
|
+
self.layers.append(
|
|
150
|
+
nn.ModuleList(
|
|
151
|
+
[
|
|
152
|
+
skip_proj,
|
|
153
|
+
attn_norm,
|
|
154
|
+
attn,
|
|
155
|
+
ff_norm,
|
|
156
|
+
ff,
|
|
157
|
+
]
|
|
158
|
+
)
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
self.norm_out = RMSNorm(dim)
|
|
162
|
+
self.proj_out = nn.Linear(dim, mel_dim)
|
|
163
|
+
|
|
164
|
+
def forward(
|
|
165
|
+
self,
|
|
166
|
+
x: float["b n d"], # nosied input audio # noqa: F722
|
|
167
|
+
cond: float["b n d"], # masked cond audio # noqa: F722
|
|
168
|
+
text: int["b nt"], # text # noqa: F722
|
|
169
|
+
time: float["b"] | float[""], # time step # noqa: F821 F722
|
|
170
|
+
drop_audio_cond, # cfg for cond audio
|
|
171
|
+
drop_text, # cfg for text
|
|
172
|
+
mask: bool["b n"] | None = None, # noqa: F722
|
|
173
|
+
):
|
|
174
|
+
batch, seq_len = x.shape[0], x.shape[1]
|
|
175
|
+
if time.ndim == 0:
|
|
176
|
+
time = time.repeat(batch)
|
|
177
|
+
|
|
178
|
+
# t: conditioning time, c: context (text + masked cond audio), x: noised input audio
|
|
179
|
+
t = self.time_embed(time)
|
|
180
|
+
text_embed = self.text_embed(text, seq_len, drop_text=drop_text)
|
|
181
|
+
x = self.input_embed(x, cond, text_embed, drop_audio_cond=drop_audio_cond)
|
|
182
|
+
|
|
183
|
+
# postfix time t to input x, [b n d] -> [b n+1 d]
|
|
184
|
+
x = torch.cat([t.unsqueeze(1), x], dim=1) # pack t to x
|
|
185
|
+
if mask is not None:
|
|
186
|
+
mask = F.pad(mask, (1, 0), value=1)
|
|
187
|
+
|
|
188
|
+
rope = self.rotary_embed.forward_from_seq_len(seq_len + 1)
|
|
189
|
+
|
|
190
|
+
# flat unet transformer
|
|
191
|
+
skip_connect_type = self.skip_connect_type
|
|
192
|
+
skips = []
|
|
193
|
+
for idx, (maybe_skip_proj, attn_norm, attn, ff_norm, ff) in enumerate(self.layers):
|
|
194
|
+
layer = idx + 1
|
|
195
|
+
|
|
196
|
+
# skip connection logic
|
|
197
|
+
is_first_half = layer <= (self.depth // 2)
|
|
198
|
+
is_later_half = not is_first_half
|
|
199
|
+
|
|
200
|
+
if is_first_half:
|
|
201
|
+
skips.append(x)
|
|
202
|
+
|
|
203
|
+
if is_later_half:
|
|
204
|
+
skip = skips.pop()
|
|
205
|
+
if skip_connect_type == "concat":
|
|
206
|
+
x = torch.cat((x, skip), dim=-1)
|
|
207
|
+
x = maybe_skip_proj(x)
|
|
208
|
+
elif skip_connect_type == "add":
|
|
209
|
+
x = x + skip
|
|
210
|
+
|
|
211
|
+
# attention and feedforward blocks
|
|
212
|
+
x = attn(attn_norm(x), rope=rope, mask=mask) + x
|
|
213
|
+
x = ff(ff_norm(x)) + x
|
|
214
|
+
|
|
215
|
+
assert len(skips) == 0
|
|
216
|
+
|
|
217
|
+
x = self.norm_out(x)[:, 1:, :] # unpack t from x
|
|
218
|
+
|
|
219
|
+
return self.proj_out(x)
|