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