|
11 | 11 | from nucleus.constants import EXPORT_FOR_TRAINING_KEY, EXPORTED_ROWS, ITEMS_KEY
|
12 | 12 | from nucleus.dataset_item import DatasetItem
|
13 | 13 | from nucleus.errors import NucleusAPIError
|
| 14 | +from nucleus.prediction import Prediction |
14 | 15 | from nucleus.prediction import from_json as prediction_from_json
|
15 | 16 | from nucleus.scene import Scene
|
16 | 17 | from nucleus.utils import (
|
@@ -458,6 +459,35 @@ def export_predictions(
|
458 | 459 | )
|
459 | 460 | return convert_export_payload(api_payload[EXPORTED_ROWS], True)
|
460 | 461 |
|
| 462 | + def export_raw_json( |
| 463 | + self, |
| 464 | + ) -> List[Union[DatasetItem, Annotation, Prediction, Scene]]: |
| 465 | + """Exports object slices in a raw JSON format. Note that it currently does not support item-level slices. |
| 466 | +
|
| 467 | + For each object or match in an object slice, this method exports the following information: |
| 468 | + - The item that contains the object. |
| 469 | + - The prediction and/or annotation (both, if the slice is based on IOU matches). |
| 470 | + - If the object is part of a scene, it includes scene-level attributes in the export. |
| 471 | +
|
| 472 | + Returns: |
| 473 | + An iterable where each element is a dictionary containing JSON-formatted data. |
| 474 | + :: |
| 475 | +
|
| 476 | + List[{ |
| 477 | + "item": DatasetItem (as JSON), |
| 478 | + "annotation": BoxAnnotation/CuboidAnnotation (as JSON) |
| 479 | + "prediction": BoxPrediction/CuboidPrediction (as JSON) |
| 480 | + "scene": Scene (as JSON) |
| 481 | + } |
| 482 | + }] |
| 483 | + """ |
| 484 | + api_payload = self._client.make_request( |
| 485 | + payload=None, |
| 486 | + route=f"slice/{self.id}/export_raw_json", |
| 487 | + requests_command=requests.get, |
| 488 | + ) |
| 489 | + return api_payload |
| 490 | + |
461 | 491 | def export_predictions_generator(
|
462 | 492 | self, model
|
463 | 493 | ) -> Iterable[Dict[str, Union[DatasetItem, Dict[str, List[Annotation]]]]]:
|
|
0 commit comments