Merged
Conversation
NicolasHug
reviewed
Jul 25, 2023
| return image, label | ||
|
|
||
| @pytest.mark.parametrize( | ||
| "transform_clss", |
Member
There was a problem hiding this comment.
Why not call this transform_class ?
Contributor
Author
There was a problem hiding this comment.
It would have to be transform_classes, since it is a list of classes. And since we use cls for singular, I'm usually just append an s to it. I'll leave it up to you.
Comment on lines
+51
to
+52
| if not self.transforms: | ||
| return inputs if needs_unpacking else inputs[0] |
Member
There was a problem hiding this comment.
Should we just error in init? I dont know if it's super valuable to special-case this?
Contributor
Author
There was a problem hiding this comment.
Depends. The old Compose works as a no-op in case you don't put any transforms in. However, this doesn't sound like a valid use case. So I'm ok in putting this into the constructor.
Contributor
Author
There was a problem hiding this comment.
I went with the error. LMK if you want the no-op behavior back.
NicolasHug
reviewed
Jul 25, 2023
Co-authored-by: Nicolas Hug <contact@nicolas-hug.com>
facebook-github-bot
pushed a commit
that referenced
this pull request
Aug 25, 2023
Summary: Co-authored-by: Nicolas Hug <contact@nicolas-hug.com> Reviewed By: matteobettini Differential Revision: D48642249 fbshipit-source-id: 48053ff1f6a19d62264500358a4df125751b71e6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The way
Composeis currently implemented always passes the input "packed" t the individual transforms. Meaning, if one passesCompose([...])(image, label)individually (on "unpacked"), the transforms inside theComposereceive(image, label), i.e. the individual inputs packed into a tuple.For our builtin transforms this makes no difference, since we operate on arbitrary input structures anyway. However, this becomes relevant as soon as a user wants to add a custom transform into the same pipeline. Assuming the user doesn't want to bother with our whole protocol and knows the sample structure exactly, they like want to write something like
However, dropping this into a
Composewould not work when passingimageandlabelindividually, due to the packing behavior described above. Instead the user would have to writeThis is somewhat awkward, since the input of the individual transform no longer conforms to the input of the
Compose.This transform fixes this behavior. This means, if the inputs to the
Composeare unpacked, they also have to be unpacked in the signature of the individual transform. Same is true for the other way around: if the input to theComposeis packed, the individual transform also needs to take a packed input.cc @vfdev-5