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

fix splitting CelebA dataset + corresponding test #4377

Merged
merged 7 commits into from
Sep 8, 2021

Conversation

VassilisCN
Copy link
Contributor

@VassilisCN VassilisCN commented Sep 7, 2021

While working on the CelebA dataset, I noticed that when splitting the dataset (into 'train'/'valid'/'test' or take it as a whole 'all') only the target (the attributes) were coherent with the split. The input images were always the same, the only thing changing was their number. I traced the code and noticed that the mask that was created for picking the correct samples for the split was only applied on the targets (the attributes) and not the input images. Therefore I fixed the above issue by applying the mask on the input images as well. Also, I added a corresponding test function that checks if each individual split ('train', 'valid', 'test') merged together would create the same input images as if taking the whole dataset ('all'). This test Fails without the aforementioned fix.

cc @pmeier

@facebook-github-bot
Copy link

Hi @VassilisCN!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @VassilisCN. Thanks for pointing this out. This is a regression from #3656. I have a few minor comments inline.

test/test_datasets.py Outdated Show resolved Hide resolved
test/test_datasets.py Outdated Show resolved Hide resolved
test/test_datasets.py Outdated Show resolved Hide resolved
torchvision/datasets/celeba.py Outdated Show resolved Hide resolved
VassilisCN and others added 4 commits September 7, 2021 21:37
Co-authored-by: Philip Meier <github.pmeier@posteo.de>
Co-authored-by: Philip Meier <github.pmeier@posteo.de>
Co-authored-by: Philip Meier <github.pmeier@posteo.de>
Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @VassilisCN for the fix!

test/test_datasets.py Outdated Show resolved Hide resolved
torchvision/datasets/celeba.py Outdated Show resolved Hide resolved
Copy link
Member

@NicolasHug NicolasHug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @VassilisCN and @pmeier !

@NicolasHug NicolasHug merged commit cadb168 into pytorch:main Sep 8, 2021
@NicolasHug NicolasHug added the bug label Sep 8, 2021
facebook-github-bot pushed a commit that referenced this pull request Sep 13, 2021
Summary:

Reviewed By: kazhang

Differential Revision: D30898333

fbshipit-source-id: cb9ef043eca01be3f07dea50148e0a1867797575

Co-authored-by: Vassilis Nicodemou <nikodim@ics.forth.gr>
Co-authored-by: Philip Meier <github.pmeier@posteo.de>
@mohammad-brdrn
Copy link

mohammad-brdrn commented Nov 19, 2021

I've not gone through the source codes but I did an experiment in Torchvision V 0.12.0.dev20211118+cu102. It seems to me that the index for choosing the image and the annotation don't match. For annotations, I checked the 'gender'. gender[1] is for image[0], gender[2] is for image[1], ... (image[0] misses a gender annotation).

I did the experiments in google cloab using torchvision V 0.12.0.dev20211118+cu102.

I went through my own codes and didn't find any bugs. is it the case or should I check again?

@pmeier
Copy link
Collaborator

pmeier commented Nov 19, 2021

@mohammad-brdrn I'm not sure what you are doing. "gender" is not one of the attributes that CelebA provides. Could you post a snippet with unexpected or wrong behavior?

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

Successfully merging this pull request may close these issues.

6 participants