{"record":{"id":"47913f74ac02588b","repo":"ultralytics/ultralytics","slug":"no-images-from-self-json-file-found-in-self-img","errorCode":null,"errorMessage":"No images from {self.json_file} found in {self.img_path}. {HELP_URL}","messagePattern":"No images from (.+?) found in (.+?)\\. (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"ultralytics/data/dataset.py","lineNumber":795,"sourceCode":"                f\"{self.json_file}: ignored segmentations that are not polygon point lists, such as RLE masks. \"\n                \"Annotations left without a polygon use a segment shaped like their bounding box.\"\n            )\n        x[\"hash\"] = self.get_cache_hash()\n        save_dataset_cache_file(self.prefix, path, x, DATASET_CACHE_VERSION)\n        return x\n\n    def get_labels(self) -> list[dict]:\n        \"\"\"Load labels from cache or generate them from JSON file.\n\n        Returns:\n            (list[dict]): List of label dictionaries, each containing information about an image and its annotations.\n        \"\"\"\n        cache_path = Path(self.json_file).with_suffix(\".cache\")\n        cache, _ = self._load_or_scan_cache(cache_path, self.get_cache_hash())\n        [cache.pop(k) for k in (\"hash\", \"version\")]  # remove items\n        labels = cache[\"labels\"]\n        if not labels:\n            raise RuntimeError(f\"No images from {self.json_file} found in {self.img_path}. {HELP_URL}\")\n        if not any(label[\"texts\"] for label in labels):  # category_freq is empty, so negative texts cannot be built\n            raise RuntimeError(\n                f\"No annotations in {self.json_file} survived filtering. Every one is iscrowd, resolves to an empty \"\n                f\"caption span or has a zero-size box. {HELP_URL}\"\n            )\n        self._verify_instance_counts(labels)\n        self.im_files = [str(label[\"im_file\"]) for label in labels]\n        if LOCAL_RANK in {-1, 0}:\n            LOGGER.info(f\"Load {self.json_file} from cache file {cache_path}\")\n        return labels\n\n    def build_transforms(self, hyp: dict | None = None) -> Compose:\n        \"\"\"Configure augmentations for training with optional text loading.\n\n        Args:\n            hyp (dict, optional): Hyperparameters for transforms.\n\n        Returns:","sourceCodeStart":777,"sourceCodeEnd":813,"githubUrl":"https://github.com/ultralytics/ultralytics/blob/0449ea011cfd6c9a0d50a0bf1043aca5190cd476/ultralytics/data/dataset.py#L777-L813","documentation":"Raised by the JSON-backed dataset used for open-vocabulary training (YOLOE-style) when get_labels finds the cached 'labels' list empty after scanning the COCO-format JSON annotation file. Empty labels means the scan matched zero images between the JSON annotations and the image directory (self.img_path), i.e. no image referenced in the JSON could be located on disk.","triggerScenarios":"Constructing this dataset (via YOLOE/open-vocabulary training with json_file and img_path) where the file names or relative paths inside the JSON's images[] entries do not correspond to any files under img_path — e.g. 'file_name': '000000123.jpg' but the directory holds '123.png', or img_path points at the wrong split directory.","commonSituations":"Wrong img_path (train images dir given for a val JSON), dataset extracted with renamed files, COCO file_name values that include a subpath ('images/train/x.jpg') that does not exist relative to img_path, or case-sensitivity mismatches after copying from macOS/Windows to Linux.","solutions":["Verify img_path actually contains the images listed in the JSON: cross-check a few images[i].file_name values against directory listings.","If file_name entries include subdirectories, point img_path at their true common parent so file_name resolves relative to it.","Re-download or re-extract the image set matching the annotation file version (COCO 2014 vs 2017 files are not interchangeable).","Delete the <json>.cache file so the scan re-runs after correcting paths."],"exampleFix":"# before\nYOLOE(\"yoloe-v8s.pt\").train(data={\"json_file\": \"instances_val2017.json\", \"img_path\": \"val_empty_dir\"})\n\n# after\nYOLOE(\"yoloe-v8s.pt\").train(data={\"json_file\": \"instances_val2017.json\", \"img_path\": \"coco/val2017\"})","handlingStrategy":"validation","validationCode":"import json\nfrom pathlib import Path\n\ndef json_images_present(json_file: str, img_path: str) -> bool:\n    names = {Path(im[\"file_name\"]).name for im in json.load(open(json_file))[\"images\"]}\n    on_disk = {p.name for p in Path(img_path).iterdir()}\n    return bool(names) and names <= on_disk","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cross-check JSON file_name values against the img_path listing before training.","Keep the annotation JSON and image folder from the same dataset release.","Delete the <json>.cache when img_path changes so the scan re-runs."],"tags":["dataset","coco-json","paths","open-vocabulary"],"backgroundTag":null,"analyzedSha":"0449ea011cfd6c9a0d50a0bf1043aca5190cd476","analyzedAt":"2026-08-15T02:34:13.413Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}