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

Update trainers to compute loss over low_res_mask #669

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

anwai98
Copy link
Contributor

@anwai98 anwai98 commented Jul 25, 2024

No description provided.

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))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not just ResizeLongsetSide until here? Can't we just use it instead of duplicating the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also to add: with ResizeLongestSide, it's still a two stage agenda: (taking LIVECell (images of shape (520, 704) as an example)

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, makes sense!

micro_sam/training/trainable_sam.py Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants