Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ 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.15.11](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.15.11) - 2023-09-15

### Added
- Added `slice.export_raw_json()` functionality to support raw export of object slices (annotations, predictions, item and scene level data). Currently does not support image slices.


## [0.15.10](https://github.com/scaleapi/nucleus-python-client/releases/tag/v0.15.10) - 2023-07-20

### Added
Expand Down
30 changes: 30 additions & 0 deletions nucleus/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from nucleus.constants import EXPORT_FOR_TRAINING_KEY, EXPORTED_ROWS, ITEMS_KEY
from nucleus.dataset_item import DatasetItem
from nucleus.errors import NucleusAPIError
from nucleus.prediction import Prediction
from nucleus.prediction import from_json as prediction_from_json
from nucleus.scene import Scene
from nucleus.utils import (
Expand Down Expand Up @@ -458,6 +459,35 @@ def export_predictions(
)
return convert_export_payload(api_payload[EXPORTED_ROWS], True)

def export_raw_json(
self,
) -> List[Union[DatasetItem, Annotation, Prediction, Scene]]:
"""Exports object slices in a raw JSON format. Note that it currently does not support item-level slices.

For each object or match in an object slice, this method exports the following information:
- The item that contains the object.
- The prediction and/or annotation (both, if the slice is based on IOU matches).
- If the object is part of a scene, it includes scene-level attributes in the export.

Returns:
An iterable where each element is a dictionary containing JSON-formatted data.
::

List[{
"item": DatasetItem (as JSON),
"annotation": BoxAnnotation/CuboidAnnotation (as JSON)
"prediction": BoxPrediction/CuboidPrediction (as JSON)
"scene": Scene (as JSON)
}
}]
"""
api_payload = self._client.make_request(
payload=None,
route=f"slice/{self.id}/export_raw_json",
requests_command=requests.get,
)
return api_payload

def export_predictions_generator(
self, model
) -> Iterable[Dict[str, Union[DatasetItem, Dict[str, List[Annotation]]]]]:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ exclude = '''

[tool.poetry]
name = "scale-nucleus"
version = "0.15.10"
version = "0.15.11"
description = "The official Python client library for Nucleus, the Data Platform for AI"
license = "MIT"
authors = ["Scale AI Nucleus Team <nucleusapi@scaleapi.com>"]
Expand Down