Skip to content

Commit 0440ead

Browse files
authored
[Validate] Fix segmentation confusion masking (#330)
* Copy rows/cols from confusion when filtering instead of masking * Bump and changelog
1 parent 22aea22 commit 0440ead

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to the [Nucleus Python Client](https://github.com/scaleapi/n
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.14.8](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.14.8) - 2022-07-14
9+
10+
### Fixed
11+
- Segmentation metrics filtering. Prior version artificially boosted performance when filtering was applied.
12+
813
## [0.14.7](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.14.7) - 2022-07-07
914

1015
### Added

nucleus/metrics/segmentation_metrics.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -219,25 +219,21 @@ def _is_instance_segmentation(self, annotation, prediction):
219219

220220
def _filter_confusion_matrix(self, confusion, annotation, prediction):
221221
if self.annotation_filters or self.prediction_filters:
222+
new_confusion = np.zeros_like(confusion)
222223
# we mask the confusion matrix instead of the images
223224
if self.annotation_filters:
224225
annotation_indexes = {
225226
segment.index for segment in annotation.annotations
226227
}
227-
indexes_to_remove = (
228-
set(range(confusion.shape[0] - 1)) - annotation_indexes
229-
)
230-
for row in indexes_to_remove:
231-
confusion[row, :] = 0
228+
for row in annotation_indexes:
229+
new_confusion[row, :] = confusion[row, :]
232230
if self.prediction_filters:
233231
prediction_indexes = {
234232
segment.index for segment in prediction.annotations
235233
}
236-
indexes_to_remove = (
237-
set(range(confusion.shape[0] - 1)) - prediction_indexes
238-
)
239-
for col in indexes_to_remove:
240-
confusion[:, col] = 0
234+
for col in prediction_indexes:
235+
new_confusion[:, col] = confusion[:, col]
236+
confusion = new_confusion
241237
return confusion
242238

243239

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exclude = '''
2121

2222
[tool.poetry]
2323
name = "scale-nucleus"
24-
version = "0.14.7"
24+
version = "0.14.8"
2525
description = "The official Python client library for Nucleus, the Data Platform for AI"
2626
license = "MIT"
2727
authors = ["Scale AI Nucleus Team <nucleusapi@scaleapi.com>"]

0 commit comments

Comments
 (0)