{"record":{"id":"75375f433a9a55ee","repo":"deepinsight/insightface","slug":"1-n-evaluation-requires-at-least-one-gallery-image","errorCode":null,"errorMessage":"1:N evaluation requires at least one gallery image.","messagePattern":"1:N evaluation requires at least one gallery image\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python-package/insightface/gui/core/evaluation.py","lineNumber":838,"sourceCode":"\n\ndef run_identity_identification_evaluation(\n    dataset_root: str | Path,\n    engine: FaceEngine,\n    auto_split: bool = False,\n    multi_face_policy: str = MULTI_FACE_REQUIRE_ONE,\n    license_status: str = DEFAULT_LICENSE_STATUS,\n    progress_callback=None,\n    cancel_callback=None,\n) -> EvaluationResult:\n    root = Path(dataset_root).expanduser()\n    if not root.is_dir():\n        raise ValueError(f\"Dataset root not found: {root}\")\n    gallery_items, probe_items, unknown_items = (\n        _collect_gallery_probe_auto_split(root) if auto_split else _collect_gallery_probe_structured(root)\n    )\n    if not gallery_items:\n        raise ValueError(\"1:N evaluation requires at least one gallery image.\")\n    if not probe_items:\n        raise ValueError(\"1:N evaluation requires at least one known probe image.\")\n\n    errors: List[Dict[str, Any]] = []\n    cache: Dict[str, np.ndarray] = {}\n    gallery: List[Dict[str, Any]] = []\n    start_all = time.perf_counter()\n    for index, item in enumerate(gallery_items):\n        embedding = _embedding_for_image(\n            Path(item[\"path\"]),\n            engine,\n            cache,\n            errors,\n            \"gallery\",\n            multi_face_policy=multi_face_policy,\n        )\n        if embedding is not None:\n            gallery.append({\"identity\": item[\"identity\"], \"path\": str(item[\"path\"]), \"embedding\": embedding})","sourceCodeStart":820,"sourceCodeEnd":856,"githubUrl":"https://github.com/deepinsight/insightface/blob/7fadd420c2351d0ffa8cac403421c1a3ed733365/python-package/insightface/gui/core/evaluation.py#L820-L856","documentation":"Raised by run_identity_identification_evaluation when, after collecting the dataset (auto-split or structured), zero gallery images were found. The gallery is the enrolled identity set that probes are matched against, so 1:N evaluation cannot proceed.","triggerScenarios":"Structured mode: gallery/ missing (also caught earlier) or containing no images in any identity folder. Auto-split mode: identity folders exist but contain no readable images, or layout has no recognizable identity folders for gallery assignment.","commonSituations":"Empty gallery folder or images with unsupported extensions filtered by list_images; dataset_root pointed at probe-only tree; all gallery images dropped by earlier validation.","solutions":["Verify gallery folders contain image files with recognized extensions (jpg/png/bmp per list_images)","Check recursive listing actually finds images (nested subfolders vs non-recursive expectations)","Confirm dataset_root/layout matches the mode (auto_split vs structured)","Run a quick count: sum(1 for _ in (root/'gallery').rglob('*') if _.suffix.lower() in {'.jpg','.jpeg','.png','.bmp'})"],"exampleFix":"# before\nresult = run_identity_identification_evaluation(root, auto_split=False)\n# after\ngallery_imgs = list((root / \"gallery\").rglob(\"*.jpg\"))\nassert gallery_imgs, \"no gallery images found\"\nresult = run_identity_identification_evaluation(root, auto_split=False)","handlingStrategy":"validation","validationCode":"from pathlib import Path\nEXTS = {\".jpg\", \".jpeg\", \".png\", \".bmp\"}\ngallery_dir = Path(root) / \"gallery\"\nn = sum(1 for f in gallery_dir.rglob(\"*\") if f.suffix.lower() in EXTS)\nassert n > 0, \"gallery empty\"","typeGuard":null,"tryCatchPattern":"try:\n    result = run_identity_identification_evaluation(root, auto_split=False)\nexcept ValueError as e:\n    if \"at least one gallery image\" in str(e):\n        populate_gallery_or_switch_layout()","preventionTips":["Count recognized images before starting long evaluations","Keep extensions restricted to formats list_images accepts","Automate dataset layout checks in a preflight script"],"tags":["insightface","gallery","dataset","identification"],"backgroundTag":"empty-gallery-dataset","analyzedSha":"7fadd420c2351d0ffa8cac403421c1a3ed733365","analyzedAt":"2026-08-28T15:44:01.850Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}