-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
KeyError: dataset has no key "image" #6069
Comments
You can list the dataset's columns with |
This is the piece of code I am running:
When I print ds.column_names I get the following The
The weird part of it all is that a sample code runs in a jupyter lab notebook without any bugs, but when I run my scripts from the terminal I get the bug. The same code. |
The |
The problem is not with the removal of the image key. The bug is why only the labels are sent to be process, instead of all the featues or dictionary keys. P.S. I just dropped the removal argument as you've suggested, but that didn't solve the problem, because only the labels are being sent to be processed |
All the If that's not the case, we need a full reproducer (not snippets) with the environment info. |
I have resolved the error after including a collate function as indicated in the Quick Start session of the Datasets docs.: Here is what I did:
Everything runs fine without any bug now. |
are you using hf Trainer? hf trainer will remove columns not used in model.forward. set |
Describe the bug
I've loaded a local image dataset with:
ds = laod_dataset("imagefolder", data_dir=path-to-data)
And defined a transform to process the data, following the Datasets docs.
However, I get a keyError error, indicating there's no "image" key in my dataset. When I printed out the example_batch sent to the transformation function, it shows only the labels are being sent to the function.
For some reason, the images are not in the example batches.
Steps to reproduce the bug
I'm using the latest stable version of datasets
Expected behavior
I expect the example_batches to contain both images and labels
Environment info
I'm using the latest stable version of datasets
The text was updated successfully, but these errors were encountered: