Skip to content

Commit 161ad0d

Browse files
committed
remove pixel count as arg
1 parent a4450a2 commit 161ad0d

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

src/valor_lite/semantic_segmentation/computation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def filter_cache(
77
datum_mask: NDArray[np.bool_],
88
label_mask: NDArray[np.bool_],
99
number_of_labels: int,
10-
) -> tuple[NDArray[np.int64]]:
10+
) -> NDArray[np.int64]:
1111
"""
1212
Performs the filter operation over the internal cache.
1313
@@ -110,7 +110,6 @@ def compute_intermediates(
110110

111111
def compute_metrics(
112112
confusion_matrices: NDArray[np.int64],
113-
n_pixels: int,
114113
) -> tuple[
115114
NDArray[np.float64],
116115
NDArray[np.float64],
@@ -152,6 +151,7 @@ def compute_metrics(
152151
Unmatched ground truth ratios.
153152
"""
154153
n_labels = confusion_matrices.shape[-1] - 1
154+
n_pixels = confusion_matrices.sum()
155155
label_metadata = np.zeros((n_labels, 2), dtype=np.int64)
156156
label_metadata[:, 0] = confusion_matrices[:, 1:, :].sum(axis=(0, 2))
157157
label_metadata[:, 1] = confusion_matrices[:, :, 1:].sum(axis=(0, 1))

src/valor_lite/semantic_segmentation/manager.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def create_filter(
200200
),
201201
)
202202

203-
def filter(self, filter_: Filter) -> tuple[NDArray[np.int64]]:
203+
def filter(self, filter_: Filter) -> NDArray[np.int64]:
204204
"""
205205
Performs the filter operation over the internal cache.
206206
@@ -236,15 +236,11 @@ def compute_precision_recall_iou(
236236
"""
237237
if filter_ is not None:
238238
confusion_matrices = self.filter(filter_)
239-
n_pixels = filter_.metadata.number_of_pixels
240239
else:
241240
confusion_matrices = self._confusion_matrices
242-
label_metadata = self._label_metadata
243-
n_pixels = self.metadata.number_of_pixels
244241

245242
results = compute_metrics(
246243
confusion_matrices=confusion_matrices,
247-
n_pixels=n_pixels,
248244
)
249245
return unpack_precision_recall_iou_into_metric_lists(
250246
results=results,

0 commit comments

Comments
 (0)