deepinsight/insightface · critical · ValueError

No gallery embeddings could be extracted.

Error message

No gallery embeddings could be extracted.

What it means

Raised by run_identity_identification_evaluation after the gallery indexing loop when the gallery list is empty — every gallery image failed to yield an embedding (each failure recorded in errors). This is distinct from error 36: images existed but none were usable.

Source

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

    errors: List[Dict[str, Any]] = []
    cache: Dict[str, np.ndarray] = {}
    gallery: List[Dict[str, Any]] = []
    start_all = time.perf_counter()
    for index, item in enumerate(gallery_items):
        embedding = _embedding_for_image(
            Path(item["path"]),
            engine,
            cache,
            errors,
            "gallery",
            multi_face_policy=multi_face_policy,
        )
        if embedding is not None:
            gallery.append({"identity": item["identity"], "path": str(item["path"]), "embedding": embedding})
        if progress_callback:
            progress_callback(index + 1, len(gallery_items), f"Indexed gallery {index + 1}/{len(gallery_items)}")
    if not gallery:
        raise ValueError("No gallery embeddings could be extracted.")

    rows: List[Dict[str, Any]] = []
    known_total = len(probe_items)
    for index, item in enumerate(probe_items):
        if cancel_callback and cancel_callback():
            break
        embedding = _embedding_for_image(
            Path(item["path"]),
            engine,
            cache,
            errors,
            "probe",
            multi_face_policy=multi_face_policy,
        )
        if embedding is None:
            rows.append({"probe_path": str(item["path"]), "ground_truth": item["identity"], "error": "embedding unavailable"})
        else:
            ranked = _rank_identities(embedding, gallery)

View on GitHub (pinned to 7fadd420c2)

Solutions

  1. Inspect the errors list in the raised run / add logging to see per-image causes and fix the dominant one
  2. Test one gallery image standalone: read_image + engine.detect_faces to verify the engine works
  3. Adjust multi_face_policy (e.g., centered_largest) if faces are present but ambiguous
  4. Replace or re-source the gallery images if they are face crops or low quality

Example fix

# before
gallery = [{"identity": it["identity"], "embedding": _embedding_for_image(it["path"], engine)} for it in gallery_items]
# after (surface per-image failures)
for it in gallery_items:
    emb = _embedding_for_image(it["path"], engine)
    if emb is None:
        print("gallery embedding failed:", it["path"])
# then fix root cause (policy, image quality, engine init)
Defensive patterns

Strategy: fallback

Validate before calling

ok = 0
for it in gallery_items:
    img = read_image(it["path"])
    if img is None:
        continue
    faces = engine.detect_faces(img)
    if faces and max(faces, key=lambda f: (f.bbox[2]-f.bbox[0])*(f.bbox[3]-f.bbox[1])).normed_embedding is not None:
        ok += 1
assert ok > 0, "all gallery embeddings will fail"

Try / catch

try:
    result = run_identity_identification_evaluation(root, ...)
except ValueError as e:
    if "No gallery embeddings" in str(e):
        diagnose_errors(result_or_log_errors); fix_policy_or_images(); retry

Prevention

When it happens

Trigger: All gallery images failing in _embedding_for_image (read failure, no face detected, multi-face skip, or missing embedding) so gallery stays empty while gallery_items was non-empty.

Common situations: Model weights not properly loaded so detection always fails; dataset of images with no visible faces (cropped face chips fed where full photos expected); multi_face_policy='skip' over group photos; systematic image corruption.

Related errors


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