deepinsight/insightface · error · ValueError

No verification pairs could be generated from the selected i

Error message

No verification pairs could be generated from the selected identity folders.

What it means

Raised by run_identity_verification_evaluation when pair_specs ends up empty, i.e., no positive or negative pairs could be built from the selected identity folders. This means the folder layout/counts cannot form any same-identity or cross-identity image pairs.

Source

Thrown at python-package/insightface/gui/core/evaluation.py:693

    else:
        images: List[Dict[str, Any]] = []
        for identity_dir in identities:
            identity = _identity_name(identity_dir)
            images.extend({"identity": identity, "path": path} for path in sorted(list_images(identity_dir, recursive=True)))
        for left_index, left in enumerate(images):
            for right in images[left_index + 1 :]:
                pair_specs.append(
                    {
                        "image1_path": str(left["path"]),
                        "image2_path": str(right["path"]),
                        "probe_identity": left["identity"],
                        "gallery_identity": right["identity"],
                        "label": 1 if left["identity"] == right["identity"] else 0,
                    }
                )

    if not pair_specs:
        raise ValueError("No verification pairs could be generated from the selected identity folders.")

    start_all = time.perf_counter()
    rows: List[Dict[str, Any]] = []
    for index, spec in enumerate(pair_specs):
        if cancel_callback and cancel_callback():
            break
        start = time.perf_counter()
        row = dict(spec)
        emb1 = _embedding_for_image(
            Path(spec["image1_path"]),
            engine,
            cache,
            errors,
            "verification",
            multi_face_policy=multi_face_policy,
        )
        emb2 = _embedding_for_image(
            Path(spec["image2_path"]),

View on GitHub (pinned to 7fadd420c2)

Solutions

  1. Ensure each identity folder has at least 2 images (for positive pairs) and there are at least 2 identity folders (for negative pairs)
  2. Verify dataset_root points at the directory whose immediate children are identity folders
  3. Check that images pass validation (readable, single face) so they are not dropped before pairing
  4. Without auto split, provide explicit gallery/probe structure so pairs can be generated
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
ids = [d for d in Path(root).iterdir() if d.is_dir()]
counts = {d.name: len(list_images(d, recursive=True)) for d in ids}
assert sum(1 for c in counts.values() if c >= 2) >= 1 and len(ids) >= 1, "cannot form pairs"

Try / catch

try:
    result = run_identity_verification_evaluation(root, ...)
except ValueError as e:
    if "No verification pairs" in str(e):
        raise SystemExit("Need >=2 images in an identity and/or >=2 identities")

Prevention

When it happens

Trigger: Using auto-split with fewer than 2 images per identity, or a dataset root with only one identity folder containing a single image; identity folders with no recognizable images at all.

Common situations: Test datasets with one photo per person; images filtered out earlier due to read/detection failures leaving too few; pointing dataset_root at the wrong directory level (folders of folders).

Related errors


AI-assisted analysis of deepinsight/insightface@7fadd420c2 (2026-08-28). Data as JSON: /api/errors/de3a89b89182baa7. Report an issue: GitHub.