Skip to content

Config

config

Configuration

Classes:

Name Description
LazyModelConfig

A lazily validated model configuration.

StftConfig

configuration for the short-time fourier transform.

LogMelConfig

Configuration for Log-Mel Spectrogram.

CqtConfig

Configuration for harmonic CQT feature extraction.

AudioIOConfig
TorchCompileConfig
InferenceConfig
NormalizationConfig
WaveformChunkingConfig
SequenceChunkingConfig
MaskingConfig
SubtractConfig
SumConfig
OutputConfig
ConfigOverrideError

Raised when one or more override strings are syntactically invalid.

Config
Model
Metrics
Resource
Comment
Registry

Functions:

Name Description
parse_override_value

Parse a CLI override value into a Python object.

parse_config_override

Parse one override entry of the form <dot.path>=<value>. Empty value

set_path_value

Set a nested value in-place, creating missing dictionaries as needed.

apply_config_overrides
load_config_dict
into_config

Convert various config inputs into a validated [Config].

Attributes:

Name Type Description
TorchDtype TypeAlias
Tuple
NonEmptyUnique
ModelInputStemName TypeAlias
ModelOutputStemName TypeAlias
FeatureExtractionConfig TypeAlias
DerivedStemName TypeAlias

The name of a derived stem, e.g. vocals_minus_drums.

StemName TypeAlias

A name of a stem, either a model output stem or a derived stem.

DerivedStemRule TypeAlias
DerivedStemsConfig TypeAlias
ConfigOverrides TypeAlias

<dot.path>=<value> form, e.g. inference.batch_size=2

IntoConfig TypeAlias

TorchDtype module-attribute

TorchDtype: TypeAlias = Annotated[
    dtype, GetPydanticSchema(_get_torch_dtype_schema)
]

Tuple module-attribute

Tuple = Annotated[
    tuple[_Item, ...], BeforeValidator(_to_tuple)
]

NonEmptyUnique module-attribute

NonEmptyUnique = Annotated[
    _S,
    Len(min_length=1),
    AfterValidator(_validate_unique_sequence),
    Field(json_schema_extra={"unique_items": True}),
]

ModelInputStemName module-attribute

ModelInputStemName: TypeAlias = Literal['mixture']

ModelOutputStemName module-attribute

ModelOutputStemName: TypeAlias = Annotated[
    ModelOutputStemName, StringConstraints(min_length=1)
]

LazyModelConfig

Bases: BaseModel

A lazily validated model configuration.

Note that it is not guaranteed to be fully valid until to_concrete is called.

Methods:

Name Description
to_concrete

Validate against a real set of model parameters and convert to it.

Attributes:

Name Type Description
chunk_size ChunkSize
output_stem_names NonEmptyUnique[Tuple[ModelOutputStemName]]
stem_names tuple[ModelInputStemName | ModelOutputStemName, ...]

Returns the model's input and output stem names.

model_config

chunk_size instance-attribute

chunk_size: ChunkSize

output_stem_names instance-attribute

output_stem_names: NonEmptyUnique[
    Tuple[ModelOutputStemName]
]

to_concrete

to_concrete(
    model_params: type[ModelParamsLikeT],
    *,
    pydantic_config: ConfigDict = ConfigDict(
        extra="forbid"
    ),
) -> ModelParamsLikeT

Validate against a real set of model parameters and convert to it.

Raises:

Type Description
pydantic.ValidationError

if extra fields are present in the model parameters that doesn't exist in the concrete model parameters.

Source code in src/splifft/config.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
def to_concrete(
    self,
    model_params: type[ModelParamsLikeT],
    *,
    pydantic_config: ConfigDict = ConfigDict(extra="forbid"),
) -> ModelParamsLikeT:
    """Validate against a real set of model parameters and convert to it.

    :raises pydantic.ValidationError: if extra fields are present in the model parameters
        that doesn't exist in the concrete model parameters.
    """
    # input_type and output_type are inconfigurable anyway
    # TODO: use lru cache to avoid recreating the TypeAdapter in a hot loop but dict isn't hashable
    ta = TypeAdapter(
        type(
            f"{model_params.__name__}Validator",
            (model_params,),
            {"__pydantic_config__": pydantic_config},
        )  # needed for https://docs.pydantic.dev/latest/errors/usage_errors/#type-adapter-config-unused
    )  # type: ignore
    # types defined within `TYPE_CHECKING` blocks will be forward references, so we need rebuild
    ta.rebuild(_types_namespace={"TorchDtype": TorchDtype, "t": t})
    model_params_concrete: ModelParamsLikeT = ta.validate_python(self.model_dump())
    return model_params_concrete

stem_names property

Returns the model's input and output stem names.

model_config class-attribute instance-attribute

model_config = ConfigDict(strict=True, extra='allow')

StftConfig

Bases: BaseModel

configuration for the short-time fourier transform.

Attributes:

Name Type Description
kind Literal['stft']
n_fft FftSize
hop_length HopSize
win_length FftSize
window_shape WindowShape
normalized bool
conv_dtype TorchDtype | None

The data type used for the conv1d buffers.

model_config

kind instance-attribute

kind: Literal['stft']

n_fft class-attribute instance-attribute

n_fft: FftSize = 2048

hop_length class-attribute instance-attribute

hop_length: HopSize = 512

win_length class-attribute instance-attribute

win_length: FftSize = 2048

window_shape class-attribute instance-attribute

window_shape: WindowShape = 'hann'

normalized class-attribute instance-attribute

normalized: bool = False

conv_dtype class-attribute instance-attribute

conv_dtype: TorchDtype | None = None

The data type used for the conv1d buffers.

model_config class-attribute instance-attribute

model_config = _PYDANTIC_STRICT_CONFIG

LogMelConfig

Bases: BaseModel

Configuration for Log-Mel Spectrogram.

Attributes:

Name Type Description
kind Literal['mel']
n_fft FftSize
hop_length HopSize
n_mels Gt0[int]
sample_rate SampleRate
f_min float
f_max float | None
mel_scale Literal['htk', 'slaney']
normalized bool | Literal['frame_length']
power float
log_multiplier float
model_config

kind instance-attribute

kind: Literal['mel']

n_fft instance-attribute

n_fft: FftSize

hop_length instance-attribute

hop_length: HopSize

n_mels instance-attribute

n_mels: Gt0[int]

sample_rate instance-attribute

sample_rate: SampleRate

f_min class-attribute instance-attribute

f_min: float = 0.0

f_max class-attribute instance-attribute

f_max: float | None = None

mel_scale class-attribute instance-attribute

mel_scale: Literal['htk', 'slaney'] = 'slaney'

normalized class-attribute instance-attribute

normalized: bool | Literal['frame_length'] = 'frame_length'

power class-attribute instance-attribute

power: float = 1.0

log_multiplier class-attribute instance-attribute

log_multiplier: float = 1000.0

model_config class-attribute instance-attribute

model_config = _PYDANTIC_STRICT_CONFIG

CqtConfig

Bases: BaseModel

Configuration for harmonic CQT feature extraction.

This intentionally matches PESTO's HCQT preprocessor defaults so we can share checkpoints without adding SciPy or nnAudio.

Attributes:

Name Type Description
kind Literal['cqt']
hop_size_ms float
harmonics NonEmptyUnique[Tuple[Gt0[int]]]
fmin float
fmax float | None
bins_per_semitone Gt0[int]
n_bins Gt0[int]
center_bins bool
gamma float
center bool
log_epsilon float
model_config

kind instance-attribute

kind: Literal['cqt']

hop_size_ms class-attribute instance-attribute

hop_size_ms: float = 10.0

harmonics class-attribute instance-attribute

harmonics: NonEmptyUnique[Tuple[Gt0[int]]] = (1,)

fmin class-attribute instance-attribute

fmin: float = 27.5

fmax class-attribute instance-attribute

fmax: float | None = None

bins_per_semitone class-attribute instance-attribute

bins_per_semitone: Gt0[int] = 3

n_bins class-attribute instance-attribute

n_bins: Gt0[int] = 251

center_bins class-attribute instance-attribute

center_bins: bool = True

gamma class-attribute instance-attribute

gamma: float = 7.0

center class-attribute instance-attribute

center: bool = True

log_epsilon class-attribute instance-attribute

log_epsilon: float = 1e-08

model_config class-attribute instance-attribute

model_config = _PYDANTIC_STRICT_CONFIG

FeatureExtractionConfig module-attribute

FeatureExtractionConfig: TypeAlias = Annotated[
    Union[StftConfig, LogMelConfig, CqtConfig],
    Discriminator("kind"),
]

AudioIOConfig

Bases: BaseModel

Attributes:

Name Type Description
target_sample_rate SampleRate
force_channels Channels | None

Whether to force mono or stereo audio input. If None, keep original.

model_config

target_sample_rate class-attribute instance-attribute

target_sample_rate: SampleRate = 44100

force_channels class-attribute instance-attribute

force_channels: Channels | None = 2

Whether to force mono or stereo audio input. If None, keep original.

model_config class-attribute instance-attribute

model_config = _PYDANTIC_STRICT_CONFIG

TorchCompileConfig

Bases: BaseModel

Attributes:

Name Type Description
fullgraph bool
dynamic bool
mode Literal['default', 'reduce-overhead', 'max-autotune', 'max-autotune-no-cudagraphs']

fullgraph class-attribute instance-attribute

fullgraph: bool = True

dynamic class-attribute instance-attribute

dynamic: bool = True

mode class-attribute instance-attribute

mode: Literal[
    "default",
    "reduce-overhead",
    "max-autotune",
    "max-autotune-no-cudagraphs",
] = "reduce-overhead"

InferenceConfig

Bases: BaseModel

Attributes:

Name Type Description
batch_size BatchSize
requested_stems NonEmptyUnique[Tuple[ModelOutputStemName]] | None

Optional subset of model output stems to compute and emit.

force_weights_dtype TorchDtype | None
use_autocast_dtype TorchDtype | None
model_device str | None

Device used for model forward execution.

io_device str | None

Device for audio IO and non-model tensor ops (chunking/stitching/output/normalization).

compile_model TorchCompileConfig | None
model_config

batch_size class-attribute instance-attribute

batch_size: BatchSize = 8

requested_stems class-attribute instance-attribute

requested_stems: (
    NonEmptyUnique[Tuple[ModelOutputStemName]] | None
) = None

Optional subset of model output stems to compute and emit.

When provided, inference only computes/keeps these model outputs in the configured order. Depending on the model architecture, this may allow specific stem-specific weights to be not loaded at all.

For example, the BS Roformer architecture has a shared backbone followed by multiple MLP heads, so setting this parameter can effectively patch out the unrelated heads.

force_weights_dtype class-attribute instance-attribute

force_weights_dtype: TorchDtype | None = None

use_autocast_dtype class-attribute instance-attribute

use_autocast_dtype: TorchDtype | None = None

model_device class-attribute instance-attribute

model_device: str | None = None

Device used for model forward execution.

If None, runtime auto-selects cuda when available, otherwise cpu.

io_device class-attribute instance-attribute

io_device: str | None = None

Device for audio IO and non-model tensor ops (chunking/stitching/output/normalization).

If None, runtime auto-selects cuda when available, otherwise cpu.

Note that switching io_device to CPU is expected to break bit-identical parity vs io_device="cuda" even with identical weights/seeds.

  • core.normalize_audio output/stat-mean (tiny CPU vs CUDA reduction drift)
  • core._get_window_fn (tiny kernel-level float differences)
  • core.generate_chunks and core.stitch_chunks may then differ bitwise

compile_model class-attribute instance-attribute

compile_model: TorchCompileConfig | None = None

model_config class-attribute instance-attribute

model_config = _PYDANTIC_STRICT_CONFIG

NormalizationConfig

Bases: BaseModel

Attributes:

Name Type Description
enabled bool
model_config

enabled class-attribute instance-attribute

enabled: bool = False

model_config class-attribute instance-attribute

model_config = _PYDANTIC_STRICT_CONFIG

WaveformChunkingConfig

Bases: BaseModel

Attributes:

Name Type Description
method Literal['overlap_add_windowed']
overlap_ratio OverlapRatio
window_shape WindowShape
padding_mode PaddingMode
model_config

method class-attribute instance-attribute

method: Literal["overlap_add_windowed"] = (
    "overlap_add_windowed"
)

overlap_ratio class-attribute instance-attribute

overlap_ratio: OverlapRatio = 0.5

window_shape class-attribute instance-attribute

window_shape: WindowShape = 'hann'

padding_mode class-attribute instance-attribute

padding_mode: PaddingMode = 'reflect'

model_config class-attribute instance-attribute

model_config = _PYDANTIC_STRICT_CONFIG

SequenceChunkingConfig

Bases: BaseModel

Attributes:

Name Type Description
trim_margin TrimMargin
overlap_mode OverlapMode
avoid_short_end bool
model_config

trim_margin class-attribute instance-attribute

trim_margin: TrimMargin = 0

overlap_mode class-attribute instance-attribute

overlap_mode: OverlapMode = 'keep_first'

avoid_short_end class-attribute instance-attribute

avoid_short_end: bool = True

model_config class-attribute instance-attribute

model_config = _PYDANTIC_STRICT_CONFIG

MaskingConfig

Bases: BaseModel

Attributes:

Name Type Description
add_sub_dtype TorchDtype | None
out_dtype TorchDtype | None
model_config

add_sub_dtype class-attribute instance-attribute

add_sub_dtype: TorchDtype | None = None

out_dtype class-attribute instance-attribute

out_dtype: TorchDtype | None = None

model_config class-attribute instance-attribute

model_config = _PYDANTIC_STRICT_CONFIG

DerivedStemName module-attribute

DerivedStemName: TypeAlias = Annotated[
    str, StringConstraints(min_length=1)
]

The name of a derived stem, e.g. vocals_minus_drums.

StemName module-attribute

A name of a stem, either a model output stem or a derived stem.

SubtractConfig

Bases: BaseModel

Attributes:

Name Type Description
operation Literal['subtract']
stem_name StemName
by_stem_name StemName
model_config

operation instance-attribute

operation: Literal['subtract']

stem_name instance-attribute

stem_name: StemName

by_stem_name instance-attribute

by_stem_name: StemName

model_config class-attribute instance-attribute

model_config = _PYDANTIC_STRICT_CONFIG

SumConfig

Bases: BaseModel

Attributes:

Name Type Description
operation Literal['sum']
stem_names NonEmptyUnique[Tuple[StemName]]
model_config

operation instance-attribute

operation: Literal['sum']

stem_names instance-attribute

model_config class-attribute instance-attribute

model_config = _PYDANTIC_STRICT_CONFIG

DerivedStemRule module-attribute

DerivedStemRule: TypeAlias = Annotated[
    Union[SubtractConfig, SumConfig],
    Discriminator("operation"),
]

DerivedStemsConfig module-attribute

DerivedStemsConfig: TypeAlias = dict[
    DerivedStemName, DerivedStemRule
]

OutputConfig

Bases: BaseModel

Attributes:

Name Type Description
stem_names Literal['all'] | NonEmptyUnique[Tuple[StemName]]
file_format FileFormat
bit_rate BitRate | None

Output bit rate for lossy formats. The default is chosen by FFmpeg.

model_config

stem_names class-attribute instance-attribute

stem_names: (
    Literal["all"] | NonEmptyUnique[Tuple[StemName]]
) = "all"

file_format class-attribute instance-attribute

file_format: FileFormat = 'flac'

bit_rate class-attribute instance-attribute

bit_rate: BitRate | None = None

Output bit rate for lossy formats. The default is chosen by FFmpeg.

model_config class-attribute instance-attribute

model_config = _PYDANTIC_STRICT_CONFIG

ConfigOverrideError

Bases: ValueError

Raised when one or more override strings are syntactically invalid.

parse_override_value

parse_override_value(value: str) -> Any

Parse a CLI override value into a Python object.

Shell-like quoting/escaping semantics beyond what your shell and JSON provide are not supported.

Source code in src/splifft/config.py
336
337
338
339
340
341
342
343
344
345
def parse_override_value(value: str) -> Any:
    """Parse a CLI override value into a Python object.

    Shell-like quoting/escaping semantics beyond what your shell and JSON provide
    are not supported.
    """
    try:
        return json.loads(value)
    except json.JSONDecodeError:
        return value

parse_config_override

parse_config_override(
    override: str,
) -> tuple[tuple[str, ...], Any]

Parse one override entry of the form <dot.path>=<value>. Empty value is interpreted as an empty string.

Missing = or empty path segments like a..b=1 or .a=1 are considered syntax errors

Source code in src/splifft/config.py
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
def parse_config_override(override: str) -> tuple[tuple[str, ...], Any]:
    """Parse one override entry of the form `<dot.path>=<value>`. Empty value
    is interpreted as an empty string.

    Missing `=` or empty path segments like `a..b=1` or `.a=1` are considered syntax errors
    """
    key, sep, raw_value = override.partition("=")
    if sep == "":
        raise ConfigOverrideError(
            "invalid override `"
            f"{override}`: expected `<dot.path>=<value>`, e.g. `inference.batch_size=2`"
        )

    path = tuple(part.strip() for part in key.split("."))
    if not path or any(part == "" for part in path):
        raise ConfigOverrideError(
            f"invalid override path `{key}` in `{override}`: empty path segment is not allowed"
        )

    return path, parse_override_value(raw_value)

set_path_value

set_path_value(
    mut_config_dict: dict[str, Any],
    path: tuple[str, ...],
    value: Any,
) -> None

Set a nested value in-place, creating missing dictionaries as needed.

Source code in src/splifft/config.py
370
371
372
373
374
375
376
377
378
379
380
def set_path_value(mut_config_dict: dict[str, Any], path: tuple[str, ...], value: Any) -> None:
    """Set a nested value in-place, creating missing dictionaries as needed."""
    current = mut_config_dict
    for key in path[:-1]:
        next_node = current.get(key)
        if not isinstance(next_node, dict):
            next_node = {}
            current[key] = next_node
        current = next_node

    current[path[-1]] = value

ConfigOverrides module-attribute

ConfigOverrides: TypeAlias = Sequence[str]

<dot.path>=<value> form, e.g. inference.batch_size=2

  • automatic creation of missing nested dictionaries while applying overrides
  • validation is performed after all overrides are applied

Not supported: list index addressing in paths (e.g. a.0.b=1 is treated as string keys)

apply_config_overrides

apply_config_overrides(
    mut_config_dict: dict[str, Any],
    overrides: ConfigOverrides,
) -> dict[str, Any]
Source code in src/splifft/config.py
393
394
395
396
397
398
399
def apply_config_overrides(
    mut_config_dict: dict[str, Any], overrides: ConfigOverrides
) -> dict[str, Any]:
    for override in overrides:
        path, value = parse_config_override(override)
        set_path_value(mut_config_dict, path, value)
    return mut_config_dict

load_config_dict

load_config_dict(
    path: StrPath | BytesPath,
) -> dict[str, Any]
Source code in src/splifft/config.py
402
403
404
405
406
407
def load_config_dict(path: t.StrPath | t.BytesPath) -> dict[str, Any]:
    with open(path, "rb") as f:
        data = json.load(f)
    if not isinstance(data, dict):
        raise TypeError(f"expected top-level JSON object in config file, got {type(data).__name__}")
    return data

Config

Bases: BaseModel

Methods:

Name Description
check_derived_stems
check_requested_stems
validate_inference_contract
from_file

Load config JSON from disk, optionally applying CLI-style overrides.

Attributes:

Name Type Description
identifier str

Unique identifier for this configuration

model_type ModelType
model LazyModelConfig
transform FeatureExtractionConfig | None
audio_io AudioIOConfig
inference InferenceConfig
normalization NormalizationConfig
waveform_chunking WaveformChunkingConfig | None
sequence_chunking SequenceChunkingConfig | None
masking MaskingConfig
derived_stems DerivedStemsConfig | None
output OutputConfig
experimental dict[str, Any] | None

Any extra experimental configurations outside of the splifft core.

model_config

identifier instance-attribute

identifier: str

Unique identifier for this configuration

model_type instance-attribute

model_type: ModelType

model instance-attribute

transform class-attribute instance-attribute

transform: FeatureExtractionConfig | None = None

audio_io class-attribute instance-attribute

audio_io: AudioIOConfig = Field(
    default_factory=AudioIOConfig
)

inference class-attribute instance-attribute

inference: InferenceConfig = Field(
    default_factory=InferenceConfig
)

normalization class-attribute instance-attribute

normalization: NormalizationConfig = Field(
    default_factory=NormalizationConfig
)

waveform_chunking class-attribute instance-attribute

waveform_chunking: WaveformChunkingConfig | None = None

sequence_chunking class-attribute instance-attribute

sequence_chunking: SequenceChunkingConfig | None = None

masking class-attribute instance-attribute

masking: MaskingConfig = Field(
    default_factory=MaskingConfig
)

derived_stems class-attribute instance-attribute

derived_stems: DerivedStemsConfig | None = None

output class-attribute instance-attribute

output: OutputConfig = Field(default_factory=OutputConfig)

experimental class-attribute instance-attribute

experimental: dict[str, Any] | None = None

Any extra experimental configurations outside of the splifft core.

check_derived_stems

check_derived_stems() -> Self
Source code in src/splifft/config.py
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
@model_validator(mode="after")
def check_derived_stems(self) -> Self:
    if self.derived_stems is None:
        return self

    base_output_stems = tuple(self.inference.requested_stems or self.model.output_stem_names)
    existing_stem_names: list[StemName] = [*_INPUT_STEM_NAMES, *base_output_stems]
    for derived_stem_name, definition in self.derived_stems.items():
        if derived_stem_name in existing_stem_names:
            raise PydanticCustomError(
                "derived_stem_name_conflict",
                "Derived stem `{derived_stem_name}` must not conflict with existing stem names: `{existing_stem_names}`",
                {
                    "derived_stem_name": derived_stem_name,
                    "existing_stem_names": existing_stem_names,
                },
            )
        required_stems: tuple[StemName, ...] = tuple()
        if isinstance(definition, SubtractConfig):
            required_stems = (definition.stem_name, definition.by_stem_name)
        elif isinstance(definition, SumConfig):
            required_stems = definition.stem_names
        for stem_name in required_stems:
            if stem_name not in existing_stem_names:
                raise PydanticCustomError(
                    "invalid_derived_stem",
                    "Derived stem `{derived_stem_name}` requires stem `{stem_name}` but is not found in `{existing_stem_names}`",
                    {
                        "derived_stem_name": derived_stem_name,
                        "stem_name": stem_name,
                        "existing_stem_names": existing_stem_names,
                    },
                )
        existing_stem_names.append(derived_stem_name)
    return self

check_requested_stems

check_requested_stems() -> Self
Source code in src/splifft/config.py
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
@model_validator(mode="after")
def check_requested_stems(self) -> Self:
    if self.inference.requested_stems is None:
        return self

    model_stem_names = set(self.model.output_stem_names)
    for stem_name in self.inference.requested_stems:
        if stem_name in model_stem_names:
            continue
        raise PydanticCustomError(
            "invalid_target_stem",
            "Target stem `{stem_name}` is not found in model output stems: `{model_stem_names}`",
            {
                "stem_name": stem_name,
                "model_stem_names": self.model.output_stem_names,
            },
        )

    return self

validate_inference_contract

validate_inference_contract(
    model_params: ModelParamsLike,
) -> InferenceArchetype
Source code in src/splifft/config.py
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
def validate_inference_contract(self, model_params: ModelParamsLike) -> t.InferenceArchetype:
    archetype = model_params.inference_archetype
    input_type = model_params.input_type
    output_type = model_params.output_type

    if archetype == "standard_end_to_end":
        if self.waveform_chunking is None:
            raise ValueError("`waveform_chunking` is required for standard_end_to_end pipeline")
        if output_type != "waveform":
            raise ValueError(
                f"standard_end_to_end expects waveform model output, got {output_type}"
            )
    elif archetype == "frequency_masking":
        if self.transform is None or self.transform.kind != "stft":
            raise ValueError(
                '`transform` with `kind="stft"` is required for frequency_masking pipeline'
            )
        if self.waveform_chunking is None:
            raise ValueError("`waveform_chunking` is required for frequency_masking pipeline")
        if input_type not in {"spectrogram", "waveform_and_spectrogram"}:
            raise ValueError(
                f"frequency_masking expects spectrogram-like model input, got {input_type}"
            )
        if output_type not in {"spectrogram_mask", "spectrogram"}:
            raise ValueError(
                f"frequency_masking expects spectrogram-like model output, got {output_type}"
            )
    elif archetype == "sequence_labeling":
        if self.sequence_chunking is None:
            raise ValueError("`sequence_chunking` is required for sequence_labeling pipeline")
        if input_type == "spectrogram" and self.transform is None:
            raise ValueError("spectrogram sequence models require `transform` to be configured")
        if input_type not in {"spectrogram", "waveform"}:
            raise ValueError(
                f"sequence_labeling expects spectrogram or waveform model input, got {input_type}"
            )
        if output_type not in {"logits", "multi_stream"}:
            raise ValueError(
                f"sequence_labeling expects logits or multi_stream model output, got {output_type}"
            )
    else:
        raise ValueError(f"unknown inference archetype: {archetype}")

    if output_type in {"logits", "multi_stream"} and self.output.file_format != "npy":
        raise ValueError(
            f"sequence models require output.file_format='npy', got {self.output.file_format!r}"
        )
    if output_type not in {"logits", "multi_stream"} and self.output.file_format == "npy":
        raise ValueError("waveform/spectrogram models cannot use output.file_format='npy'")

    return archetype

from_file classmethod

from_file(
    path: StrPath | BytesPath,
    *,
    overrides: ConfigOverrides = (),
) -> Config

Load config JSON from disk, optionally applying CLI-style overrides.

Source code in src/splifft/config.py
539
540
541
542
543
544
545
546
547
548
549
550
@classmethod
def from_file(
    cls,
    path: t.StrPath | t.BytesPath,
    *,
    overrides: ConfigOverrides = (),
) -> Config:
    """Load config JSON from disk, optionally applying CLI-style overrides."""
    config_dict = load_config_dict(path)
    if overrides:
        apply_config_overrides(config_dict, overrides)
    return cls.model_validate(config_dict)

model_config class-attribute instance-attribute

model_config = ConfigDict(
    arbitrary_types_allowed=True,
    strict=True,
    extra="forbid",
)

IntoConfig module-attribute

IntoConfig: TypeAlias = (
    Config | dict[str, Any] | StrPath | BytesPath
)

into_config

into_config(
    config: IntoConfig, *, overrides: ConfigOverrides = ()
) -> Config

Convert various config inputs into a validated [Config].

If overrides is non-empty, they are applied before validation. Caller-owned objects are not mutated.

Source code in src/splifft/config.py
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
def into_config(config: IntoConfig, *, overrides: ConfigOverrides = ()) -> Config:
    """Convert various config inputs into a validated [`Config`].

    If `overrides` is non-empty, they are applied before validation.
    Caller-owned objects are not mutated.
    """
    if isinstance(config, Config):
        if not overrides:
            return config
        config_dict = config.model_dump(mode="python")
        apply_config_overrides(config_dict, overrides)
        return Config.model_validate(config_dict)

    if isinstance(config, dict):
        config_dict = copy.deepcopy(config)
        if overrides:
            apply_config_overrides(config_dict, overrides)
        return Config.model_validate(config_dict)

    return Config.from_file(config, overrides=overrides)

Model

Bases: BaseModel

Attributes:

Name Type Description
authors list[str]
purpose Literal['separation', 'denoise', 'debleed', 'dereverb', 'decrowd', 'beat_tracking'] | str
architecture Literal['bs_roformer', 'mel_roformer', 'mdx23c', 'scnet', 'beat_this'] | str
config_id str | None

The default configuration identifier (filename stem) to use if one is not provided.

created_at str | None

ISO8601 date, time is optional (e.g. YYYY-MM-DD)

output NonEmptyUnique[list[Instrument]]
status Literal['tested'] | None
metrics list[Metrics]
description list[Comment]
resources list[Resource]
model_size int | None

Model size in bytes, if available.

authors instance-attribute

authors: list[str]

purpose instance-attribute

purpose: (
    Literal[
        "separation",
        "denoise",
        "debleed",
        "dereverb",
        "decrowd",
        "beat_tracking",
    ]
    | str
)

architecture instance-attribute

architecture: (
    Literal[
        "bs_roformer",
        "mel_roformer",
        "mdx23c",
        "scnet",
        "beat_this",
    ]
    | str
)

config_id class-attribute instance-attribute

config_id: str | None = None

The default configuration identifier (filename stem) to use if one is not provided. Files are expected to be in data/config.

If None, the model is not officially supported.

created_at class-attribute instance-attribute

created_at: str | None = None

ISO8601 date, time is optional (e.g. YYYY-MM-DD)

output class-attribute instance-attribute

output: NonEmptyUnique[list[Instrument]] = Field(
    default_factory=list
)

status class-attribute instance-attribute

status: Literal['tested'] | None = None

metrics class-attribute instance-attribute

metrics: list[Metrics] = Field(default_factory=list)

description class-attribute instance-attribute

description: list[Comment] = Field(default_factory=list)

resources class-attribute instance-attribute

resources: list[Resource] = Field(default_factory=list)

model_size class-attribute instance-attribute

model_size: int | None = None

Model size in bytes, if available.

Metrics

Bases: BaseModel

Attributes:

Name Type Description
values dict[Instrument, dict[Metric, float]]
source Literal['mvsep'] | str | None

values class-attribute instance-attribute

values: dict[Instrument, dict[Metric, float]] = Field(
    default_factory=dict
)

source class-attribute instance-attribute

source: Literal['mvsep'] | str | None = None

Resource

Bases: BaseModel

Attributes:

Name Type Description
kind Literal['model_ckpt', 'config_msst', 'arxiv', 'other']
url str
digest str | None

kind instance-attribute

kind: Literal["model_ckpt", "config_msst", "arxiv", "other"]

url instance-attribute

url: str

digest class-attribute instance-attribute

digest: str | None = None

Comment

Bases: BaseModel

Attributes:

Name Type Description
content list[str]

Condensed informative points of the model (lowercase)

author str | None

content instance-attribute

content: list[str]

Condensed informative points of the model (lowercase)

author class-attribute instance-attribute

author: str | None = None

Registry

Bases: dict[Identifier, Model]

Methods:

Name Description
__get_pydantic_core_schema__
from_file

__get_pydantic_core_schema__ classmethod

__get_pydantic_core_schema__(
    source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema
Source code in src/splifft/config.py
643
644
645
646
647
@classmethod
def __get_pydantic_core_schema__(
    cls, source_type: Any, handler: GetCoreSchemaHandler
) -> CoreSchema:
    return core_schema.no_info_after_validator_function(cls, handler(dict[t.Identifier, Model]))

from_file classmethod

from_file(path: StrPath | BytesPath) -> Registry
Source code in src/splifft/config.py
649
650
651
652
653
654
@classmethod
def from_file(cls, path: t.StrPath | t.BytesPath) -> Registry:
    with open(path, "r") as f:
        data = f.read()
    ta = TypeAdapter(cls)
    return ta.validate_json(data)