base
¶
Classes¶
fastvideo.eval.metrics.base.BaseMetric
¶
Abstract base class for all eval metrics.
Two execution shapes:
- Per-sample (
is_set_metric=False, default) — implement :meth:compute. The Evaluator calls it once per input sample and returns one :class:MetricResultper sample.
- Set-vs-set (
is_set_metric=True) — implement :meth:accumulate(called once per sample to buffer features) and :meth:finalize(called once after all samples to compute the corpus-level result). Use :meth:resetto clear buffers and :meth:merge_fromto fold multi-GPU per-worker state together.
Optionally override :meth:setup to eagerly load models. Metrics
that chunk along the time dim for memory hardcode their own chunk
size in __init__ (see optical_flow for the canonical
example). Eval always processes one video per
:meth:Evaluator.evaluate call; compute / accumulate
receive a single sample, not a batch.
Source code in fastvideo/eval/metrics/base.py
Functions¶
fastvideo.eval.metrics.base.BaseMetric.compute
¶
compute(sample: dict) -> MetricResult
Per-sample metrics: compute the score for one sample.
sample["video"] is (T, C, H, W) float in [0, 1].
sample["reference"] (if used) has the same shape. Return
self._skip(sample, reason) for missing inputs.
Source code in fastvideo/eval/metrics/base.py
fastvideo.eval.metrics.base.BaseMetric.finalize
¶
finalize() -> MetricResult
fastvideo.eval.metrics.base.BaseMetric.merge_from
¶
merge_from(other: BaseMetric) -> None
fastvideo.eval.metrics.base.BaseMetric.reset
¶
fastvideo.eval.metrics.base.BaseMetric.setup
¶
Eagerly load models. Called once by :class:EvalWorker.
Default is a no-op; metrics with no eager state (pixel math, closed-form ops) inherit this. Override only if your metric needs to load weights.
Source code in fastvideo/eval/metrics/base.py
fastvideo.eval.metrics.base.BaseMetric.to
¶
to(device: str | device) -> BaseMetric