Skip to content

Commit

Permalink
wrapper for uploading LSS predictions (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
jean-lucas authored Apr 15, 2024
1 parent f0d8022 commit f5d8b2d
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
mkdir test_results
set -e
TEST_FILES=$(circleci tests glob "tests/**/test_*.py")
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
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
poetry run coverage report
poetry run coverage html
- store_test_results:
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ All notable changes to the [Nucleus Python Client](https://github.com/scaleapi/n
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.17.5](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.17.5) - 2024-04-15

### Added
- Method for uploading lidar semantic segmentation predictions, via `dataset.upload_lidar_semseg_predictions`

Example usage:

```python
dataset = client.get_dataset("ds_...")
model = client.get_model("prj_...")
pointcloud_ref_id = 'pc_ref_1'
predictions_s3 = "s3://temp/predictions.json"

dataset.upload_lidar_semseg_predictions(model, pointcloud_ref_id, predictions_s3)
```

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)


## [0.17.4](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.17.4) - 2024-03-25

### Modified
Expand Down
40 changes: 39 additions & 1 deletion nucleus/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
from .upload_response import UploadResponse

if TYPE_CHECKING:
from . import NucleusClient
from . import Model, NucleusClient

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

else:
print(f"Did not find any items in {dirname}.")

def upload_lidar_semseg_predictions(
self,
model: "Model",
pointcloud_ref_id: str,
predictions_s3_path: str,
):
"""Upload Lidar Semantic Segmentation predictions for a given pointcloud.
Assuming a pointcloud with only 4 points (three labeled as Car, one labeled as Person),
the contents of the predictions s3 object should be formatted as such:
.. code-block:: json
{
"objects": [
{ "label": "Car", "index": 1},
{ "label": "Person", "index": 2}
],
"point_objects": [1, 1, 1, 2],
"point_confidence": [0.5, 0.9, 0.9, 0.3]
}
The order of the points in the `"point_objects"` should be in the same order as the points that
were originally uploaded to Scale.
Parameters:
model (:class:`Model`): Nucleus model used to store these predictions
pointcloud_ref_id (str): The reference ID of the pointcloud for which these predictions belong to
predictions_s3_path (str): S3 path to where the predictions are stored
"""

return self._client.make_request(
payload={"pointsSegmentationUrl": predictions_s3_path},
route=f"dataset/{self.id}/model/{model.id}/pointcloud/{pointcloud_ref_id}/uploadLSSPrediction",
requests_command=requests.post,
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ignore = ["E501", "E741", "E731", "F401"] # Easy ignore for getting it running

[tool.poetry]
name = "scale-nucleus"
version = "0.17.4"
version = "0.17.5"
description = "The official Python client library for Nucleus, the Data Platform for AI"
license = "MIT"
authors = ["Scale AI Nucleus Team <[email protected]>"]
Expand Down

0 comments on commit f5d8b2d

Please sign in to comment.