-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[Datasets] Add ImageFolderDatasource
#24641
Conversation
ImageFolderDatasource
ImageFolderDatasource
ImageFolderDatasource
ImageFolderDatasource
Co-authored-by: matthewdeng <[email protected]>
…into image-datasource
For the CUJ that amog posted can we add it in as an example to test in ci? |
No. There are issues with applying TorchVision transformations that are completely unrelated to this PR. To make this code snippet work, you need to add several workarounds
|
@bveeramani sorry, what I mean is we should have an end-to-end test such as Amog's example (with whatever modifications you want to make). Can you please do that before merging? |
@richardliaw Added an E2E test. Wasn't sure what to test other than that there are no errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great work!
Signed-off-by: Richard Liaw <[email protected]>
path, data = records[0] | ||
|
||
image = iio.imread(data) | ||
label = _get_class_from_path(path, self.root) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have any docs / past discussion about this part? Basically we're assuming we get the label based on user file path, which has to be structured in certain way in order to get the correct one without knobs needed to pass in custom label file or join ?
For example, if i read a s3 bucket with filenames of "dog.jpg", "dog_2.jpg" my dataloader will end up getting these string values by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically we're assuming we get the label based on user file path, which has to be structured in certain way in order to get the correct one without knobs needed to pass in custom label file or join ?
Yeah, that's right. The datasource assumes that the layout is structured in the same way as ImageNet. The functionality of the datasource is based on that of TorchVision's ImageFolder.
For example, if i read a s3 bucket with filenames of "dog.jpg", "dog_2.jpg" my dataloader will end up getting these string values by default.
Yeah, you're right. We don't validate that the label corresponds to a directory. In this case, we could raise an error stating that the folder isn't structured correctly.
Alternatively, if images aren't stored in a directory, we could set the label to None
.
If images aren't stored in a sub-directory, then the image's label will be set to `None`.
.. code-block::
root/dog/xxx.png # Label is 'dog'
root/123.jpg. # Label is `None`
Co-authored-by: matthewdeng <[email protected]> Co-authored-by: Richard Liaw <[email protected]> Signed-off-by: Xiaowei Jiang <[email protected]>
Co-authored-by: matthewdeng <[email protected]> Co-authored-by: Richard Liaw <[email protected]> Signed-off-by: Stefan van der Kleij <[email protected]>
Why are these changes needed?
Popular datasets like ImageNet and Tiny ImageNet are arranged in a specific layout like this:
This PR adds a datasource that reads such datasets.
Related issue number
Closes #23977
Checks
scripts/format.sh
to lint the changes in this PR.