Skip to content

Commit

Permalink
fix: handle zero cost saliency
Browse files Browse the repository at this point in the history
  • Loading branch information
danellecline committed Oct 18, 2024
1 parent 7cb5440 commit 2d990e4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions aipipeline/prediction/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ def compute_saliency_contour(contour, min_std: float, img_saliency: np.ndarray,
# The cost function penalizes smaller areas with low variance
cost = (area * (mean_intensity_l + mean_intensity_s + 0.1 * area) - variance) / factor

# If cost is NaN, set it to 1
if np.isnan(cost):
cost = 1

# If the std is too low, then the contour is not interesting; set the cost to 1
if std < min_std:
cost = 1
Expand Down

0 comments on commit 2d990e4

Please sign in to comment.