Skip to content

Optional evaluation/plotting dependencies are imported globally and can break inference setup #7

Description

@tapstoop

Some dependencies appear to be required only for evaluation metrics or plotting, but they are imported globally by modules used during inference.

This makes simple single-file inference fail unless optional packages are installed and pinned correctly.

Examples

ssr_eval

ssr_eval is used for evaluation metrics:

metrics = ssr_eval.metrics.AudioMetrics(rate=self.sampling_rate)

but it is imported globally:

import ssr_eval

This forces users to install ssr_eval even if they only want to run inference and do not need benchmark metrics.

moviepy

plotting_utils.py imports:

from moviepy.video.io.bindings import mplfig_to_npimage

This is required for plotting / logging utilities, but it can break inference if the installed MoviePy version is 2.x.

Suggested improvement

Use lazy imports for optional functionality.

For example:

def compute_eval_metrics(...):
    import ssr_eval
    ...

and:

def plot_spec_to_numpy(...):
    from moviepy.video.io.bindings import mplfig_to_npimage
    ...

This would allow simple inference to run with a smaller dependency set, simplify the installation and have less friction for users who only want audio restoration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions