{"record":{"id":"3834caad64e4ed82","repo":"huggingface/pytorch-image-models","slug":"found-0-images-in-subfolders-of-root-supported","errorCode":null,"errorMessage":"Found 0 images in subfolders of {root}. Supported image extensions are {\", \".join(get_img_extensions())}","messagePattern":"Found 0 images in subfolders of (.+?)\\. Supported image extensions are (.+?)","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"timm/data/readers/reader_image_folder.py","lineNumber":82,"sourceCode":"            class_map='',\n            input_key=None,\n    ):\n        super().__init__()\n\n        self.root = root\n        class_to_idx = None\n        if class_map:\n            class_to_idx = load_class_map(class_map, root)\n        find_types = None\n        if input_key:\n            find_types = input_key.split(';')\n        self.samples, self.class_to_idx = find_images_and_targets(\n            root,\n            class_to_idx=class_to_idx,\n            types=find_types,\n        )\n        if len(self.samples) == 0:\n            raise RuntimeError(\n                f'Found 0 images in subfolders of {root}. '\n                f'Supported image extensions are {\", \".join(get_img_extensions())}')\n\n    def __getitem__(self, index):\n        path, target = self.samples[index]\n        return open(path, 'rb'), target\n\n    def __len__(self):\n        return len(self.samples)\n\n    def _filename(self, index, basename=False, absolute=False):\n        filename = self.samples[index][0]\n        if basename:\n            filename = os.path.basename(filename)\n        elif not absolute:\n            filename = os.path.relpath(filename, self.root)\n        return filename\n","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/huggingface/pytorch-image-models/blob/9a5261e31b3b5128526eb2658333b4c0a54464ae/timm/data/readers/reader_image_folder.py#L64-L100","documentation":"ImageDataset (image_folder reader) walks root for image files under class subfolders and found zero usable samples, so it raises RuntimeError at construction — an empty dataset would otherwise fail confusingly during training.","triggerScenarios":"Calling ImageDataset(root) (or create_dataset with image_folder) where root has no class subdirectories containing files with supported extensions (jpg/jpeg/png/bmp/gif/webp/etc. per get_img_extensions).","commonSituations":"Wrong or misspelled data dir path; images stored flat in root without per-class folders; images with uppercase or unsupported extensions; dataset on an unmounted drive; passing a tar/WebDataset-style directory to the image_folder reader.","solutions":["Verify root is the directory containing class-name subfolders, each holding images.","Check extensions against timm.data.readers.get_img_extensions(); rename .JPG/.JPEG files or add extensions via set_img_extensions if needed.","Confirm the path is mounted/accessible and not empty (ls root/*/ | head).","If data lives in .tar shards, use the in_tar or wds reader instead."],"exampleFix":"# before\nds = ImageDataset('/data/train_flat')  # images directly in dir\n\n# after\n# /data/train/dog/*.jpg, /data/train/cat/*.jpg\nds = ImageDataset('/data/train')","handlingStrategy":"validation","validationCode":"from pathlib import Path\nfrom timm.data.readers import get_img_extensions\nimgs = [p for p in Path(root).rglob('*') if p.suffix.lower() in get_img_extensions()]\nassert imgs, f'no images under {root}'\nds = ImageDataset(root)","typeGuard":null,"tryCatchPattern":"try:\n    ds = ImageDataset(root)\nexcept RuntimeError as e:\n    if 'Found 0 images' in str(e):\n        raise SystemExit(f'check data path/layout: {root}')\n    raise","preventionTips":["Use the standard class-subfolder layout (root/class/img.jpg).","Sanity-check extension casing (.JPG is common).","Add a dataset smoke-test step before long training runs."],"tags":["timm","dataset","image-folder","no-samples"],"backgroundTag":"empty-dataset-directory","analyzedSha":"9a5261e31b3b5128526eb2658333b4c0a54464ae","analyzedAt":"2026-08-27T02:34:25.417Z","schemaVersion":2},"datasetVersion":"2026-08-27T03:17:27.898Z"}