|
104 | 104 | from .upload_response import UploadResponse |
105 | 105 |
|
106 | 106 | if TYPE_CHECKING: |
107 | | - from . import NucleusClient |
| 107 | + from . import Model, NucleusClient |
108 | 108 |
|
109 | 109 | # TODO: refactor to reduce this file to under 1000 lines. |
110 | 110 | # pylint: disable=C0302 |
@@ -2303,3 +2303,41 @@ def add_items_from_dir( |
2303 | 2303 |
|
2304 | 2304 | else: |
2305 | 2305 | 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 | + ) |
0 commit comments