Skip to content

Commit f5d8b2d

Browse files
authored
wrapper for uploading LSS predictions (#436)
1 parent f0d8022 commit f5d8b2d

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
mkdir test_results
6161
set -e
6262
TEST_FILES=$(circleci tests glob "tests/**/test_*.py")
63-
echo "$TEST_FILES" | circleci tests run --command "xargs poetry run coverage run --include=nucleus/* -m pytest -n auto -s -v -o junit_family=legacy --junitxml=test_results/junit.xml" --verbose --split-by=timings
63+
echo "$TEST_FILES" | circleci tests run --command "xargs poetry run coverage run --include=nucleus/* -m pytest -s -v -o junit_family=legacy --junitxml=test_results/junit.xml" --verbose --split-by=timings
6464
poetry run coverage report
6565
poetry run coverage html
6666
- store_test_results:

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ 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.17.5](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.17.5) - 2024-04-15
9+
10+
### Added
11+
- Method for uploading lidar semantic segmentation predictions, via `dataset.upload_lidar_semseg_predictions`
12+
13+
Example usage:
14+
15+
```python
16+
dataset = client.get_dataset("ds_...")
17+
model = client.get_model("prj_...")
18+
pointcloud_ref_id = 'pc_ref_1'
19+
predictions_s3 = "s3://temp/predictions.json"
20+
21+
dataset.upload_lidar_semseg_predictions(model, pointcloud_ref_id, predictions_s3)
22+
```
23+
24+
For the expected format of the s3 predictions, refer to the [documentation here](https://docs.nucleus.scale.com/en/latest/api/nucleus/index.html#nucleus.Dataset.upload_lidar_semseg_predictions)
25+
26+
827
## [0.17.4](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.17.4) - 2024-03-25
928

1029
### Modified

nucleus/dataset.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
from .upload_response import UploadResponse
105105

106106
if TYPE_CHECKING:
107-
from . import NucleusClient
107+
from . import Model, NucleusClient
108108

109109
# TODO: refactor to reduce this file to under 1000 lines.
110110
# pylint: disable=C0302
@@ -2303,3 +2303,41 @@ def add_items_from_dir(
23032303

23042304
else:
23052305
print(f"Did not find any items in {dirname}.")
2306+
2307+
def upload_lidar_semseg_predictions(
2308+
self,
2309+
model: "Model",
2310+
pointcloud_ref_id: str,
2311+
predictions_s3_path: str,
2312+
):
2313+
"""Upload Lidar Semantic Segmentation predictions for a given pointcloud.
2314+
2315+
Assuming a pointcloud with only 4 points (three labeled as Car, one labeled as Person),
2316+
the contents of the predictions s3 object should be formatted as such:
2317+
2318+
.. code-block:: json
2319+
2320+
{
2321+
"objects": [
2322+
{ "label": "Car", "index": 1},
2323+
{ "label": "Person", "index": 2}
2324+
],
2325+
"point_objects": [1, 1, 1, 2],
2326+
"point_confidence": [0.5, 0.9, 0.9, 0.3]
2327+
}
2328+
2329+
The order of the points in the `"point_objects"` should be in the same order as the points that
2330+
were originally uploaded to Scale.
2331+
2332+
Parameters:
2333+
model (:class:`Model`): Nucleus model used to store these predictions
2334+
pointcloud_ref_id (str): The reference ID of the pointcloud for which these predictions belong to
2335+
predictions_s3_path (str): S3 path to where the predictions are stored
2336+
2337+
"""
2338+
2339+
return self._client.make_request(
2340+
payload={"pointsSegmentationUrl": predictions_s3_path},
2341+
route=f"dataset/{self.id}/model/{model.id}/pointcloud/{pointcloud_ref_id}/uploadLSSPrediction",
2342+
requests_command=requests.post,
2343+
)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ignore = ["E501", "E741", "E731", "F401"] # Easy ignore for getting it running
2525

2626
[tool.poetry]
2727
name = "scale-nucleus"
28-
version = "0.17.4"
28+
version = "0.17.5"
2929
description = "The official Python client library for Nucleus, the Data Platform for AI"
3030
license = "MIT"
3131
authors = ["Scale AI Nucleus Team <nucleusapi@scaleapi.com>"]

0 commit comments

Comments
 (0)