You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When running inference.py --data-dir data --class-map class_map.txt --model efficientnet_b7 --num-classes 8 --checkpoint output/model_best.pth.tar where data is a directory that contains images and no subfolders, the script crashes with the following output:
Traceback (most recent call last):
File "/home/josua/redacted/pytorch-image-models/inference.py", line 369, in <module>
main()
File "/home/josua/redacted/pytorch-image-models/inference.py", line 224, in main
dataset = create_dataset(
^^^^^^^^^^^^^^^
File "/home/josua/redacted/pytorch-image-models/timm/data/dataset_factory.py", line 216, in create_dataset
ds = ImageDataset(
^^^^^^^^^^^^^
File "/home/josua/redacted/pytorch-image-models/timm/data/dataset.py", line 36, in __init__
reader = create_reader(
^^^^^^^^^^^^^^
File "/home/josua/redacted/pytorch-image-models/timm/data/readers/reader_factory.py", line 44, in create_reader
reader = ReaderImageFolder(root, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/josua/redacted/pytorch-image-models/timm/data/readers/reader_image_folder.py", line 82, in __init__
raise RuntimeError(
RuntimeError: Found 0 images in subfolders of /home/josua/redacted/data/unlabeled. Supported image extensions are .png, .jpg, .jpeg
Expected behavior
Instead of raising an error, I expect it to perform the inference on the (recursive) contents of data irrespective of the existence of labeled subfolders because labels are not necessary for inference.
Desktop (please complete the following information):
PyTorch version w/ CUDA/cuDNN: python-pytorch-cuda 2.3.1-8, cuda 12.6.2-2
Additional context
Workaround: It works when, instead of placing the images in data/ directly, one places them in data/random_label/ where random_label is a random label, i.e. a random line from class_map.txt
The text was updated successfully, but these errors were encountered:
@JosuaRieder it works just fine, the issue is using the class map filters by folder label structure to match behaviour where subsets of imagenet are remapped using class map. Class map isn't really intended to provide labels, it's remapping/filtering transform.
It seems I have misunderstood the intended purpose of class map (as I wrote in the PR).
Even so, I think it's unexpected that inference.py requires a different --data-dir structure with and without class map. I don't see the purpose of having/requiring this subfolder structure when inferring.
Describe the bug
When running
inference.py --data-dir data --class-map class_map.txt --model efficientnet_b7 --num-classes 8 --checkpoint output/model_best.pth.tar
wheredata
is a directory that contains images and no subfolders, the script crashes with the following output:Expected behavior
Instead of raising an error, I expect it to perform the inference on the (recursive) contents of
data
irrespective of the existence of labeled subfolders because labels are not necessary for inference.Desktop (please complete the following information):
Additional context
Workaround: It works when, instead of placing the images in
data/
directly, one places them indata/random_label/
whererandom_label
is a random label, i.e. a random line fromclass_map.txt
The text was updated successfully, but these errors were encountered: