Update trainers to compute loss over low_res_mask#669
Closed
Update trainers to compute loss over low_res_mask#669
Conversation
| h, w = y_one_hot.shape[-2:] | ||
| padh = self.model.sam.image_encoder.img_size - h | ||
| padw = self.model.sam.image_encoder.img_size - w | ||
| y_one_hot = F.pad(input=y_one_hot, pad=(0, padw, 0, padh)) |
Contributor
There was a problem hiding this comment.
Is this not just ResizeLongsetSide until here? Can't we just use it instead of duplicating the code?
Collaborator
Author
There was a problem hiding this comment.
It's because of one parameter that I have to remplement this: (they set antialias to True, which for labels here, we need to set to False.) https://github.com/facebookresearch/segment-anything/blob/main/segment_anything/utils/transforms.py#L63-L65
Collaborator
Author
There was a problem hiding this comment.
Also to add: with ResizeLongestSide, it's still a two stage agenda: (taking LIVECell (images of shape (520, 704) as an example)
ResizeLongestSidewould only adjust the inputs to the longest side: (eg.(520, 704)-?(720, 1024)).- There's still the next stage where the padding takes place to complete the image shape to the desired input shape: (eg.
(720, 1024)->(1024, 1024))
Contributor
There was a problem hiding this comment.
I see, makes sense!
Collaborator
Author
|
I'll close this in favor of #990 |
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.
No description provided.