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

Weird results when use Segmentation Pass for inference #123

Closed
luuil opened this issue Jan 4, 2022 · 4 comments
Closed

Weird results when use Segmentation Pass for inference #123

luuil opened this issue Jan 4, 2022 · 4 comments

Comments

@luuil
Copy link

luuil commented Jan 4, 2022

fgr, pha, *rec = model(src, *rec, downsample_ratio)

I changed this line to use Segmentation Pass. (use the pretrained weights rvm_mobilenetv3.pth)

pha, *rec = model(src, *rec, segmentation_pass=True)
fgr = src * pha

But I got weird mask results, something like this, why?

seg_pass_alpha

@PeterL1n
Copy link
Owner

PeterL1n commented Jan 4, 2022

Try pha.sigmoid(), aka fgr = src * pha.sigmoid(). Because the segmentation pass outputs logits. You need a sigmoid to convert it to 0-1 range.

@luuil
Copy link
Author

luuil commented Jan 4, 2022

Thank you for your prompt reply. You are right, now the result is correct.

@luuil luuil closed this as completed Jan 4, 2022
@FengMu1995
Copy link

is it necessary to change "pha.sigmoid()" for the train module
"""
pred_seg = self.model_ddp(true_img, segmentation_pass=True)[0]
loss = segmentation_loss(pred_seg, true_seg)
"""

@vacing
Copy link

vacing commented Oct 27, 2022

is it necessary to change "pha.sigmoid()" for the train module

it seems not necessary

https://zhang-yang.medium.com/how-is-pytorchs-binary-cross-entropy-with-logits-function-related-to-sigmoid-and-d3bd8fb080e7

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

No branches or pull requests

4 participants