pymss 2.3.4__tar.gz → 2.4.0__tar.gz
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.
- {pymss-2.3.4 → pymss-2.4.0}/PKG-INFO +28 -3
- {pymss-2.3.4 → pymss-2.4.0}/README.md +24 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/__init__.py +3 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/audio_io.py +68 -16
- pymss-2.4.0/pymss/backends.py +93 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/cli.py +5 -4
- {pymss-2.3.4 → pymss-2.4.0}/pymss/model_download.py +45 -6
- {pymss-2.3.4 → pymss-2.4.0}/pymss/model_registry.py +2 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/modules/vocal_remover/uvr_lib_v5/spec_utils.py +17 -9
- {pymss-2.3.4 → pymss-2.4.0}/pymss/modules/vocal_remover/vr_separator.py +13 -5
- pymss-2.4.0/pymss/plugins/gitcode.py +269 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/plugins/install.py +11 -3
- {pymss-2.3.4 → pymss-2.4.0}/pymss/plugins/manifest.py +4 -1
- {pymss-2.3.4 → pymss-2.4.0}/pymss/plugins/marketplace.py +7 -6
- {pymss-2.3.4 → pymss-2.4.0}/pymss/plugins/sources.py +16 -2
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/model_catalog.json +114 -60
- {pymss-2.3.4 → pymss-2.4.0}/pymss/separator.py +210 -17
- {pymss-2.3.4 → pymss-2.4.0}/pymss/utils.py +21 -14
- {pymss-2.3.4 → pymss-2.4.0}/pymss.egg-info/PKG-INFO +28 -3
- {pymss-2.3.4 → pymss-2.4.0}/pymss.egg-info/SOURCES.txt +9 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss.egg-info/requires.txt +5 -2
- {pymss-2.3.4 → pymss-2.4.0}/pymss_plugin_manager/_engine.py +3 -3
- {pymss-2.3.4 → pymss-2.4.0}/pyproject.toml +4 -3
- {pymss-2.3.4 → pymss-2.4.0}/test/test_audio_layout_metadata.py +4 -1
- {pymss-2.3.4 → pymss-2.4.0}/test/test_audio_resample.py +4 -1
- pymss-2.4.0/test/test_audio_tracks.py +150 -0
- pymss-2.4.0/test/test_backends.py +108 -0
- pymss-2.4.0/test/test_backends_musa.py +69 -0
- pymss-2.4.0/test/test_device_release_contracts.py +166 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_graph_resample_service.py +4 -1
- pymss-2.4.0/test/test_model_catalog_presentation.py +35 -0
- pymss-2.4.0/test/test_model_download_offline.py +134 -0
- pymss-2.4.0/test/test_plugin_gitcode.py +229 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_plugin_management.py +10 -4
- {pymss-2.3.4 → pymss-2.4.0}/test/test_plugin_marketplace.py +6 -5
- {pymss-2.3.4 → pymss-2.4.0}/test/test_plugin_sources.py +2 -2
- {pymss-2.3.4 → pymss-2.4.0}/test/test_separator_device_defaults.py +42 -0
- {pymss-2.3.4 → pymss-2.4.0}/LICENSE +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/__main__.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/_builtin_node_types.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/_identifiers.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/audio_services.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/config.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/ensemble.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/graph/__init__.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/graph/builtin_nodes.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/graph/comfy_loader.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/graph/core.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/graph/nodes.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/graph/runner.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/graph/yaml_compiler.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/logger.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/modules/__init__.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/modules/_core_shims.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/modules/vocal_remover/__init__.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/modules/vocal_remover/common_separator.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/modules/vocal_remover/uvr_lib_v5/__init__.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/modules/vocal_remover/vr_mlx.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/modules/vocal_remover/vr_models.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/__init__.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/_command_bootstrap.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/_command_process.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/_profile_lock.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/_python_entry.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/_rpc_session.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/builtins.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/command.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/files.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/graph_bridge.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/host_services.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/kit_builtins.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/python_profiles.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/operations/rpc_process.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/plugins/__init__.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/plugins/builtins.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/plugins/codecs.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/plugins/graph_ops.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/plugins/kit.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/plugins/lifecycle.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/plugins/loader.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/plugins/registry.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/plugins/service.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/progress.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/1band_sr16000_hl512.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/1band_sr32000_hl512.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/1band_sr33075_hl384.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/1band_sr44100_hl1024.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/1band_sr44100_hl256.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/1band_sr44100_hl512.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/1band_sr44100_hl512_cut.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/1band_sr44100_hl512_nf1024.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/2band_32000.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/2band_44100_lofi.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/2band_48000.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/3band_44100.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/3band_44100_mid.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/3band_44100_msb2.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/4band_44100.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/4band_44100_mid.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/4band_44100_msb.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/4band_44100_msb2.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/4band_44100_reverse.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/4band_44100_sw.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/4band_v2.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/4band_v2_sn.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/4band_v3.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/4band_v3_sn.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/resources/vr_modelparams/4band_v4_ms_fullband.json +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/__init__.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/app.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/audio.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/config.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/errors.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/models.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/state.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/webui.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/webui_static/assets/index-C2f3RgYK.js +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/webui_static/assets/index-Dd_kG96D.css +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/webui_static/assets/noto-sans-cyrillic-ext-wght-normal-DSNfmdVt.woff2 +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/webui_static/assets/noto-sans-cyrillic-wght-normal-B2hlT84T.woff2 +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/webui_static/assets/noto-sans-devanagari-wght-normal-Cv-Vwajv.woff2 +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/webui_static/assets/noto-sans-greek-ext-wght-normal-12T8GTDR.woff2 +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/webui_static/assets/noto-sans-greek-wght-normal-Ymb6dZNd.woff2 +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/webui_static/assets/noto-sans-latin-ext-wght-normal-W1qJv59z.woff2 +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/webui_static/assets/noto-sans-latin-wght-normal-BYSzYMf3.woff2 +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/webui_static/assets/noto-sans-vietnamese-wght-normal-DLTJy58D.woff2 +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/server/webui_static/index.html +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/user_models.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss/workflow.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss.egg-info/dependency_links.txt +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss.egg-info/entry_points.txt +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss.egg-info/top_level.txt +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss_plugin_manager/LICENSE +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss_plugin_manager/NOTICE +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss_plugin_manager/__init__.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss_plugin_manager/_platform.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss_plugin_manager/cli.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss_plugin_manager/context.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss_plugin_manager/environment.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss_plugin_manager/inventory.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss_plugin_manager/leases.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss_plugin_manager/locks.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss_plugin_manager/profiles.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/pymss_plugin_manager/service.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/setup.cfg +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_all.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_audio_downmix.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_audio_formats.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_audio_materialization.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_audio_services.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_builtin_capabilities.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_builtin_operations.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_codec_capabilities.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_command_bootstrap.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_command_operations.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_command_process.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_core_shims.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_graph.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_graph_audio_merge.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_graph_custom_models.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_graph_execution_events.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_graph_lifecycle.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_graph_runner_lifecycle.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_kit_builtins.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_legacy_loudnorm_node.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_mlx_warmup.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_model_catalog_overrides.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_model_detection.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_model_download_progress.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_npu_runtime.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_operation_graph_bridge.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_operation_invocation.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_operations.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_overlap_finalize.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_platform_queries.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_plugin_environment.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_plugin_kit.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_plugin_macos_attributes.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_plugin_node_contract.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_plugin_protocol.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_plugin_protocol_posix.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_plugins.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_polarformer.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_progress.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_python_profiles.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_rpc_declarations.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_rpc_process.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_separator_channels.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_use_amp.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_workflow.py +0 -0
- {pymss-2.3.4 → pymss-2.4.0}/test/test_xpu_runtime.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pymss
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: Python package for music source separation.
|
|
5
5
|
Author-email: KitsuneX07 <ghast1085654218@163.com>
|
|
6
6
|
Maintainer-email: baicai1145 <3423714059@qq.com>
|
|
@@ -26,10 +26,11 @@ Requires-Dist: av>=14
|
|
|
26
26
|
Requires-Dist: librosa>=0.10.2
|
|
27
27
|
Requires-Dist: numpy>=1.26
|
|
28
28
|
Requires-Dist: packaging>=24.0
|
|
29
|
-
Requires-Dist: pymss-core==0.1.
|
|
29
|
+
Requires-Dist: pymss-core==0.1.16
|
|
30
30
|
Requires-Dist: pyyaml>=6.0.1
|
|
31
|
-
Requires-Dist: torch>=2.
|
|
31
|
+
Requires-Dist: torch>=2.4
|
|
32
32
|
Requires-Dist: tqdm>=4.60
|
|
33
|
+
Requires-Dist: tomli>=2.0; python_version < "3.11"
|
|
33
34
|
Requires-Dist: mlx>=0.31.0; sys_platform == "darwin" and platform_machine == "arm64"
|
|
34
35
|
Provides-Extra: server
|
|
35
36
|
Requires-Dist: fastapi>=0.115; extra == "server"
|
|
@@ -111,6 +112,30 @@ If you need API or WebUI, install this instead:
|
|
|
111
112
|
pip install "pymss[server]"
|
|
112
113
|
```
|
|
113
114
|
|
|
115
|
+
### Chinese accelerators (Biren / Iluvatar / MetaX / Enflame / Hygon DCU / Cambricon MLU)
|
|
116
|
+
|
|
117
|
+
pymss runs on the domestic accelerator families too: Biren (BIRENSUPA), Iluvatar CoreX,
|
|
118
|
+
MetaX MACA, Enflame GCU, Hygon DCU and Cambricon MLU. They are pure-PyTorch targets -- pymss
|
|
119
|
+
ships no CUDA extensions -- so the only requirement is a vendor PyTorch build of **2.4 or newer**:
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
pip install --no-deps torch==<vendor build> # never let PyPI overwrite the vendor build
|
|
123
|
+
pip install --no-deps pymss
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
| Vendor | `--device` | Vendor torch |
|
|
127
|
+
| --- | --- | --- |
|
|
128
|
+
| Biren | `biren` (`supa`) | 2.4 - 2.8 (`torch_br`) |
|
|
129
|
+
| Iluvatar CoreX | `iluvatar` | 2.4.1 / 2.7.1 (`+corex`) |
|
|
130
|
+
| MetaX MACA | `metax` | 2.6 - 2.8 (`+metax`) |
|
|
131
|
+
| Enflame GCU | `enflame` (`gcu`) | 2.6 - 2.10 (`torch_gcu`) |
|
|
132
|
+
| Hygon DCU | `hygon` | 2.4.1 (`+das`, DTK 25.04) |
|
|
133
|
+
| Cambricon MLU | `mlu` | 2.4 (`torch_mlu`) |
|
|
134
|
+
| Moore Threads | `musa` (`moore`) | 2.7.1 (`torch_musa`) |
|
|
135
|
+
|
|
136
|
+
See [docs/cn-gpu.md](./docs/cn-gpu.md) for the full compatibility matrix, the capability flags that
|
|
137
|
+
replace hardcoded `device.type` checks, and the per-vendor verification checklist.
|
|
138
|
+
|
|
114
139
|
## Develop
|
|
115
140
|
|
|
116
141
|
Development requires Git, Python 3.11 or later, and [uv](https://docs.astral.sh/uv/). WebUI development also requires Node.js and npm.
|
|
@@ -71,6 +71,30 @@ If you need API or WebUI, install this instead:
|
|
|
71
71
|
pip install "pymss[server]"
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
+
### Chinese accelerators (Biren / Iluvatar / MetaX / Enflame / Hygon DCU / Cambricon MLU)
|
|
75
|
+
|
|
76
|
+
pymss runs on the domestic accelerator families too: Biren (BIRENSUPA), Iluvatar CoreX,
|
|
77
|
+
MetaX MACA, Enflame GCU, Hygon DCU and Cambricon MLU. They are pure-PyTorch targets -- pymss
|
|
78
|
+
ships no CUDA extensions -- so the only requirement is a vendor PyTorch build of **2.4 or newer**:
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
pip install --no-deps torch==<vendor build> # never let PyPI overwrite the vendor build
|
|
82
|
+
pip install --no-deps pymss
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
| Vendor | `--device` | Vendor torch |
|
|
86
|
+
| --- | --- | --- |
|
|
87
|
+
| Biren | `biren` (`supa`) | 2.4 - 2.8 (`torch_br`) |
|
|
88
|
+
| Iluvatar CoreX | `iluvatar` | 2.4.1 / 2.7.1 (`+corex`) |
|
|
89
|
+
| MetaX MACA | `metax` | 2.6 - 2.8 (`+metax`) |
|
|
90
|
+
| Enflame GCU | `enflame` (`gcu`) | 2.6 - 2.10 (`torch_gcu`) |
|
|
91
|
+
| Hygon DCU | `hygon` | 2.4.1 (`+das`, DTK 25.04) |
|
|
92
|
+
| Cambricon MLU | `mlu` | 2.4 (`torch_mlu`) |
|
|
93
|
+
| Moore Threads | `musa` (`moore`) | 2.7.1 (`torch_musa`) |
|
|
94
|
+
|
|
95
|
+
See [docs/cn-gpu.md](./docs/cn-gpu.md) for the full compatibility matrix, the capability flags that
|
|
96
|
+
replace hardcoded `device.type` checks, and the per-vendor verification checklist.
|
|
97
|
+
|
|
74
98
|
## Develop
|
|
75
99
|
|
|
76
100
|
Development requires Git, Python 3.11 or later, and [uv](https://docs.astral.sh/uv/). WebUI development also requires Node.js and npm.
|
|
@@ -24,6 +24,7 @@ Exports:
|
|
|
24
24
|
save_ensemble_audio: Ensemble multiple audio files and save the result.
|
|
25
25
|
WorkflowRunner: Run a multi-model audio workflow.
|
|
26
26
|
load_audio: Load an audio file into a NumPy array.
|
|
27
|
+
list_audio_tracks: List selectable audio streams and their metadata.
|
|
27
28
|
save_audio: Save a NumPy audio array to wav/flac/mp3/m4a.
|
|
28
29
|
|
|
29
30
|
Example:
|
|
@@ -67,6 +68,7 @@ _EXPORT_MODULES = {
|
|
|
67
68
|
"ensemble_audios": ".ensemble",
|
|
68
69
|
"save_ensemble_audio": ".ensemble",
|
|
69
70
|
"load_audio": ".audio_io",
|
|
71
|
+
"list_audio_tracks": ".audio_io",
|
|
70
72
|
"save_audio": ".audio_io",
|
|
71
73
|
"WorkflowRunner": ".workflow",
|
|
72
74
|
"load_workflow_file": ".workflow",
|
|
@@ -107,5 +109,6 @@ __all__ = (
|
|
|
107
109
|
"run_workflow_file",
|
|
108
110
|
"validate_workflow",
|
|
109
111
|
"load_audio",
|
|
112
|
+
"list_audio_tracks",
|
|
110
113
|
"save_audio",
|
|
111
114
|
)
|
|
@@ -125,14 +125,47 @@ def resample_audio(audio, orig_sr, target_sr):
|
|
|
125
125
|
return result[0] if mono else result
|
|
126
126
|
|
|
127
127
|
|
|
128
|
-
def
|
|
128
|
+
def _normalize_audio_track(audio_track):
|
|
129
|
+
if isinstance(audio_track, bool) or not isinstance(audio_track, int) or audio_track <= 0:
|
|
130
|
+
raise ValueError("audio_track must be a positive integer.")
|
|
131
|
+
return audio_track
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def list_audio_tracks(path):
|
|
135
|
+
"""Return audio-stream metadata in audio-stream (one-based) order.
|
|
136
|
+
|
|
137
|
+
``index`` intentionally refers to the audio stream's position, rather
|
|
138
|
+
than the container-wide stream index. It is therefore suitable for
|
|
139
|
+
passing directly to :func:`load_audio`.
|
|
140
|
+
|
|
141
|
+
Example:
|
|
142
|
+
>>> list_audio_tracks("concert.mkv")[0]["index"]
|
|
143
|
+
1
|
|
144
|
+
"""
|
|
145
|
+
tracks = []
|
|
146
|
+
with av.open(path) as container:
|
|
147
|
+
for index, stream in enumerate(container.streams.audio, start=1):
|
|
148
|
+
codec = stream.codec_context
|
|
149
|
+
metadata = stream.metadata or {}
|
|
150
|
+
tracks.append({
|
|
151
|
+
"index": index,
|
|
152
|
+
"language": str(metadata.get("language") or ""),
|
|
153
|
+
"title": str(metadata.get("title") or ""),
|
|
154
|
+
"channels": int(getattr(codec, "channels", 0) or 0),
|
|
155
|
+
"sampleRate": int(getattr(codec, "sample_rate", 0) or getattr(stream, "rate", 0) or 0),
|
|
156
|
+
"streamIndex": int(stream.index),
|
|
157
|
+
})
|
|
158
|
+
return tracks
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def _ffmpeg_audio_stream_info(path, audio_track=1):
|
|
129
162
|
"""Return basic audio stream information from ffprobe."""
|
|
130
163
|
command = [
|
|
131
164
|
"ffprobe",
|
|
132
165
|
"-v",
|
|
133
166
|
"error",
|
|
134
167
|
"-select_streams",
|
|
135
|
-
"a:
|
|
168
|
+
f"a:{_normalize_audio_track(audio_track) - 1}",
|
|
136
169
|
"-show_entries",
|
|
137
170
|
"stream=sample_rate,channels,channel_layout",
|
|
138
171
|
"-of",
|
|
@@ -147,16 +180,17 @@ def _ffmpeg_audio_stream_info(path):
|
|
|
147
180
|
return int(stream["sample_rate"]), int(stream["channels"]), stream.get("channel_layout")
|
|
148
181
|
|
|
149
182
|
|
|
150
|
-
def _load_audio_ffmpeg(path, sr=None, mono=False, offset=0.0, duration=None, downmix_stereo=False, return_layout=False):
|
|
183
|
+
def _load_audio_ffmpeg(path, sr=None, mono=False, offset=0.0, duration=None, downmix_stereo=False, return_layout=False, audio_track=1):
|
|
151
184
|
"""Load audio through the ffmpeg CLI as a fallback for damaged streams."""
|
|
152
|
-
|
|
185
|
+
audio_track = _normalize_audio_track(audio_track)
|
|
186
|
+
source_rate, source_channels, source_layout = _ffmpeg_audio_stream_info(path, audio_track)
|
|
153
187
|
out_rate = int(sr or source_rate)
|
|
154
188
|
channels = 1 if mono else (2 if downmix_stereo and source_channels > 2 else source_channels)
|
|
155
189
|
layout = "mono" if channels == 1 else ("stereo" if channels == 2 else source_layout)
|
|
156
190
|
command = ["ffmpeg", "-nostdin", "-v", "error"]
|
|
157
191
|
if offset:
|
|
158
192
|
command += ["-ss", str(float(offset))]
|
|
159
|
-
command += ["-i", str(path), "-map", "0:a:
|
|
193
|
+
command += ["-i", str(path), "-map", f"0:a:{audio_track - 1}", "-vn"]
|
|
160
194
|
if duration is not None:
|
|
161
195
|
command += ["-t", str(float(duration))]
|
|
162
196
|
if layout:
|
|
@@ -176,8 +210,11 @@ def _load_audio_ffmpeg(path, sr=None, mono=False, offset=0.0, duration=None, dow
|
|
|
176
210
|
return (audio, out_rate, layout) if return_layout else (audio, out_rate)
|
|
177
211
|
|
|
178
212
|
|
|
179
|
-
def _load_audio_librosa(path, sr=None, mono=False, offset=0.0, duration=None, downmix_stereo=False, return_layout=False):
|
|
213
|
+
def _load_audio_librosa(path, sr=None, mono=False, offset=0.0, duration=None, downmix_stereo=False, return_layout=False, audio_track=1):
|
|
180
214
|
"""Load audio through librosa as a fallback before the ffmpeg CLI."""
|
|
215
|
+
audio_track = _normalize_audio_track(audio_track)
|
|
216
|
+
if audio_track != 1:
|
|
217
|
+
raise ValueError("librosa cannot select a non-first audio stream.")
|
|
181
218
|
import librosa
|
|
182
219
|
|
|
183
220
|
audio, out_rate = librosa.load(
|
|
@@ -213,13 +250,17 @@ def _load_audio_librosa(path, sr=None, mono=False, offset=0.0, duration=None, do
|
|
|
213
250
|
return audio, int(out_rate), layout
|
|
214
251
|
|
|
215
252
|
|
|
216
|
-
def _load_audio_av(path, sr=None, mono=False, offset=0.0, duration=None, downmix_stereo=False, return_layout=False):
|
|
253
|
+
def _load_audio_av(path, sr=None, mono=False, offset=0.0, duration=None, downmix_stereo=False, return_layout=False, audio_track=1):
|
|
217
254
|
"""Load audio through PyAV."""
|
|
218
255
|
chunks = []
|
|
219
256
|
out_rate = None
|
|
220
257
|
output_layout = None
|
|
258
|
+
audio_track = _normalize_audio_track(audio_track)
|
|
221
259
|
with av.open(path) as container:
|
|
222
|
-
|
|
260
|
+
streams = container.streams.audio
|
|
261
|
+
if audio_track > len(streams):
|
|
262
|
+
raise ValueError(f"Audio track {audio_track} does not exist in {path!s}.")
|
|
263
|
+
stream = streams[audio_track - 1]
|
|
223
264
|
out_rate = int(sr or stream.rate)
|
|
224
265
|
resampler = None
|
|
225
266
|
stop_samples = None if duration is None else int(round((offset + duration) * out_rate))
|
|
@@ -253,7 +294,7 @@ def _load_audio_av(path, sr=None, mono=False, offset=0.0, duration=None, downmix
|
|
|
253
294
|
return (audio, out_rate, output_layout) if return_layout else (audio, out_rate)
|
|
254
295
|
|
|
255
296
|
|
|
256
|
-
def load_audio(path, sr=None, mono=False, offset=0.0, duration=None, *, downmix_stereo=False, return_layout=False):
|
|
297
|
+
def load_audio(path, sr=None, mono=False, offset=0.0, duration=None, *, downmix_stereo=False, return_layout=False, audio_track=1):
|
|
257
298
|
"""Load an audio file as float32 NumPy samples.
|
|
258
299
|
|
|
259
300
|
Audio decoding is attempted in this order: PyAV, librosa, then the
|
|
@@ -280,6 +321,8 @@ def load_audio(path, sr=None, mono=False, offset=0.0, duration=None, *, downmix_
|
|
|
280
321
|
a third return value. Defaults to False, preserving the usual
|
|
281
322
|
``(audio, sample_rate)`` pair. Unknown multichannel positions use
|
|
282
323
|
an unspecified layout such as ``"3 channels"``.
|
|
324
|
+
audio_track (int, optional): One-based audio-stream position to decode.
|
|
325
|
+
Defaults to 1. Invalid or unavailable tracks raise an error.
|
|
283
326
|
|
|
284
327
|
Returns:
|
|
285
328
|
tuple[np.ndarray, int]: Audio samples and sample rate. The array is
|
|
@@ -302,17 +345,26 @@ def load_audio(path, sr=None, mono=False, offset=0.0, duration=None, *, downmix_
|
|
|
302
345
|
... )
|
|
303
346
|
>>> clip.ndim
|
|
304
347
|
1"""
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
("
|
|
309
|
-
|
|
348
|
+
audio_track = _normalize_audio_track(audio_track)
|
|
349
|
+
loaders = [("PyAV", _load_audio_av)]
|
|
350
|
+
if audio_track == 1:
|
|
351
|
+
loaders.append(("librosa", _load_audio_librosa))
|
|
352
|
+
loaders.append(("ffmpeg CLI", _load_audio_ffmpeg))
|
|
310
353
|
|
|
311
354
|
errors = []
|
|
312
355
|
for name, loader in loaders:
|
|
313
356
|
try:
|
|
314
|
-
|
|
315
|
-
|
|
357
|
+
kwargs = {
|
|
358
|
+
"sr": sr,
|
|
359
|
+
"mono": mono,
|
|
360
|
+
"offset": offset,
|
|
361
|
+
"duration": duration,
|
|
362
|
+
"downmix_stereo": downmix_stereo,
|
|
363
|
+
"return_layout": return_layout,
|
|
364
|
+
}
|
|
365
|
+
if audio_track != 1:
|
|
366
|
+
kwargs["audio_track"] = audio_track
|
|
367
|
+
return loader(path, **kwargs)
|
|
316
368
|
except Exception as e:
|
|
317
369
|
errors.append(f"{name}: {e}")
|
|
318
370
|
continue
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"""Accelerator backend helpers.
|
|
2
|
+
|
|
3
|
+
pymss runs on CUDA, ROCm, Apple MPS/MLX, Ascend NPU, and the domestic
|
|
4
|
+
accelerator families (Biren, Iluvatar, MetaX, Enflame, Hygon DCU, Cambricon
|
|
5
|
+
MLU). Those SDKs disagree about how they surface to ``torch``: some add a
|
|
6
|
+
private device type (``npu``/``gcu``/``mlu``/``supa``), others impersonate CUDA.
|
|
7
|
+
:mod:`pymss_core.device` owns the detection matrix; this module is the thin
|
|
8
|
+
surface pymss itself uses so that no caller needs to hardcode ``device.type``
|
|
9
|
+
comparisons.
|
|
10
|
+
|
|
11
|
+
Example:
|
|
12
|
+
>>> from pymss.backends import install_recurrent_fallback, amp_supported
|
|
13
|
+
>>> install_recurrent_fallback("npu:0")
|
|
14
|
+
True
|
|
15
|
+
>>> amp_supported("cuda:0")
|
|
16
|
+
True
|
|
17
|
+
"""
|
|
18
|
+
from __future__ import annotations
|
|
19
|
+
|
|
20
|
+
from pymss_core.device import (
|
|
21
|
+
DEVICE_ALIASES,
|
|
22
|
+
DeviceProfile,
|
|
23
|
+
amp_supported,
|
|
24
|
+
autocast_dtype,
|
|
25
|
+
clear_device_cache,
|
|
26
|
+
detect_vendor,
|
|
27
|
+
device_profile,
|
|
28
|
+
dilated_conv_supported,
|
|
29
|
+
fft_fallback_required,
|
|
30
|
+
prepare_device_alias,
|
|
31
|
+
requires_plugin,
|
|
32
|
+
rnn_fallback_required,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
#: Values accepted by ``--device``; ``auto`` is resolved by the separator.
|
|
36
|
+
SUPPORTED_DEVICES: tuple[str, ...] = ("auto", *DEVICE_ALIASES)
|
|
37
|
+
|
|
38
|
+
__all__ = (
|
|
39
|
+
"SUPPORTED_DEVICES",
|
|
40
|
+
"DeviceProfile",
|
|
41
|
+
"amp_supported",
|
|
42
|
+
"autocast_dtype",
|
|
43
|
+
"clear_device_cache",
|
|
44
|
+
"detect_vendor",
|
|
45
|
+
"device_profile",
|
|
46
|
+
"fft_fallback_required",
|
|
47
|
+
"install_conv_fallback",
|
|
48
|
+
"install_recurrent_fallback",
|
|
49
|
+
"prepare_device_alias",
|
|
50
|
+
"requires_plugin",
|
|
51
|
+
"rnn_fallback_required",
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def install_conv_fallback(device) -> bool:
|
|
56
|
+
"""Install the CPU fallback for dilated convolutions when needed.
|
|
57
|
+
|
|
58
|
+
BIREN's SUDNN aborts the process (C++ exception -> ``terminate()``) on most
|
|
59
|
+
dilated convolutions, so affected calls are evaluated on CPU instead.
|
|
60
|
+
|
|
61
|
+
Args:
|
|
62
|
+
device: Device string, ``torch.device`` or tensor.
|
|
63
|
+
|
|
64
|
+
Returns:
|
|
65
|
+
``True`` when the fallback was installed.
|
|
66
|
+
"""
|
|
67
|
+
if dilated_conv_supported(device):
|
|
68
|
+
return False
|
|
69
|
+
from pymss_core.npu_conv import install_dilated_conv_fallback
|
|
70
|
+
|
|
71
|
+
install_dilated_conv_fallback()
|
|
72
|
+
return True
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def install_recurrent_fallback(device) -> bool:
|
|
76
|
+
"""Install the CPU recurrent fallback when ``device`` needs it.
|
|
77
|
+
|
|
78
|
+
Ascend NPU builds ship inference-incomplete ``npu_lstm``/``npu_gru``
|
|
79
|
+
kernels, and any future accelerator whose profile reports ``rnn=False``
|
|
80
|
+
hits the same wall. Native backends are left untouched.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
device: Device string, ``torch.device`` or tensor.
|
|
84
|
+
|
|
85
|
+
Returns:
|
|
86
|
+
``True`` when the fallback was installed.
|
|
87
|
+
"""
|
|
88
|
+
if not rnn_fallback_required(device):
|
|
89
|
+
return False
|
|
90
|
+
from pymss_core.npu_rnn import install_rnn_cpu_fallback
|
|
91
|
+
|
|
92
|
+
install_rnn_cpu_fallback()
|
|
93
|
+
return True
|
|
@@ -4,6 +4,7 @@ import os
|
|
|
4
4
|
import sys
|
|
5
5
|
import warnings
|
|
6
6
|
|
|
7
|
+
from .backends import SUPPORTED_DEVICES
|
|
7
8
|
from .ensemble import ENSEMBLE_ALGORITHMS, save_ensemble_audio
|
|
8
9
|
from .logger import get_separation_logger
|
|
9
10
|
from .model_download import download_all, download_model
|
|
@@ -855,7 +856,7 @@ def build_parser():
|
|
|
855
856
|
action="store_true",
|
|
856
857
|
help="Save each input audio file's separated stems in a subfolder named after the audio file.",
|
|
857
858
|
)
|
|
858
|
-
infer_parser.add_argument("--device", default="auto", choices=
|
|
859
|
+
infer_parser.add_argument("--device", default="auto", choices=list(SUPPORTED_DEVICES))
|
|
859
860
|
infer_parser.add_argument(
|
|
860
861
|
"--device-id", action="append", type=int, dest="device_ids", help="Accelerator device id. Can be repeated; XPU/NPU use the first."
|
|
861
862
|
)
|
|
@@ -975,7 +976,7 @@ def build_parser():
|
|
|
975
976
|
)
|
|
976
977
|
workflow_run_parser.add_argument("--source", default="modelscope", choices=["modelscope", "huggingface", "hf-mirror"])
|
|
977
978
|
workflow_run_parser.add_argument("--endpoint", help="Custom resolve endpoint. It must serve files by relative path.")
|
|
978
|
-
workflow_run_parser.add_argument("--device", choices=
|
|
979
|
+
workflow_run_parser.add_argument("--device", choices=list(SUPPORTED_DEVICES))
|
|
979
980
|
workflow_run_parser.add_argument("--format", choices=["wav", "flac", "mp3", "m4a"], dest="output_format")
|
|
980
981
|
workflow_run_parser.add_argument("--wav-bit-depth", default="FLOAT", choices=["FLOAT", "PCM_16", "PCM_24"])
|
|
981
982
|
workflow_run_parser.add_argument("--flac-bit-depth", default="PCM_16", choices=["PCM_16", "PCM_24"])
|
|
@@ -1018,7 +1019,7 @@ def build_parser():
|
|
|
1018
1019
|
comfy_run_parser.add_argument("--download", action="store_true", help="Download missing model files before running.")
|
|
1019
1020
|
comfy_run_parser.add_argument("--source", default="modelscope", choices=["modelscope", "huggingface", "hf-mirror"])
|
|
1020
1021
|
comfy_run_parser.add_argument("--endpoint", help="Custom resolve endpoint. It must serve files by relative path.")
|
|
1021
|
-
comfy_run_parser.add_argument("--device", choices=
|
|
1022
|
+
comfy_run_parser.add_argument("--device", choices=list(SUPPORTED_DEVICES))
|
|
1022
1023
|
comfy_run_parser.add_argument("--format", choices=["wav", "flac", "mp3", "m4a", "aac", "opus", "vorbis", "ogg"], dest="output_format")
|
|
1023
1024
|
comfy_run_parser.add_argument("--strict", dest="strict", action="store_true", default=True, help="Fail on unknown node types (default).")
|
|
1024
1025
|
comfy_run_parser.add_argument("--no-strict", dest="strict", action="store_false", help="Skip unknown node types with a warning.")
|
|
@@ -1046,7 +1047,7 @@ def build_parser():
|
|
|
1046
1047
|
)
|
|
1047
1048
|
serve_parser.add_argument("--source", default="modelscope", choices=["modelscope", "huggingface", "hf-mirror"])
|
|
1048
1049
|
serve_parser.add_argument("--endpoint", help="Custom resolve endpoint. It must serve files by relative path.")
|
|
1049
|
-
serve_parser.add_argument("--device", default="auto", choices=
|
|
1050
|
+
serve_parser.add_argument("--device", default="auto", choices=list(SUPPORTED_DEVICES))
|
|
1050
1051
|
serve_parser.add_argument(
|
|
1051
1052
|
"--device-id",
|
|
1052
1053
|
action="append",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import hashlib
|
|
2
2
|
import json
|
|
3
|
+
import logging
|
|
3
4
|
import os
|
|
4
5
|
import re
|
|
5
6
|
import shutil
|
|
@@ -338,7 +339,7 @@ def _already_valid(path, expected_size=None, expected_sha256=""):
|
|
|
338
339
|
|
|
339
340
|
Returns:
|
|
340
341
|
Any: Computed result."""
|
|
341
|
-
if not path.is_file():
|
|
342
|
+
if not path.is_file() or path.stat().st_size == 0:
|
|
342
343
|
return False
|
|
343
344
|
if expected_size is not None and path.stat().st_size != expected_size:
|
|
344
345
|
return False
|
|
@@ -373,6 +374,8 @@ def _validate_downloaded_file(path, dest, expected_size=None, expected_sha256=""
|
|
|
373
374
|
|
|
374
375
|
Returns:
|
|
375
376
|
None: This callable completes for its side effects."""
|
|
377
|
+
if path.stat().st_size == 0:
|
|
378
|
+
raise DownloadValidationError(f"empty download for {dest.name}")
|
|
376
379
|
if expected_size is not None and path.stat().st_size != expected_size:
|
|
377
380
|
raise DownloadValidationError(f"size mismatch for {dest.name}: expected {expected_size}, got {path.stat().st_size}")
|
|
378
381
|
if expected_sha256:
|
|
@@ -632,6 +635,23 @@ def files_for_model(model_name, model_dir=None):
|
|
|
632
635
|
return entry, files
|
|
633
636
|
|
|
634
637
|
|
|
638
|
+
def _catalog_size_and_hash(entry, relpath):
|
|
639
|
+
if relpath != getattr(entry, "relpath", None):
|
|
640
|
+
return None, ""
|
|
641
|
+
size = getattr(entry, "size_bytes", 0)
|
|
642
|
+
return (size if isinstance(size, int) and size > 0 else None), getattr(entry, "sha256", "") or ""
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
def _cached_model_is_usable(entry, files):
|
|
646
|
+
primary = getattr(entry, "relpath", None)
|
|
647
|
+
if not primary or not any(relpath == primary for relpath, _ in files):
|
|
648
|
+
return False
|
|
649
|
+
size, digest = _catalog_size_and_hash(entry, primary)
|
|
650
|
+
if size is None and not digest:
|
|
651
|
+
return False
|
|
652
|
+
return all(_already_valid(dest, *_catalog_size_and_hash(entry, relpath)) for relpath, dest in files)
|
|
653
|
+
|
|
654
|
+
|
|
635
655
|
def download_model(model_name, model_dir=None, source="modelscope", endpoint=None, verify=True, force=False, timeout=30, progress_callback=None, proxy=None):
|
|
636
656
|
"""Download all files required by one catalog model.
|
|
637
657
|
|
|
@@ -652,9 +672,12 @@ def download_model(model_name, model_dir=None, source="modelscope", endpoint=Non
|
|
|
652
672
|
endpoint (str | None, optional): Custom endpoint prefix. When provided,
|
|
653
673
|
the final URL is ``endpoint/relative/catalog/path`` and ``source``
|
|
654
674
|
is ignored for URL construction. Defaults to None.
|
|
655
|
-
verify (bool, optional):
|
|
656
|
-
|
|
657
|
-
|
|
675
|
+
verify (bool, optional): Validate using available size/hash metadata.
|
|
676
|
+
A usable local cache is reused without network access. ModelScope
|
|
677
|
+
index metadata is optional and is fetched only for that source.
|
|
678
|
+
Offline checks use the catalog's primary size/hash and require
|
|
679
|
+
non-empty config/auxiliary files; they cannot verify unknown hashes.
|
|
680
|
+
Custom endpoints skip catalog and source-index checks. Defaults to True.
|
|
658
681
|
force (bool, optional): Whether to redownload files even when existing
|
|
659
682
|
local files appear valid. Defaults to False.
|
|
660
683
|
timeout (int, optional): Network timeout in seconds. Defaults to 30.
|
|
@@ -691,13 +714,29 @@ def download_model(model_name, model_dir=None, source="modelscope", endpoint=Non
|
|
|
691
714
|
... timeout=60,
|
|
692
715
|
... )"""
|
|
693
716
|
entry, files = files_for_model(model_name, model_dir)
|
|
694
|
-
|
|
717
|
+
use_catalog = verify and endpoint is None
|
|
718
|
+
if use_catalog and not force and _cached_model_is_usable(entry, files):
|
|
719
|
+
return {"entry": entry, "downloaded": [], "skipped": [str(dest) for _, dest in files]}
|
|
720
|
+
index = None
|
|
721
|
+
if use_catalog and source == "modelscope":
|
|
722
|
+
try:
|
|
723
|
+
index = fetch_modelscope_file_index(timeout=timeout, proxy=proxy)
|
|
724
|
+
except (urllib.error.URLError, OSError, json.JSONDecodeError) as error:
|
|
725
|
+
logging.getLogger(__name__).warning(
|
|
726
|
+
"ModelScope file index is unavailable (%s); continuing with catalog metadata", type(error).__name__,
|
|
727
|
+
)
|
|
695
728
|
downloaded = []
|
|
696
729
|
skipped = []
|
|
697
730
|
|
|
698
731
|
for relpath, dest in files:
|
|
699
732
|
expected_size, expected_sha256 = _expected_size_and_hash(relpath, index)
|
|
700
|
-
if
|
|
733
|
+
if use_catalog:
|
|
734
|
+
size, digest = _catalog_size_and_hash(entry, relpath)
|
|
735
|
+
expected_size = expected_size if expected_size is not None else size
|
|
736
|
+
expected_sha256 = expected_sha256 or digest
|
|
737
|
+
can_reuse = (not use_catalog or expected_size is not None or bool(expected_sha256)
|
|
738
|
+
or relpath != getattr(entry, "relpath", None))
|
|
739
|
+
if not force and can_reuse and _already_valid(dest, expected_size, expected_sha256):
|
|
701
740
|
skipped.append(str(dest))
|
|
702
741
|
continue
|
|
703
742
|
url = remote_url(relpath, source=source, endpoint=endpoint)
|
|
@@ -46,6 +46,7 @@ class ModelEntry:
|
|
|
46
46
|
secondary_category_cn: str
|
|
47
47
|
target_stem: str
|
|
48
48
|
target_instrument_override: str = ""
|
|
49
|
+
sort_key: str = ""
|
|
49
50
|
|
|
50
51
|
@property
|
|
51
52
|
def stem(self):
|
|
@@ -95,6 +96,7 @@ class ModelEntry:
|
|
|
95
96
|
secondary_category_cn=data.get("secondary_category_cn", ""),
|
|
96
97
|
target_stem=data.get("target_stem", ""),
|
|
97
98
|
target_instrument_override=data.get("target_instrument_override", ""),
|
|
99
|
+
sort_key=data.get("sort_key", ""),
|
|
98
100
|
)
|
|
99
101
|
|
|
100
102
|
|
|
@@ -7,6 +7,8 @@ import librosa
|
|
|
7
7
|
import numpy as np
|
|
8
8
|
import torch
|
|
9
9
|
|
|
10
|
+
from pymss_core.device import device_profile, fft_fallback_required
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
ARM = "arm"
|
|
12
14
|
wav_resolution = (
|
|
@@ -201,14 +203,14 @@ def wave_to_spectrogram(wave, hop_length, n_fft, mp, band, is_v51_model=False, t
|
|
|
201
203
|
|
|
202
204
|
|
|
203
205
|
def _torch_stft(wave, n_fft, hop_length, device):
|
|
204
|
-
|
|
205
|
-
if device_type not in ("cuda", "npu", "xpu"):
|
|
206
|
+
if not device_profile(device).is_accelerator:
|
|
206
207
|
return None
|
|
208
|
+
fft_fallback = fft_fallback_required(device)
|
|
207
209
|
wave_t = torch.from_numpy(np.ascontiguousarray(wave)).to(device)
|
|
208
|
-
if
|
|
210
|
+
if fft_fallback:
|
|
209
211
|
wave_t = wave_t.float()
|
|
210
212
|
window = _hann_window(n_fft, wave_t.dtype, device)
|
|
211
|
-
if
|
|
213
|
+
if fft_fallback:
|
|
212
214
|
from pymss_core.npu_fft import stft_npu
|
|
213
215
|
|
|
214
216
|
spec = stft_npu(
|
|
@@ -230,17 +232,23 @@ def _torch_stft(wave, n_fft, hop_length, device):
|
|
|
230
232
|
pad_mode="constant",
|
|
231
233
|
return_complex=True,
|
|
232
234
|
)
|
|
233
|
-
|
|
235
|
+
# BIREN cannot copy complex tensors device->host; move the real planes instead.
|
|
236
|
+
from pymss_core.npu_fft import complex_to_numpy_cpu
|
|
237
|
+
|
|
238
|
+
return np.asfortranarray(complex_to_numpy_cpu(spec))
|
|
234
239
|
|
|
235
240
|
|
|
236
241
|
def _torch_istft(spec, hop_length, device):
|
|
237
|
-
|
|
238
|
-
if device_type not in ("cuda", "npu", "xpu"):
|
|
242
|
+
if not device_profile(device).is_accelerator:
|
|
239
243
|
return None
|
|
244
|
+
fft_fallback = fft_fallback_required(device)
|
|
240
245
|
n_fft = (spec.shape[1] - 1) * 2
|
|
241
|
-
|
|
246
|
+
from pymss_core.npu_fft import numpy_complex_to_device
|
|
247
|
+
|
|
248
|
+
# complex host->device copies are rejected by BIREN; send the real planes.
|
|
249
|
+
spec_t = numpy_complex_to_device(spec, device)
|
|
242
250
|
window = _hann_window(n_fft, spec_t.real.dtype, device)
|
|
243
|
-
if
|
|
251
|
+
if fft_fallback:
|
|
244
252
|
from pymss_core.npu_fft import istft_npu
|
|
245
253
|
|
|
246
254
|
wave = istft_npu(
|
|
@@ -10,9 +10,11 @@ from torch.nn.utils.fusion import fuse_conv_bn_eval
|
|
|
10
10
|
from tqdm import tqdm
|
|
11
11
|
|
|
12
12
|
from pymss_core.modules.vocal_remover import ModelParameters, determine_model_capacity
|
|
13
|
+
from pymss_core.npu_fft import masked_spectrum, numpy_complex_to_device
|
|
13
14
|
from pymss_core.modules.vocal_remover.uvr_lib_v5.vr_network import nets_new
|
|
14
15
|
|
|
15
|
-
from
|
|
16
|
+
from ...backends import device_profile
|
|
17
|
+
from ...utils import _autocast
|
|
16
18
|
|
|
17
19
|
from .common_separator import CommonSeparator
|
|
18
20
|
from .uvr_lib_v5 import spec_utils
|
|
@@ -101,7 +103,7 @@ class VRSeparator(CommonSeparator):
|
|
|
101
103
|
self.use_amp = bool(arch_config.get("use_amp", True))
|
|
102
104
|
device_type = torch.device(self.torch_device).type
|
|
103
105
|
self.fuse_conv_bn = bool(arch_config.get("fuse_conv_bn", False))
|
|
104
|
-
self.use_channels_last = bool(arch_config.get("use_channels_last", False)) and
|
|
106
|
+
self.use_channels_last = bool(arch_config.get("use_channels_last", False)) and device_profile(self.torch_device).channels_last
|
|
105
107
|
self.input_high_end_h = None
|
|
106
108
|
self.input_high_end = None
|
|
107
109
|
self.aggression = float(int(arch_config.get("aggression", 5)) / 100)
|
|
@@ -334,6 +336,9 @@ class VRSeparator(CommonSeparator):
|
|
|
334
336
|
if self.use_channels_last
|
|
335
337
|
else x_batch_cpu.to(device=device, non_blocking=True)
|
|
336
338
|
)
|
|
339
|
+
# One AMP policy for every caller: pymss.utils._autocast reads
|
|
340
|
+
# DeviceProfile.amp / amp_dtype, so BIREN gets bf16, XPU stays
|
|
341
|
+
# FP32, and CUDA/MPS keep fp16.
|
|
337
342
|
with _autocast(device, self.use_amp):
|
|
338
343
|
pred = self.model_run.predict_mask(x_batch)
|
|
339
344
|
if not pred.size()[3] > 0:
|
|
@@ -415,9 +420,12 @@ class VRSeparator(CommonSeparator):
|
|
|
415
420
|
return np.array(y_spec, copy=False), np.array(v_spec, copy=False)
|
|
416
421
|
|
|
417
422
|
mask = adjust_aggr_torch(mask, is_non_accom_stem)
|
|
418
|
-
x_spec_t =
|
|
419
|
-
|
|
420
|
-
|
|
423
|
+
x_spec_t = numpy_complex_to_device(x_spec, device)
|
|
424
|
+
# BIREN has no complex64 * float32 pointwise kernel, so the mask is
|
|
425
|
+
# applied on the real/imaginary planes (see npu_fft.masked_spectrum).
|
|
426
|
+
# to_cpu=True: BIREN cannot copy complex tensors device->host.
|
|
427
|
+
y_spec = masked_spectrum(mask, x_spec_t, to_cpu=True)
|
|
428
|
+
v_spec = masked_spectrum(1 - mask, x_spec_t, to_cpu=True)
|
|
421
429
|
return y_spec, v_spec
|
|
422
430
|
|
|
423
431
|
x_mag = np.abs(x_spec)
|