Skip to content
FastVideo
Esc
↑↓navigate↵open⌘Jpreview
On this page

eval

fastvideo eval CLI: list registered eval metrics and run them against a set of videos.

This is a thin wrapper around :mod:fastvideo.eval. Heavy lifting (metric loading, GPU handling, batching) lives in :func:fastvideo.eval.create_evaluator.

Examples::

fastvideo eval list
fastvideo eval list --group vbench
fastvideo eval run --videos path/to/videos/*.mp4 \
    --metrics common.ssim --reference path/to/refs/
fastvideo eval run --videos clip.mp4 --metrics vbench.aesthetic_quality \
    --output scores.json

fastvideo.entrypoints.cli.eval.CLISubcommand

CLISubcommand()

Base class for CLI subcommands

fastvideo.entrypoints.cli.eval.CLISubcommand.cmd

cmd(args: argparse.Namespace) -> None

Execute the command with the given arguments

fastvideo.entrypoints.cli.eval.CLISubcommand.validate

validate(args: argparse.Namespace) -> None

Validate the arguments for this command

fastvideo.entrypoints.cli.eval.CLISubcommand.subparser_init

subparser_init(subparsers: argparse._SubParsersAction) -> FlexibleArgumentParser

Initialize the subparser for this command

fastvideo.entrypoints.cli.eval.init_logger

init_logger(name: str) -> _FastvideoLogger

The main purpose of this function is to ensure that loggers are retrieved in such a way that we can be sure the root fastvideo logger has already been configured.

fastvideo.entrypoints.cli.eval.FlexibleArgumentParser

FlexibleArgumentParser(*args, **kwargs)

ArgumentParser that allows both underscore and dash in names.

fastvideo.entrypoints.cli.eval.FlexibleArgumentParser.parse_args

parse_args(args = None, namespace = None) -> argparse.Namespace

fastvideo.entrypoints.cli.eval.FlexibleArgumentParser.parse_known_args

parse_known_args(args = None, namespace = None) -> tuple[argparse.Namespace, list[str]]

fastvideo.entrypoints.cli.eval.EvalSubcommand

EvalSubcommand()

The eval subcommand — entry point for the eval suite.

Source
class EvalSubcommand(CLISubcommand):
    """The ``eval`` subcommand — entry point for the eval suite."""
def __init__(self) -> None:
    self.name = "eval"
    super().__init__()

def cmd(self, args: argparse.Namespace) -> None:
    action = getattr(args, "eval_action", None)
    if action == "list":
        _cmd_list(args)
    elif action == "run":
        _cmd_run(args)
    elif action == "v2a":
        _cmd_v2a(args)
    else:
        # Re-print help if no action was given.
        self._parser.print_help()  # type: ignore[attr-defined]

def validate(self, args: argparse.Namespace) -> None:
    action = getattr(args, "eval_action", None)
    if action == "v2a":
        if args.backend != "av-benchmark":
            raise SystemExit(f"Unsupported V2A evaluation backend: {args.backend}")
        return
    if action != "run":
        return
    if not args.manifest and not args.videos and not args.audios:
        raise SystemExit("`fastvideo eval run` requires --manifest, --videos, or --audios")
    if args.manifest and (args.videos or args.audios or args.reference or args.reference_audio):
        raise SystemExit("--manifest cannot be combined with media path arguments")

def subparser_init(self, subparsers: argparse._SubParsersAction) -> FlexibleArgumentParser:
    eval_parser = subparsers.add_parser(
        "eval",
        help="Run video and V2A evaluation metrics",
        usage="fastvideo eval {list,run,v2a} [...]",
    )
    sub = eval_parser.add_subparsers(dest="eval_action", required=False)

    # `eval list`
    list_p = sub.add_parser("list", help="List registered metrics")
    list_p.add_argument("--group", type=str, default=None, help="Filter to a metric group (e.g. 'vbench').")

    # `eval run`
    run_p = sub.add_parser("run", help="Evaluate videos against one or more metrics")
    run_p.add_argument(
        "--manifest",
        type=str,
        default=None,
        help="JSON/JSONL canonical sample manifest (recommended for benchmarks).",
    )
    run_p.add_argument("--videos",
                       type=str,
                       nargs="+",
                       required=False,
                       help="Path, glob, or directory of generated videos.")
    run_p.add_argument("--audios",
                       type=str,
                       nargs="+",
                       required=False,
                       help="Path, glob, or directory of generated audio files.")
    run_p.add_argument("--reference",
                       type=str,
                       default=None,
                       help="Path / glob / dir of reference videos (for paired metrics).")
    run_p.add_argument(
        "--reference-audio",
        type=str,
        nargs="+",
        default=None,
        help="Path, glob, or directory of reference audio files.",
    )
    run_p.add_argument("--metrics", type=str, default="all", help="Comma-separated metric names, or 'all'.")
    run_p.add_argument("--device", type=str, default="cuda", help="Torch device (e.g. 'cuda', 'cuda:0', 'cpu').")
    run_p.add_argument("--num-gpus", type=int, default=1, help="Number of metric replicas for dataset evaluation.")
    run_p.add_argument("--compile", action="store_true", help="Compile supported metric models.")
    run_p.add_argument(
        "--skip-missing-deps",
        action="store_true",
        help="Skip explicitly requested metrics whose optional dependencies are missing.",
    )
    run_p.add_argument(
        "--extract-audio",
        nargs="?",
        const=True,
        default=False,
        help="Extract missing audio tracks; optionally provide a persistent cache directory.",
    )
    run_p.add_argument("--extract-workers", type=int, default=4)
    run_p.add_argument(
        "--text-prompt",
        type=str,
        nargs="*",
        default=None,
        help="Prompt(s) for text-conditioned metrics. One per video.",
    )
    run_p.add_argument("--fps", type=float, default=None, help="Frame-rate annotation passed to fps-aware metrics.")
    run_p.add_argument("--output",
                       type=str,
                       default=None,
                       help="Write results as JSON to this path (default: stdout).")
    run_p.add_argument(
        "--output-format",
        choices=("legacy", "full"),
        default="legacy",
        help="'full' includes corpus metrics and sample identities.",
    )

    # `eval v2a`: isolated corpus-level backends for video-to-audio.
    v2a_p = sub.add_parser("v2a", help="Evaluate V2A audio with a corpus benchmark backend")
    v2a_p.add_argument("--backend", choices=("av-benchmark", ), default="av-benchmark")
    v2a_p.add_argument("--audio-dir", required=True, help="Directory containing generated WAV/FLAC files.")
    v2a_p.add_argument("--gt-cache", required=True, help="Official ground-truth feature cache directory.")
    v2a_p.add_argument(
        "--prediction-cache",
        default=None,
        help="Generated-audio feature cache (default: <audio-dir>/../av_benchmark_cache).",
    )
    v2a_p.add_argument(
        "--output",
        default=None,
        help="Result JSON (default: <audio-dir>/../av_benchmark_results.json).",
    )
    v2a_p.add_argument(
        "--python-executable",
        default=None,
        help="Python from an isolated av-benchmark environment.",
    )
    v2a_p.add_argument("--device", default="cuda")
    v2a_p.add_argument("--batch-size", type=int, default=32)
    v2a_p.add_argument("--num-workers", type=int, default=0)
    v2a_p.add_argument("--audio-length", type=float, default=8.0)
    v2a_p.add_argument("--recompute", action="store_true", help="Re-extract the prediction cache.")
    v2a_p.add_argument("--skip-video-related", action="store_true", help="Skip ImageBind and DeSync.")
    v2a_p.add_argument("--skip-clap", action="store_true", help="Skip LAION/MS CLAP extraction and scores.")
    v2a_p.add_argument(
        "--align-prediction-keys",
        action="store_true",
        help="Align uniquely underscore-prefixed prediction ids to official GT cache ids.",
    )

    # Stash the parser so cmd() can re-print help on no-action.
    self._parser = eval_parser  # type: ignore[attr-defined]
    return cast(FlexibleArgumentParser, eval_parser)</code></pre></details>

fastvideo.entrypoints.cli.eval.EvalSubcommand.cmd

cmd(args: argparse.Namespace) -> None
Source
def cmd(self, args: argparse.Namespace) -> None:
    action = getattr(args, "eval_action", None)
    if action == "list":
        _cmd_list(args)
    elif action == "run":
        _cmd_run(args)
    elif action == "v2a":
        _cmd_v2a(args)
    else:
        # Re-print help if no action was given.
        self._parser.print_help()  # type: ignore[attr-defined]

fastvideo.entrypoints.cli.eval.EvalSubcommand.validate

validate(args: argparse.Namespace) -> None
Source
def validate(self, args: argparse.Namespace) -> None:
    action = getattr(args, "eval_action", None)
    if action == "v2a":
        if args.backend != "av-benchmark":
            raise SystemExit(f"Unsupported V2A evaluation backend: {args.backend}")
        return
    if action != "run":
        return
    if not args.manifest and not args.videos and not args.audios:
        raise SystemExit("`fastvideo eval run` requires --manifest, --videos, or --audios")
    if args.manifest and (args.videos or args.audios or args.reference or args.reference_audio):
        raise SystemExit("--manifest cannot be combined with media path arguments")

fastvideo.entrypoints.cli.eval.EvalSubcommand.subparser_init

subparser_init(subparsers: argparse._SubParsersAction) -> FlexibleArgumentParser
Source
def subparser_init(self, subparsers: argparse._SubParsersAction) -> FlexibleArgumentParser:
    eval_parser = subparsers.add_parser(
        "eval",
        help="Run video and V2A evaluation metrics",
        usage="fastvideo eval {list,run,v2a} [...]",
    )
    sub = eval_parser.add_subparsers(dest="eval_action", required=False)
# `eval list`
list_p = sub.add_parser(&quot;list&quot;, help=&quot;List registered metrics&quot;)
list_p.add_argument(&quot;--group&quot;, type=str, default=None, help=&quot;Filter to a metric group (e.g. &#x27;vbench&#x27;).&quot;)

# `eval run`
run_p = sub.add_parser(&quot;run&quot;, help=&quot;Evaluate videos against one or more metrics&quot;)
run_p.add_argument(
    &quot;--manifest&quot;,
    type=str,
    default=None,
    help=&quot;JSON/JSONL canonical sample manifest (recommended for benchmarks).&quot;,
)
run_p.add_argument(&quot;--videos&quot;,
                   type=str,
                   nargs=&quot;+&quot;,
                   required=False,
                   help=&quot;Path, glob, or directory of generated videos.&quot;)
run_p.add_argument(&quot;--audios&quot;,
                   type=str,
                   nargs=&quot;+&quot;,
                   required=False,
                   help=&quot;Path, glob, or directory of generated audio files.&quot;)
run_p.add_argument(&quot;--reference&quot;,
                   type=str,
                   default=None,
                   help=&quot;Path / glob / dir of reference videos (for paired metrics).&quot;)
run_p.add_argument(
    &quot;--reference-audio&quot;,
    type=str,
    nargs=&quot;+&quot;,
    default=None,
    help=&quot;Path, glob, or directory of reference audio files.&quot;,
)
run_p.add_argument(&quot;--metrics&quot;, type=str, default=&quot;all&quot;, help=&quot;Comma-separated metric names, or &#x27;all&#x27;.&quot;)
run_p.add_argument(&quot;--device&quot;, type=str, default=&quot;cuda&quot;, help=&quot;Torch device (e.g. &#x27;cuda&#x27;, &#x27;cuda:0&#x27;, &#x27;cpu&#x27;).&quot;)
run_p.add_argument(&quot;--num-gpus&quot;, type=int, default=1, help=&quot;Number of metric replicas for dataset evaluation.&quot;)
run_p.add_argument(&quot;--compile&quot;, action=&quot;store_true&quot;, help=&quot;Compile supported metric models.&quot;)
run_p.add_argument(
    &quot;--skip-missing-deps&quot;,
    action=&quot;store_true&quot;,
    help=&quot;Skip explicitly requested metrics whose optional dependencies are missing.&quot;,
)
run_p.add_argument(
    &quot;--extract-audio&quot;,
    nargs=&quot;?&quot;,
    const=True,
    default=False,
    help=&quot;Extract missing audio tracks; optionally provide a persistent cache directory.&quot;,
)
run_p.add_argument(&quot;--extract-workers&quot;, type=int, default=4)
run_p.add_argument(
    &quot;--text-prompt&quot;,
    type=str,
    nargs=&quot;*&quot;,
    default=None,
    help=&quot;Prompt(s) for text-conditioned metrics. One per video.&quot;,
)
run_p.add_argument(&quot;--fps&quot;, type=float, default=None, help=&quot;Frame-rate annotation passed to fps-aware metrics.&quot;)
run_p.add_argument(&quot;--output&quot;,
                   type=str,
                   default=None,
                   help=&quot;Write results as JSON to this path (default: stdout).&quot;)
run_p.add_argument(
    &quot;--output-format&quot;,
    choices=(&quot;legacy&quot;, &quot;full&quot;),
    default=&quot;legacy&quot;,
    help=&quot;&#x27;full&#x27; includes corpus metrics and sample identities.&quot;,
)

# `eval v2a`: isolated corpus-level backends for video-to-audio.
v2a_p = sub.add_parser(&quot;v2a&quot;, help=&quot;Evaluate V2A audio with a corpus benchmark backend&quot;)
v2a_p.add_argument(&quot;--backend&quot;, choices=(&quot;av-benchmark&quot;, ), default=&quot;av-benchmark&quot;)
v2a_p.add_argument(&quot;--audio-dir&quot;, required=True, help=&quot;Directory containing generated WAV/FLAC files.&quot;)
v2a_p.add_argument(&quot;--gt-cache&quot;, required=True, help=&quot;Official ground-truth feature cache directory.&quot;)
v2a_p.add_argument(
    &quot;--prediction-cache&quot;,
    default=None,
    help=&quot;Generated-audio feature cache (default: &lt;audio-dir&gt;/../av_benchmark_cache).&quot;,
)
v2a_p.add_argument(
    &quot;--output&quot;,
    default=None,
    help=&quot;Result JSON (default: &lt;audio-dir&gt;/../av_benchmark_results.json).&quot;,
)
v2a_p.add_argument(
    &quot;--python-executable&quot;,
    default=None,
    help=&quot;Python from an isolated av-benchmark environment.&quot;,
)
v2a_p.add_argument(&quot;--device&quot;, default=&quot;cuda&quot;)
v2a_p.add_argument(&quot;--batch-size&quot;, type=int, default=32)
v2a_p.add_argument(&quot;--num-workers&quot;, type=int, default=0)
v2a_p.add_argument(&quot;--audio-length&quot;, type=float, default=8.0)
v2a_p.add_argument(&quot;--recompute&quot;, action=&quot;store_true&quot;, help=&quot;Re-extract the prediction cache.&quot;)
v2a_p.add_argument(&quot;--skip-video-related&quot;, action=&quot;store_true&quot;, help=&quot;Skip ImageBind and DeSync.&quot;)
v2a_p.add_argument(&quot;--skip-clap&quot;, action=&quot;store_true&quot;, help=&quot;Skip LAION/MS CLAP extraction and scores.&quot;)
v2a_p.add_argument(
    &quot;--align-prediction-keys&quot;,
    action=&quot;store_true&quot;,
    help=&quot;Align uniquely underscore-prefixed prediction ids to official GT cache ids.&quot;,
)

# Stash the parser so cmd() can re-print help on no-action.
self._parser = eval_parser  # type: ignore&#91;attr-defined&#93;
return cast(FlexibleArgumentParser, eval_parser)</code></pre></details>

fastvideo.entrypoints.cli.eval.cmd_init

cmd_init() -> list[CLISubcommand]
Source
def cmd_init() -> list[CLISubcommand]:
    return [EvalSubcommand()]

Was this page helpful?