-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrongly labelled when using dataset.ImageFolder #10
Comments
Following @chaeunl, you can use the following dataset class:
and initialize it with Sanity CheckThen you can check that the class indices point to the correct folder:
whereas the current implementation in repo (using
The problem stems from the class folder being named with int strings without preceding zeros. |
Hi @psandovalsegura is right ImageFolder is not natively compatible because our class ids are actually uuids. Just use the class in https://github.com/modestyachts/ImageNetV2_pytorch (should be same class as @psandovalsegura shows above) |
Hello.
I found that for some OS system (my environment is Ubuntu20.04), the
class_to_idx
property ofdataset.ImageFolder
is not aligned with the directories' name, so it leads to wrongly label samples.For instance, the directory
100 (str)
is labelled with2 (int)
class. The easiest way to resolve the above issue is, from thedataset.ImageFolder
source code (https://pytorch.org/vision/stable/_modules/torchvision/datasets/folder.html#ImageFolder), modifying the line infind_classes
functionclass_to_idx = {cls_name: i for i, cls_name in enumerate(classes)}
withclass_to_idx = {cls_name: int(cls_name) for cls_name in classes}
.The text was updated successfully, but these errors were encountered: