Skip to content

simet.pipeline.simple_pipeline

simet.pipeline.simple_pipeline

SimplePipeline

SimplePipeline(loader, metrics=None)

Minimal pipeline that loads two folders and computes selected metrics.

This pipeline wires a :class:DatasetLoader with two local providers (parsed from filesystem paths) and computes one or more metrics. If no metrics are specified, it defaults to running FID, RocAuc, and PrecisionRecall in that order.

Expected YAML structure for :meth:from_yaml:

pipeline:
  real_path: data/real_images
  synth_path: data/synth_images
  metrics:        # optional; defaults to ["FID", "RocAuc", "PrecisionRecall"]
    - FID
    - RocAuc
    - PrecisionRecall

Attributes:

Name Type Description
loader DatasetLoader

Loader built from the two provided paths.

metrics list[Metric]

Metrics to compute; defaults to [FID, RocAuc, PrecisionRecall].

Example

sp = SimplePipeline.from_yaml(Path("simple.yaml")) sp.run() # computes each metric and logs the results

Initialize the simple pipeline.

Parameters:

Name Type Description Default
loader DatasetLoader

Prepared dataset loader (constructed from two providers).

required
metrics list[Metric] | None

Optional list of metric instances. If None, falls back to [FID(), RocAuc(), PrecisionRecall()].

None
Source code in simet/pipeline/simple_pipeline.py
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
def __init__(
    self, loader: DatasetLoader, metrics: list[Metric] | None = None
) -> None:
    """Initialize the simple pipeline.

    Args:
        loader: Prepared dataset loader (constructed from two providers).
        metrics: Optional list of metric instances. If ``None``, falls back to
            ``[FID(), RocAuc(), PrecisionRecall()]``.
    """
    self.loader = loader
    self.metrics = metrics or [
        FID(),
        RocAuc(),
        PrecisionRecall(),
    ]

from_yaml classmethod

from_yaml(config_path)

Build a simple pipeline from a YAML file.

Parameters:

Name Type Description Default
config_path Path

Path to a YAML file with the structure shown in the class docstring.

required

Returns:

Name Type Description
SimplePipeline SimplePipeline

A pipeline instance ready to run.

Raises:

Type Description
OSError

If the file cannot be opened.

YAMLError

If the YAML is invalid.

ValueError

If required keys are missing (re-raised from _from_config_dict).

Source code in simet/pipeline/simple_pipeline.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
@classmethod
def from_yaml(cls, config_path: Path) -> "SimplePipeline":
    """Build a simple pipeline from a YAML file.

    Args:
        config_path: Path to a YAML file with the structure shown in the class docstring.

    Returns:
        SimplePipeline: A pipeline instance ready to run.

    Raises:
        OSError: If the file cannot be opened.
        yaml.YAMLError: If the YAML is invalid.
        ValueError: If required keys are missing (re-raised from `_from_config_dict`).
    """
    try:
        with open(config_path, "r") as file:
            pipeline_data = yaml.safe_load(file)
            return cls._from_config_dict(pipeline_data)
    except Exception as e:
        logger.error(f"Failed to parse pipeline file: {e}")
        raise

run

run()

Compute all configured metrics sequentially.

For each metric

1) Logs the metric name. 2) Calls metric.compute(self.loader). 3) Logs the computed result.

Returns:

Type Description
None

None

Source code in simet/pipeline/simple_pipeline.py
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
def run(self) -> None:
    """Compute all configured metrics sequentially.

    For each metric:
      1) Logs the metric name.
      2) Calls ``metric.compute(self.loader)``.
      3) Logs the computed result.

    Returns:
        None
    """
    for metric in self.metrics:
        logger.info(f"Computing metric: {metric.name}")
        res = metric.compute(self.loader)
        logger.info(f"Metric {metric.name} computed successfully, result is {res}.")

    logger.info("All metrics computed successfully")