{"record":{"id":"0d356657733727e6","repo":"roboflow/supervision","slug":"createml-annotation-refers-to-image-image-name-0d3566","errorCode":null,"errorMessage":"CreateML annotation refers to image {image_name}, which resolves to directory {resolved_image_path}. Expected a path to an image file.","messagePattern":"CreateML annotation refers to image (.+?), which resolves to directory (.+?)\\. Expected a path to an image file\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/supervision/dataset/formats/createml.py","lineNumber":49,"sourceCode":"    except (OSError, ValueError) as exc:\n        raise ValueError(\n            f\"CreateML annotation refers to image {image_name!r}, which \"\n            f\"produces an invalid path: {exc}\"\n        ) from exc\n    if resolved_image_path == images_directory_resolved:\n        raise ValueError(\n            f\"CreateML annotation refers to image {image_name!r}, which \"\n            f\"resolves to the images directory itself \"\n            f\"({images_directory_resolved}). Expected a path to an image file.\"\n        )\n    if images_directory_resolved not in resolved_image_path.parents:\n        raise ValueError(\n            f\"CreateML annotation refers to image {image_name!r}, which \"\n            f\"resolves to {resolved_image_path} — outside the images \"\n            f\"directory {images_directory_resolved}.\"\n        )\n    if resolved_image_path.is_dir():\n        raise ValueError(\n            f\"CreateML annotation refers to image {image_name!r}, which \"\n            f\"resolves to directory {resolved_image_path}. Expected a path \"\n            \"to an image file.\"\n        )\n    return str(resolved_image_path)\n\n\ndef createml_annotations_to_detections(\n    image_annotations: list[CreateMLDict], class_to_index: dict[str, int]\n) -> Detections:\n    \"\"\"Convert a single image's CreateML annotations into ``Detections``.\n\n    CreateML stores each box as a pixel-space centre point plus width/height\n    (``{\"x\", \"y\", \"width\", \"height\"}``); they are converted to ``xyxy`` corners.\n\n    Args:\n        image_annotations: List of annotation dicts for one image, each containing\n            a ``\"label\"`` key and a ``\"coordinates\"`` dict with ``\"x\"``, ``\"y\"``,","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/roboflow/supervision/blob/7f254d9784d4c37e0f03cd89ddee164c8db099c0/src/supervision/dataset/formats/createml.py#L31-L67","documentation":"Raised by _resolve_image_path in the CreateML loader when the resolved image path is an existing directory. The image field must resolve to a file; naming a directory (e.g. via a trailing slash or a folder name) is treated as malformed data.","triggerScenarios":"A CreateML entry with \"image\": \"train/\" or a name that happens to match a subdirectory inside images_directory_path.","commonSituations":"String concatenation bugs leaving a trailing '/'; empty filename joined after a folder prefix; directory/file name collisions in the dataset tree.","solutions":["Point the image field at the actual file, with no trailing slash.","Fix the generator script that assembled the path with an empty basename.","Pre-validate: Path(images_dir, entry['image']).resolve().is_dir() should be False for every entry."],"exampleFix":"// before\n{\"image\": \"train/\", ...}\n\n// after\n{\"image\": \"train/img_0001.jpg\", ...}","handlingStrategy":"validation","validationCode":"import json\nfrom pathlib import Path\n\ndef find_dir_valued_createml_images(annotations_path: str, images_dir: str) -> list[str]:\n    \"\"\"List 'image' values resolving to an existing directory.\"\"\"\n    entries = json.loads(Path(annotations_path).read_text())\n    return [e[\"image\"] for e in entries if Path(images_dir, e[\"image\"]).resolve().is_dir()]","typeGuard":"def names_image_file_createml(name: str, images_dir: str) -> bool:\n    \"\"\"True when the resolved path exists and is a regular file.\"\"\"\n    return Path(images_dir, name).resolve().is_file()","tryCatchPattern":"try:\n    sv.DetectionDataset.from_createml(images_directory_path=d, annotations_path=a)\nexcept ValueError as exc:\n    if \"resolves to directory\" in str(exc):\n        raise ValueError(f\"Fix directory-valued 'image' entries: {find_dir_valued_createml_images(a, d)}\") from exc\n    raise","preventionTips":["Never leave a trailing '/' on the 'image' field.","Check Path(...).is_file() when generating entries from directory walks.","Test loaders on a small curated sample of any third-party annotation file first."],"tags":["createml","dataset-load","path-validation","data-quality"],"backgroundTag":null,"analyzedSha":"7f254d9784d4c37e0f03cd89ddee164c8db099c0","analyzedAt":"2026-08-15T05:13:01.950Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}