-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Support empty target_type for CelebA dataset #1351
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1351 +/- ##
=========================================
- Coverage 65.47% 64.8% -0.67%
=========================================
Files 75 76 +1
Lines 5827 5955 +128
Branches 892 912 +20
=========================================
+ Hits 3815 3859 +44
- Misses 1742 1822 +80
- Partials 270 274 +4
Continue to review full report at Codecov.
|
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.
Thanks for the PR!
What do you think about always returning image, target
, but target
potentially being None
if you pass an empty list?
I'm not sure I'd like to see the return values of datasets to change depending on a constructor argument. This has caused some issues already, like #1273
I had some doubts about the interface: in addition to |
I'd say just return |
Amended code and docstring. Please re-review. |
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.
I have a comment that I think would minimize the changes in the PR, let me know what you think
torchvision/datasets/celeba.py
Outdated
return X, target | ||
if not self.target_type: | ||
return X, None | ||
else: |
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.
I would maybe simplify the changes in this PR like the following, and only change the following places:
if target:
target = tuple(target) if len(target) > 1 else target[0]
if self.target_transform is not None:
target = self.target_transform(target)
else:
target = None
Thoughts?
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.
I had doubts about keeping the diff small vs keeping the logic straightforward. Amended the commit following your advice.
Also, added a check for a meaningless combination of parameters (empty target_type
with nonempty target_transform
).
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, thanks!
Previously, passing
target_type=[]
wouldn't work because of this line:This is a workaround that returns only
X
instead ofX, target
iftarget_type
is empty.