@@ -28,171 +28,7 @@ pip install --upgrade scale-nucleus
28
28
29
29
## Usage
30
30
31
- The first step to using the Nucleus library is instantiating a client object.
32
- The client abstractions serves to authenticate the user and act as the gateway
33
- for users to interact with their datasets, models, and model runs.
34
-
35
- ### Create a client object
36
-
37
- ``` python
38
- import nucleus
39
- client = nucleus.NucleusClient(" YOUR_API_KEY_HERE" )
40
- ```
41
-
42
- ### Create Dataset
43
-
44
- ``` python
45
- dataset = client.create_dataset(" My Dataset" )
46
- ```
47
-
48
- ### List Datasets
49
-
50
- ``` python
51
- datasets = client.list_datasets()
52
- ```
53
- ### List Jobs
54
- ``` python
55
- jobs = client.list_jobs()
56
- ```
57
- ### Delete a Dataset
58
-
59
- By specifying target dataset id.
60
- A response code of 200 indicates successful deletion.
61
-
62
- ``` python
63
- client.delete_dataset(" YOUR_DATASET_ID" )
64
- ```
65
-
66
- ### Append Items to a Dataset
67
-
68
- You can append both local images and images from the web. Simply specify the location and Nucleus will automatically infer if it's remote or a local file.
69
-
70
- ``` python
71
- dataset_item_1 = DatasetItem(image_location = " ./1.jpeg" , reference_id = " 1" , metadata = {" key" : " value" })
72
- dataset_item_2 = DatasetItem(image_location = " s3://srikanth-nucleus/9-1.jpg" , reference_id = " 2" , metadata = {" key" : " value" })
73
- ```
74
-
75
- The append function expects a list of ` DatasetItem ` objects to upload, like this:
76
-
77
- ``` python
78
- response = dataset.append([dataset_item_1, dataset_item_2])
79
- ```
80
-
81
- ### Get Dataset Info
82
-
83
- Tells us the dataset name, number of dataset items, model_runs, and slice_ids.
84
-
85
- ``` python
86
- dataset.info
87
- ```
88
-
89
- ### Access Dataset Items
90
-
91
- There are three methods to access individual Dataset Items:
92
-
93
- (1) Dataset Items are accessible by reference id
94
-
95
- ``` python
96
- item = dataset.refloc(" my_img_001.png" )
97
- ```
98
-
99
- (2) Dataset Items are accessible by index
100
-
101
- ``` python
102
- item = dataset.iloc(0 )
103
- ```
104
-
105
- (3) Dataset Items are accessible by the dataset_item_id assigned internally
106
-
107
- ``` python
108
- item = dataset.loc(" dataset_item_id" )
109
- ```
110
-
111
- ### Add Annotations
112
-
113
- Upload groundtruth annotations for the items in your dataset.
114
- Box2DAnnotation has same format as https://dashboard.scale.com/nucleus/docs/api#add-ground-truth
115
-
116
- ``` python
117
- annotation_1 = BoxAnnotation(reference_id = " 1" , label = " label" , x = 0 , y = 0 , width = 10 , height = 10 , annotation_id = " ann_1" , metadata = {})
118
- annotation_2 = BoxAnnotation(reference_id = " 2" , label = " label" , x = 0 , y = 0 , width = 10 , height = 10 , annotation_id = " ann_2" , metadata = {})
119
- response = dataset.annotate([annotation_1, annotation_2])
120
- ```
121
-
122
- For particularly large payloads, please reference the accompanying scripts in ** references**
123
-
124
- ### Add Model
125
-
126
- The model abstraction is intended to represent a unique architecture.
127
- Models are independent of any dataset.
128
-
129
- ``` python
130
- model = client.add_model(name = " My Model" , reference_id = " newest-cnn-its-new" , metadata = {" timestamp" : " 121012401" })
131
- ```
132
-
133
- ### Upload Predictions to ModelRun
134
-
135
- This method populates the model_run object with predictions. ` ModelRun ` objects need to reference a ` Dataset ` that has been created.
136
- Returns the associated model_id, human-readable name of the run, status, and user specified metadata.
137
- Takes a list of Box2DPredictions within the payload, where Box2DPrediction
138
- is formulated as in https://dashboard.scale.com/nucleus/docs/api#upload-model-outputs
139
-
140
- ``` python
141
- prediction_1 = BoxPrediction(reference_id = " 1" , label = " label" , x = 0 , y = 0 , width = 10 , height = 10 , annotation_id = " pred_1" , confidence = 0.9 )
142
- prediction_2 = BoxPrediction(reference_id = " 2" , label = " label" , x = 0 , y = 0 , width = 10 , height = 10 , annotation_id = " pred_2" , confidence = 0.2 )
143
-
144
- model_run = model.create_run(name = " My Model Run" , metadata = {" timestamp" : " 121012401" }, dataset = dataset, predictions = [prediction_1, prediction_2])
145
- ```
146
-
147
- ### Commit ModelRun
148
-
149
- The commit action indicates that the user is finished uploading predictions associated
150
- with this model run. Committing a model run kicks off Nucleus internal processes
151
- to calculate performance metrics like IoU. After being committed, a ModelRun object becomes immutable.
152
-
153
- ``` python
154
- model_run.commit()
155
- ```
156
-
157
- ### Get ModelRun Info
158
-
159
- Returns the associated model_id, human-readable name of the run, status, and user specified metadata.
160
-
161
- ``` python
162
- model_run.info
163
- ```
164
-
165
- ### Accessing ModelRun Predictions
166
-
167
- You can access the modelRun predictions for an individual dataset_item through three methods:
168
-
169
- (1) user specified reference_id
170
-
171
- ``` python
172
- model_run.refloc(" my_img_001.png" )
173
- ```
174
-
175
- (2) Index
176
-
177
- ``` python
178
- model_run.iloc(0 )
179
- ```
180
-
181
- (3) Internally maintained dataset_item_id
182
-
183
- ``` python
184
- model_run.loc(" dataset_item_id" )
185
- ```
186
-
187
- ### Delete ModelRun
188
-
189
- Delete a model run using the target model_run_id.
190
-
191
- A response code of 200 indicates successful deletion.
192
-
193
- ``` python
194
- client.delete_model_run(" model_run_id" )
195
- ```
31
+ For the most up to date documentation, reference: https://dashboard.scale.com/nucleus/docs/api?language=python .
196
32
197
33
## For Developers
198
34
0 commit comments