Skip to content

Commit 26c86f3

Browse files
aobo-ymeta-codesync[bot]
authored andcommitted
set values in MMImageMaskInput (#1675)
Summary: Pull Request resolved: #1675 previously `InterpretableInput` is only used for text, the `values` are the actual text segments, which are used in `AttributionResult` for plot legends. This design no longer makes sense for image. Will redesign the `values`. But for now, just set `values` for plot legends Reviewed By: craymichael Differential Revision: D87891825 fbshipit-source-id: 5b8e739f44d7b5983cdeff609a38cb53b48c7c88
1 parent ff0eaf3 commit 26c86f3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

captum/attr/_utils/interpretable_input.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ class MMImageMaskInput(InterpretableInput):
572572
n_itp_features: int
573573
original_model_inputs: Any
574574
mask_id_to_idx: Dict[int, int]
575-
values: List[str] = [] # no use for now
575+
values: List[str]
576576

577577
def __init__(
578578
self,
@@ -606,6 +606,10 @@ def __init__(
606606

607607
self.original_model_inputs = processor_fn(image)
608608

609+
# temporarily for compatibility with AttributionResult
610+
# which use the values for plot legends
611+
self.values = [f"image_feature_{mid}" for mid in mask_ids]
612+
609613
def to_tensor(self) -> Tensor:
610614
return torch.tensor([[1.0] * self.n_itp_features])
611615

0 commit comments

Comments
 (0)