Skip to content

Commit 3564310

Browse files
authored
[Validate] Fix instance segmentation metrics (#317)
1 parent 076bb6e commit 3564310

File tree

10 files changed

+1104
-345
lines changed

10 files changed

+1104
-345
lines changed

.circleci/config.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,17 +137,15 @@ jobs:
137137
command: |
138138
pip install --upgrade pip
139139
name: Upgrade pip
140-
# - python/install-packages:
141-
# pkg-manager: poetry
142140
- run:
143141
command: |
144142
poetry build
145-
name: Test it
143+
name: Build the package
146144
- run:
147145
command: |
148146
export FOUND_PKG=$(find ./dist -name "*.tar.gz")
149147
pip install $FOUND_PKG
150-
name: Test it
148+
name: Install with Python Version
151149
workflows:
152150
nightly_build_test:
153151
triggers:
@@ -165,7 +163,7 @@ workflows:
165163
- test_poetry_installation:
166164
matrix:
167165
parameters:
168-
python_version: ['3.6', '3.7', '3.8', '3.9'] #, '3.10'] Haven't gotten the 3.10 test to work
166+
python_version: ['3.6', '3.7', '3.8', '3.9'] #, '3.10'] Haven't gotten the 3.10 poetry install test to work
169167
context: Nucleus
170168
- test_client_installation:
171169
matrix:

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ 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.1](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.14.1) - 2022-06-20
9+
10+
### Fixed
11+
- Adapt Segmentation metrics to better support instance segmentation
12+
- Change Segmentation/Polygon metrics to use new segmentation metrics
13+
814

915
## [0.14.0](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.14.0) - 2022-06-16
1016

nucleus/metrics/cuboid_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,4 @@ def detection_iou(
357357
meter_3d.append(iou_3d[i, j])
358358
meter_2d.append(iou_2d[i, j])
359359

360-
meter_3d = np.array(meter_3d)
361-
meter_2d = np.array(meter_2d)
362-
return meter_3d, meter_2d
360+
return np.array(meter_3d), np.array(meter_2d)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
from typing import Dict
2+
3+
import numpy as np
4+
from PIL import Image
5+
6+
try:
7+
import fsspec
8+
except ModuleNotFoundError:
9+
from ..package_not_installed import PackageNotInstalled
10+
11+
fsspec = PackageNotInstalled
12+
13+
14+
class SegmentationMaskLoader:
15+
def __init__(self, fs: fsspec):
16+
self.fs = fs
17+
18+
def fetch(self, url: str):
19+
with self.fs.open(url) as fh:
20+
img = Image.open(fh)
21+
return np.asarray(img)
22+
23+
24+
class InMemoryLoader:
25+
"""We use this loader in the tests, this allows us to serve images from memory instead of fetching
26+
from a filesystem.
27+
"""
28+
29+
def __init__(self, url_to_array: Dict[str, np.ndarray]):
30+
self.url_to_array = url_to_array
31+
32+
def fetch(self, url: str):
33+
array = self.url_to_array[url]
34+
return array

0 commit comments

Comments
 (0)