Skip to content

Commit

Permalink
Merge branch 'main' into fixes-explain-func
Browse files Browse the repository at this point in the history
  • Loading branch information
annahedstroem authored Feb 29, 2024
2 parents 13ae159 + 692f292 commit 8dcf749
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions quantus/metrics/localisation/attribution_localisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def __init__(
self,
weighted: bool = False,
max_size: float = 1.0,
positive_attributions: bool = False,
abs: bool = True,
normalise: bool = True,
normalise_func: Optional[Callable] = None,
Expand All @@ -76,6 +77,9 @@ def __init__(
default=False.
max_size: float
The maximum ratio for the size of the bounding box to image, default=1.0.
positive_attributions: boolean
Indicates whether only positive attributions should be used, i.e., clipping,
default=False.
abs: boolean
Indicates whether absolute operation is applied on the attribution, default=True.
normalise: boolean
Expand Down Expand Up @@ -118,6 +122,7 @@ def __init__(
# Save metric-specific attributes.
self.weighted = weighted
self.max_size = max_size
self.positive_attributions = positive_attributions
if not self.disable_warnings:
warn.warn_parameterisation(
metric_name=self.__class__.__name__,
Expand Down Expand Up @@ -270,6 +275,8 @@ def evaluate_instance(

# Prepare shapes.
a = a.flatten()
if self.positive_attributions:
a = np.clip(a, 0, None)
s = s.flatten().astype(bool)

# Compute ratio.
Expand Down

0 comments on commit 8dcf749

Please sign in to comment.