Skip to content
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

Indexing using certain key #1984

Open
noringname opened this issue Nov 2, 2022 · 4 comments
Open

Indexing using certain key #1984

noringname opened this issue Nov 2, 2022 · 4 comments

Comments

@noringname
Copy link

Hi,
I'm wondering if there is an easy way of indexing using certain column (image name) instead of using row number?
For example, I want to check the annotation of "0001.jpg", can I do something like ds["0001.jpg"] to get the record?
The solution I can think of is using the filter function, which is not very convenient.

@FayazRahman
Copy link
Contributor

We don't support that and it seems like ds.filter will be your best option.

ds.filter("images.sample_info['filename'] == '0001.jpg'")

which will return the samples with the given image name. If you already tried this, could you tell me why it's not a good option for you?

@noringname
Copy link
Author

Thanks, it's because I want to do upsampling and downsampling on the dataset based on certain conditions, if i can do something like ds["0001.jpg"], then I can just play with the image name list, upsample or downsample the image names, then access corresponding records.

@noringname
Copy link
Author

Basically what indexes are for, providing quick access to certain records.

@AbhinavTuli
Copy link
Contributor

Hey @noringname! Thanks for the feature request, we've seen custom indexing requested by multiple users and we plan on implementing this in the near future.
In the meantime, an alternate way to handle this is to keep a dictionary and maintain a mapping of image names to indexes. You can store this dictionary in ds.info or ds.images.info and use it to translate the image name to the relevant indexes. As long as you aren't popping samples, it should work as intended. (In case you do pop, all indexes in the dictionary after that sample would need to be shifted down)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants