-
Notifications
You must be signed in to change notification settings - Fork 413
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
F score over boundaries #1500
Comments
Hi! thanks for your contribution!, great first issue! |
Hi @bhack, thanks for proposing this metric to be a part of torchmetrics. |
Check Section 4.1 in You will find also a comparative analysis where the alternative But F is still the popular one for boundaries measurement in dedicated conference challenges/workshop. I suppose that probably we could reuse the F1Score multiclass metric already available in the library but it needs to be integrated by a boundary extraction function. Let me know if you need any other info. |
@vkosolapov Has a torchmetric for https://github.com/vkosolapov/anchor_free/blob/master/anchor_free/model/metric.py#L8-L74 |
If it could be useful this is Refactored it could be probably quite compatible/reused also for the F metric. def mask_to_boundary_pytorch(mask, dilation_ratio=0.02):
# convert mask to float tensor
mask = mask.float()
# calculate dilation ratio based on image diagonal
h, w = mask.shape
img_diag = math.sqrt(h ** 2 + w ** 2)
dilation = int(round(dilation_ratio * img_diag))
# create structuring element for morphological operations
selem_size = dilation * 2 + 1
selem = torch.ones(selem_size, selem_size, device=mask.device)
# erode the mask using the structuring element
eroded_mask = F.conv2d(mask.unsqueeze(0).unsqueeze(0), selem.unsqueeze(0).unsqueeze(0), padding=dilation)
eroded_mask = eroded_mask.squeeze(0).squeeze(0)
eroded_mask = (eroded_mask == (selem.sum())) # make the output binary
# subtract the eroded mask from the original mask to get the contour
contour = mask.byte() - (eroded_mask > 0).byte()
return contour |
@Borda Can the mask to boundary util be contributed somewhere in the meantime? I don't see a generic util file in the image folder. |
This is a very useful metric for semantic segmentation since it correlates nicely with human perception of IoU. Any news on whether it will be added? |
🚀 Feature
An F score over the boundaries.
It will requires boundaries extraction on multiclass tensors.
Motivation
It is used in many Video dataset and their related challenges (Davis, Yotube VOS, etc.).
Pitch
Generally we have opencv/script/numpy implementations but it could be very useful to have a metrics directly to plug in the eval step.
Alternatives
Implementing BoundaryIOU
https://bowenc0221.github.io/boundary-iou/
Additional context
F-boundary Reference implementation:
https://github.com/davisvideochallenge/davis2017-evaluation/blob/master/davis2017/metrics.py
The text was updated successfully, but these errors were encountered: