Skip to content

Commit

Permalink
Fix error in recall and precision (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
qubvel committed Aug 30, 2019
1 parent e9cac0d commit 687b632
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions segmentation_models/base/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ def precision(gt, pr, class_weights=1, class_indexes=None, smooth=SMOOTH, per_im

# score calculation
tp = backend.sum(gt * pr, axis=axes)
fn = backend.sum(gt, axis=axes) - tp

score = (tp + smooth) / (tp + fn + smooth)
fp = backend.sum(pr, axis=axes) - tp
score = (tp + smooth) / (tp + fp + smooth)
score = average(score, per_image, class_weights, **kwargs)

return score
Expand Down Expand Up @@ -222,9 +222,9 @@ def recall(gt, pr, class_weights=1, class_indexes=None, smooth=SMOOTH, per_image
axes = get_reduce_axes(per_image, **kwargs)

tp = backend.sum(gt * pr, axis=axes)
fp = backend.sum(pr, axis=axes) - tp
fn = backend.sum(gt, axis=axes) - tp

score = (tp + smooth) / (tp + fp + smooth)
score = (tp + smooth) / (tp + fn + smooth)
score = average(score, per_image, class_weights, **kwargs)

return score
Expand Down

0 comments on commit 687b632

Please sign in to comment.