|
Download torch_models/README.md from Sucial/photon-models: direct link, hf CLI and curl.
- Browser
- Download file 4.52 kB
-
https://huggingface.co/Sucial/photon-models/resolve/main/torch_models/README.md
- Command line
-
hf download hf://Sucial/photon-models/torch_models/README.md
-
curl -L -o README.md https://huggingface.co/Sucial/photon-models/resolve/main/torch_models/README.md
4.52 kB
| # PyTorch 模型说明(pymss / MSST 可加载) | |
| 4 个 BS-RoFormer,权重命名遵循 **ZFTurbo MSST / pymss** 的约定,可直接 `load_state_dict(strict=True)`。 | |
| 每个模型一个文件夹:`.ckpt` + `config.yaml` + `metadata.json`。 | |
| --- | |
| ## 目录 | |
| ``` | |
| torch_models/ | |
| ├── voice2stem_v03_fp16c_t2/ | |
| │ ├── voice2stem_v03_fp16c_t2.ckpt 305 MB | |
| │ ├── config.yaml model_type: bs_roformer | |
| │ └── metadata.json 张量数 / dtype / 元素统计 | |
| ├── voicesep2stem_fp16c_t2/ 462 MB | |
| ├── drumsep_1.3/ 286 MB | |
| └── music4stemhq_fp16c_t2/ 478 MB ← 唯一没有 ONNX 版本的模型 | |
| ``` | |
| --- | |
| ## 四个模型是什么 | |
| | 模型 | 产品名 | 音轨 | dim | depth | stems | hop | | |
| |---|---|---|---|---|---|---| | |
| | `voice2stem_v03_fp16c_t2` | Voice - 2 Stems | **vocals**(伴奏为残差) | 512 | 12 | 1 | 441 | | |
| | `voicesep2stem_fp16c_t2` | Voice Separator | **speech / other**(见下方说明) | 512 | 12 | 2 | 441 | | |
| | `drumsep_1.3` | Drums - 5 Stems | kick / snare / toms / hihat / cymbals | 256 | 12 | 5 | 512 | | |
| | `music4stemhq_fp16c_t2` | Music - 4 Stems Ultra | drums / bass / vocals / other | 256 | 12 | 4 | 512 | | |
| 共同点:BS-RoFormer、62 个频带(正好是 MSST 默认的 `DEFAULT_FREQS_PER_BANDS`)、 | |
| `n_fft=2048`、`sample_rate=44100`、`chunk_size=352800`(8 秒)、`num_overlap=2`、`batch_size=1`。 | |
| > **关于 `voicesep2stem`** | |
| > 它只做「人声 / 其他」两路,不区分说话人。产品上的「6 人分离」是配合 | |
| > `redimnet_ptn_activity` + `speaker_activity_single_pass` 做说话人日志后按时序门控切出来的。 | |
| > 所以同时说话会串音。config 里音轨名暂用 `speech` / `other`。 | |
| --- | |
| ## 加载方式 | |
| ### pymss | |
| ```python | |
| import sys; sys.path.insert(0, r"E:\vs\pymss-core") | |
| from pymss_core.checkpoint import load_model_weights | |
| from pymss_core.modules.bs_roformer.bs_roformer import BSRoformer | |
| from pymss_core.modules.bs_roformer.common import DEFAULT_FREQS_PER_BANDS | |
| model = BSRoformer(dim=512, depth=12, stereo=True, num_stems=1, | |
| time_transformer_depth=1, freq_transformer_depth=1, | |
| dim_head=64, heads=8, freqs_per_bands=DEFAULT_FREQS_PER_BANDS, | |
| stft_n_fft=2048, stft_hop_length=441, stft_win_length=2048, | |
| mask_estimator_depth=2, mlp_expansion_factor=4, | |
| use_shared_bias=True) | |
| load_model_weights(model, | |
| r"E:\AI\models\torch_models\voice2stem_v03_fp16c_t2\voice2stem_v03_fp16c_t2.ckpt", | |
| strict=True) | |
| model.eval() | |
| ``` | |
| 各模型的参数差异(照 `config.yaml` 抄即可): | |
| | 模型 | dim | num_stems | use_shared_bias | stft_hop_length | | |
| |---|---|---|---|---| | |
| | voice2stem_v03 | 512 | 1 | `true` | 441 | | |
| | voicesep2stem | 512 | 2 | `true` | 441 | | |
| | drumsep | 256 | 5 | `false` | 512 | | |
| | music4stemhq | 256 | 4 | `false` | 512 | | |
| ### MSST | |
| 权重键名与 ZFTurbo MSST 的 `bs_roformer` 完全同源(`band_split.to_features.*`、 | |
| `mask_estimators.*.to_freqs.*`、`layers.N.M.layers.*`、`final_norm.gamma`、`linear_62_bias_0`), | |
| 所以同一份 `config.yaml` 可以直接给 MSST 的推理脚本用。 | |
| > 未实测 MSST 本体,但 pymss 的实现就是从 MSST 移植的,参数名一一对应。 | |
| --- | |
| ## ckpt 里是什么 | |
| ```python | |
| { | |
| "state_dict": OrderedDict[str, torch.Tensor], # 参数名与 BSRoformer 一致 | |
| "metadata": { # 从 .model4 带来的信息 | |
| "source_file", "num_tensors", "dtype_counts", | |
| "elements", "float_parameters", "safetensors_metadata" | |
| } | |
| } | |
| ``` | |
| - `pymss_core.checkpoint.unwrap_state_dict` 认 `state` / `state_dict` / `model_state_dict` 三种键名 | |
| - 原 dtype 保留(F32/F16/I64 混合),加载时会按模型参数 dtype 自动转换 | |
| - `weights_only=True` 的安全模式可正常加载 | |
| --- | |
| ## 注意事项 | |
| 1. **hop 必须对上**:`voice2stem` / `voicesep2stem` 是 441,`drumsep` / `music4stemhq` 是 512。 | |
| 写错会让输入帧数从 801 变成 689,模型照跑但结果全错。 | |
| 2. **这两个 voice 模型的 mask 数是 1 和 2**,`num_stems` 必须与 ckpt 里 `mask_estimators` 的数量一致。 | |
| 3. `music4stemhq` 的注意力多包了一层 `.branch.`,但只是命名差异,用标准 `BSRoformer` 即可加载。 | |
| 4. 前向未与 iZotope 官方输出做过 A/B,**能加载 ≠ 数值等价**。需要保真度时建议做「stems 相加 ≈ 原混音」的重构检查。 | |