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

Add SemanticSamTrainer #637

Merged
merged 10 commits into from
Jun 21, 2024
Merged

Add SemanticSamTrainer #637

merged 10 commits into from
Jun 21, 2024

Conversation

anwai98
Copy link
Contributor

@anwai98 anwai98 commented Jun 17, 2024

@constantinpape Here is the trainer for semantic segmentation using SAM. Let me know if this aligns with what we discussed.

Copy link
Contributor

@constantinpape constantinpape left a comment

Choose a reason for hiding this comment

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

Looks good to me, I couldn't spot any issues.

@anwai98
Copy link
Contributor Author

anwai98 commented Jun 18, 2024

Thanks @constantinpape. I tested this in a 2d dataset, looks like it's doing the job as expected. This is GTG from my side now (only pending a few minor discussion in the evaluation PR)

Copy link
Contributor

@constantinpape constantinpape left a comment

Choose a reason for hiding this comment

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

We should revisit this with multi-class segmentation in mind, and potentially prefer the low-res masks.

micro_sam/training/semantic_sam_trainer.py Show resolved Hide resolved
@anwai98
Copy link
Contributor Author

anwai98 commented Jun 19, 2024

Hi @constantinpape,

Looks like the mutli-class semantic segmentation works as expected now (atleast from the first looks of the Tensorboard logs). I am not a big fan of the workarounds I had to apply to make this work, but maybe we find a better way to make things work in a much more modular setup. Let me know if you spot something. We can discuss together tomorrow the details anyways.

ADDITION: I added the support for an added loss function (cross entropy) over the logits (between the low_res_masks returned by the model and the downscaled version of the ground-truth). Looks like it's working as expected, and converges a bit faster compared to just dice over masks.

micro_sam/training/semantic_sam_trainer.py Outdated Show resolved Hide resolved
micro_sam/training/util.py Outdated Show resolved Hide resolved
micro_sam/training/util.py Outdated Show resolved Hide resolved
micro_sam/util.py Outdated Show resolved Hide resolved
micro_sam/util.py Outdated Show resolved Hide resolved
Copy link
Contributor

@constantinpape constantinpape left a comment

Choose a reason for hiding this comment

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

Looks good, but let's remove the GT downsampling. (I think we don't need it anyore)

micro_sam/training/util.py Outdated Show resolved Hide resolved
@anwai98
Copy link
Contributor Author

anwai98 commented Jun 21, 2024

@constantinpape,

I've removed the downscaling of masks. Should be GTG now. Thanks!

PS. Tested it on a quick training as well

@constantinpape constantinpape merged commit 14f9f23 into dev Jun 21, 2024
0 of 3 checks passed
@constantinpape constantinpape deleted the semantic-sam branch June 21, 2024 14:44
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