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

Can you give a boundary loss for binary segmentation, thanks #2

Open
ustczhouyu opened this issue Mar 3, 2020 · 9 comments
Open

Can you give a boundary loss for binary segmentation, thanks #2

ustczhouyu opened this issue Mar 3, 2020 · 9 comments

Comments

@ustczhouyu
Copy link

Can you give a boundary loss for binary segmentation, or can you tell me how to modify the code to use it for binary segmentation, thanks

@yiskw713
Copy link
Owner

yiskw713 commented Apr 9, 2020

Hi, ustczhouyu

Sorry for the delay in replying.
How about converting binary prediction to two-class prediction?

import torch
n_batch = 4
H = 112
W = 112

# prediction for binary cross entropy
binary_pred = torch.rand(n_batch, 1, H, W)

# background prediction
bg_pred = torch.ones_like(binary) - binary_pred

# foreground prediction
fg_pred = binary_pred.clone()

# 2 class prediction. shape => (n_batch, 2, H, W)
pred = torch.cat([bg_pred, fg_pred], dim=1)

@NguyenHungHust256
Copy link

Hi, ustczhouyu

Sorry for the delay in replying.
How about converting binary prediction to two-class prediction?

import torch
n_batch = 4
H = 112
W = 112

# prediction for binary cross entropy
binary_pred = torch.rand(n_batch, 1, H, W)

# background prediction
bg_pred = torch.ones_like(binary) - binary_pred

# foreground prediction
fg_pred = binary_pred.clone()

# 2 class prediction. shape => (n_batch, 2, H, W)
pred = torch.cat([bg_pred, fg_pred], dim=1)

Can you explain code. I don't know why you implement this code

@ustczhouyu
Copy link
Author

Thanks for sharing your code. When doing binary segmentation (one class is the object, the other class is the background), I want to know this function: loss = criterion(y['out'], gt), where 'gt' should be the ground-truth of the whole instance or only ground-truth of the boundary? @yiskw713

6 similar comments
@ustczhouyu
Copy link
Author

Thanks for sharing your code. When doing binary segmentation (one class is the object, the other class is the background), I want to know this function: loss = criterion(y['out'], gt), where 'gt' should be the ground-truth of the whole instance or only ground-truth of the boundary? @yiskw713

@ustczhouyu
Copy link
Author

Thanks for sharing your code. When doing binary segmentation (one class is the object, the other class is the background), I want to know this function: loss = criterion(y['out'], gt), where 'gt' should be the ground-truth of the whole instance or only ground-truth of the boundary? @yiskw713

@ustczhouyu
Copy link
Author

Thanks for sharing your code. When doing binary segmentation (one class is the object, the other class is the background), I want to know this function: loss = criterion(y['out'], gt), where 'gt' should be the ground-truth of the whole instance or only ground-truth of the boundary? @yiskw713

@ustczhouyu
Copy link
Author

Thanks for sharing your code. When doing binary segmentation (one class is the object, the other class is the background), I want to know this function: loss = criterion(y['out'], gt), where 'gt' should be the ground-truth of the whole instance or only ground-truth of the boundary? @yiskw713

@ustczhouyu
Copy link
Author

Thanks for sharing your code. When doing binary segmentation (one class is the object, the other class is the background), I want to know this function: loss = criterion(y['out'], gt), where 'gt' should be the ground-truth of the whole instance or only ground-truth of the boundary? @yiskw713

@ustczhouyu
Copy link
Author

Thanks for sharing your code. When doing binary segmentation (one class is the object, the other class is the background), I want to know this function: loss = criterion(y['out'], gt), where 'gt' should be the ground-truth of the whole instance or only ground-truth of the boundary? @yiskw713

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

3 participants