Skip to content

Commit 8d3a8b8

Browse files
committed
delete binary_iou
1 parent 35f5387 commit 8d3a8b8

File tree

2 files changed

+0
-42
lines changed

2 files changed

+0
-42
lines changed

change_detection_pytorch/utils/functional.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -126,26 +126,3 @@ def recall(pr, gt, eps=1e-7, threshold=None, ignore_channels=None):
126126
score = (tp + eps) / (tp + fn + eps)
127127

128128
return score
129-
130-
def binary_miou(pr, gt, eps=1e-7, threshold=None, ignore_channels=None):
131-
"""Calculate binary_miou score between ground truth and prediction
132-
Args:
133-
pr (torch.Tensor): predicted tensor
134-
gt (torch.Tensor): ground truth tensor
135-
eps (float): epsilon to avoid zero division
136-
threshold: threshold for outputs binarization
137-
Returns:
138-
float: precision score
139-
"""
140-
141-
pr = _threshold(pr, threshold=threshold)
142-
pr, gt = _take_channels(pr, gt, ignore_channels=ignore_channels)
143-
144-
tp = torch.sum(gt * pr)
145-
fp = torch.sum(pr) - tp
146-
fn = torch.sum(gt) - tp
147-
tn = torch.sum(gt == pr, dtype=pr.dtype) - tp
148-
149-
score = ((tp + eps) / (tp + fp + fn + eps) + (tn + eps) / (tn + fp + fn + eps)) / 2
150-
151-
return score

change_detection_pytorch/utils/metrics.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,24 +98,5 @@ def forward(self, y_pr, y_gt):
9898
ignore_channels=self.ignore_channels,
9999
)
100100

101-
# customized and unofficial
102101

103-
class Binary_mIOU(base.Metric):
104-
__name__ = 'binary_miou'
105-
106-
def __init__(self, eps=1e-7, threshold=0.5, activation=None, ignore_channels=None, **kwargs):
107-
super().__init__(**kwargs)
108-
self.eps = eps
109-
self.threshold = threshold
110-
self.activation = Activation(activation)
111-
self.ignore_channels = ignore_channels
112-
113-
def forward(self, y_pr, y_gt):
114-
y_pr = self.activation(y_pr)
115-
return F.binary_miou(
116-
y_pr, y_gt,
117-
eps=self.eps,
118-
threshold=self.threshold,
119-
ignore_channels=self.ignore_channels,
120-
)
121102

0 commit comments

Comments
 (0)