Skip to content

Commit f85239a

Browse files
committed
support new api types
1 parent 8337d25 commit f85239a

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

nucleus/constants.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
ANNOTATION_TYPES = (BOX_TYPE, POLYGON_TYPE, SEGMENTATION_TYPE, CUBOID_TYPE)
1212
ANNOTATION_UPDATE_KEY = "update"
1313
AUTOTAGS_KEY = "autotags"
14+
AUTOTAG_SCORE_THRESHOLD = "score_threshold"
1415
EXPORTED_ROWS = "exportedRows"
1516
CAMERA_PARAMS_KEY = "camera_params"
1617
CLASS_PDF_KEY = "class_pdf"
@@ -62,7 +63,8 @@
6263
MODEL_RUN_ID_KEY = "model_run_id"
6364
NAME_KEY = "name"
6465
NEW_ITEMS = "new_items"
65-
NUCLEUS_ENDPOINT = "https://api.scale.com/v1/nucleus"
66+
NUCLEUS_ENDPOINT = "https://jihan-yin-api.devbox.internal.scale.com/v1/nucleus"
67+
# NUCLEUS_ENDPOINT = "https://api.scale.com/v1/nucleus"
6668
NUM_SENSORS_KEY = "num_sensors"
6769
ORIGINAL_IMAGE_URL_KEY = "original_image_url"
6870
POINTCLOUD_KEY = "pointcloud"

nucleus/dataset.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
NAME_KEY,
2525
REFERENCE_IDS_KEY,
2626
REQUEST_ID_KEY,
27+
AUTOTAG_SCORE_THRESHOLD,
2728
UPDATE_KEY,
2829
)
2930
from .dataset_item import (
@@ -86,21 +87,36 @@ def items(self) -> List[DatasetItem]:
8687
return self._client.get_dataset_items(self.id)
8788

8889
@sanitize_string_args
89-
def autotag_scores(self, autotag_name, for_scores_greater_than=0):
90-
"""Export the autotag scores above a threshold, largest scores first.
90+
def autotag_items(self, autotag_name, for_scores_greater_than=0):
91+
"""For a given Autotag of this dataset, export its tagged items with scores above a threshold, largest scores first.
9192
92-
If you have pandas installed, you can create a pandas dataframe using
93+
:return: dictionary of the form
94+
{
95+
'autotagItems': AutotagItem[],
96+
'autotag': Autotag
97+
}
98+
See https://dashboard.nucleus.scale.com/nucleus/docs/api#export-autotag-items for more details on the return types.
99+
"""
100+
response = self._client.make_request(
101+
payload={AUTOTAG_SCORE_THRESHOLD: for_scores_greater_than},
102+
route=f"autotag/dataset/{self.id}/autotag/{autotag_name}/taggedItems",
103+
requests_command=requests.get,
104+
)
105+
return response
93106

94-
pandas.Dataframe(dataset.autotag_scores(autotag_name))
107+
def autotag_training_items(self, autotag_name):
108+
"""For a given Autotag of this dataset, export its training items. These are user selected positives during refinement.
95109
96110
:return: dictionary of the form
97-
{'ref_ids': List[str],
98-
'datset_item_ids': List[str],
99-
'score': List[float]}
111+
{
112+
'autotagTrainingItems': AutotagTrainingItem[],
113+
'autotag': Autotag
114+
}
115+
See https://dashboard.nucleus.scale.com/nucleus/docs/api#export-autotag-training-items for more details on the return types.
100116
"""
101117
response = self._client.make_request(
102118
payload={},
103-
route=f"autotag/{self.id}/{autotag_name}/{for_scores_greater_than}",
119+
route=f"autotag/dataset/{self.id}/autotag/{autotag_name}/trainingItems",
104120
requests_command=requests.get,
105121
)
106122
return response

0 commit comments

Comments
 (0)