@@ -39,8 +39,7 @@ client = nucleus.NucleusClient("YOUR_API_KEY_HERE")
39
39
40
40
### Create Dataset
41
41
``` python
42
- response = client.create_dataset({" name" : " My Dataset" })
43
- dataset = client.get_dataset(response[" dataset_id" ])
42
+ dataset = client.create_dataset(" My Dataset" )
44
43
```
45
44
46
45
### List Datasets
@@ -56,28 +55,17 @@ client.delete_dataset("YOUR_DATASET_ID")
56
55
```
57
56
58
57
### Append Items to a Dataset
59
- You can append both local images and images from the web.
60
- Each image object is a dictionary with three fields:
58
+ 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.
61
59
``` python
62
- datasetItem1 = { " image_url " : " http://<my_image_url> " , " reference_id " : " my_image_name.jpg " ,
63
- " metadata " : { " label " : " 0 " }}
60
+ dataset_item_1 = DatasetItem( image_location = " ./1.jpeg " , reference_id = " 1 " , metadata = { " key " : " value " })
61
+ dataset_item_2 = DatasetItem( image_location = " s3://srikanth-nucleus/9-1.jpg " , reference_id = " 2 " , metadata = { " key " : " value " })
64
62
```
65
63
66
- The append function expects a list of datasetItems to upload, like this:
64
+ The append function expects a list of ` DatasetItem ` objects to upload, like this:
67
65
``` python
68
- response = dataset.append({ " items " : [datasetItem2]} )
66
+ response = dataset.append([dataset_item_1, dataset_item_2] )
69
67
```
70
68
71
- If you're uploading a local image, you can specify a filepath as the image_url.
72
- ``` python
73
- datasetItem2 = {" image_url" : " ./data_folder/my_img_001.png" , " reference_id" : " my_img_001.png" ,
74
- " metadata" : {" label" : " 1" }}
75
- response = dataset.append({" items" : [datasetItem2]}, local = True )
76
- ```
77
-
78
- For particularly large item uploads, consider using one of the example scripts located in ** references**
79
- These scripts upload items in batches for easier debugging.
80
-
81
69
### Get Dataset Info
82
70
Tells us the dataset name, number of dataset items, model_runs, and slice_ids.
83
71
``` python
@@ -104,7 +92,9 @@ item = dataset.loc("dataset_item_id")
104
92
Upload groundtruth annotations for the items in your dataset.
105
93
Box2DAnnotation has same format as https://dashboard.scale.com/nucleus/docs/api#add-ground-truth
106
94
``` python
107
- response = dataset.annotate({" annotations:" [Box2DAnnotation, ... , Box2DAnnotation]})
95
+ annotation_1 = BoxAnnotation(reference_id = " 1" , label = " label" , x = 0 , y = 0 , width = 10 , height = 10 , metadata = {})
96
+ annotation_2 = BoxAnnotation(reference_id = " 2" , label = " label" , x = 0 , y = 0 , width = 10 , height = 10 , metadata = {})
97
+ response = dataset.annotate([annotation_1, annotation_2])
108
98
```
109
99
110
100
For particularly large payloads, please reference the accompanying scripts in ** references**
@@ -114,34 +104,33 @@ The model abstraction is intended to represent a unique architecture.
114
104
Models are independent of any dataset.
115
105
116
106
``` python
117
- response = client.add_model({ " name" : " My Model" , " reference_id" : " model-0.5 " , " metadata" : { " iou_thr " : 0.5 } })
107
+ model = client.add_model(name = " My Model" , reference_id = " newest-cnn-its-new " , metadata = { " timestamp " : " 121012401 " })
118
108
```
119
109
120
- ### Create Model Run
121
- In contrast to the model abstraction, the model run abstraction
122
- represents an experiment. A model run is associated with both a model and
123
- a dataset. A model run is meant to represent "the predictions of model y on
124
- dataset x"
125
-
126
- Creating a model run returns a ModelRun object.
110
+ ### Upload Predictions to ModelRun
111
+ This method populates the model_run object with predictions. ` ModelRun ` objects need to reference a ` Dataset ` that has been created.
112
+ Returns the associated model_id, human-readable name of the run, status, and user specified metadata.
113
+ Takes a list of Box2DPredictions within the payload, where Box2DPrediction
114
+ is formulated as in https://dashboard.scale.com/nucleus/docs/api#upload-model-outputs
127
115
``` python
128
- model_run = dataset.create_model_run({" reference_id" : " model-0.5" })
116
+ prediction_1 = BoxPrediction(reference_id = " 1" , label = " label" , x = 0 , y = 0 , width = 10 , height = 10 , confidence = 0.9 )
117
+ prediction_2 = BoxPrediction(reference_id = " 2" , label = " label" , x = 0 , y = 0 , width = 10 , height = 10 , confidence = 0.2 )
118
+
119
+ model_run = model.create_run(name = " My Model Run" , metadata = {" timestamp" : " 121012401" }, dataset = dataset, predictions = [prediction_1, prediction_2])
129
120
```
130
121
131
- ### Get ModelRun Info
132
- Returns the associated model_id, human-readable name of the run, status, and user specified metadata.
122
+ ### Commit ModelRun
123
+ The commit action indicates that the user is finished uploading predictions associated
124
+ with this model run. Committing a model run kicks off Nucleus internal processes
125
+ to calculate performance metrics like IoU. After being committed, a ModelRun object becomes immutable.
133
126
``` python
134
- model_run.info
127
+ model_run.commit()
135
128
```
136
129
137
- ### Upload Predictions to ModelRun
138
- This method populates the model_run object with predictions.
130
+ ### Get ModelRun Info
139
131
Returns the associated model_id, human-readable name of the run, status, and user specified metadata.
140
- Takes a list of Box2DPredictions within the payload, where Box2DPrediction
141
- is formulated as in https://dashboard.scale.com/nucleus/docs/api#upload-model-outputs
142
132
``` python
143
- payload = {" annotations" : List[Box2DPrediction]}
144
- model_run.predict(payload)
133
+ model_run.info
145
134
```
146
135
147
136
### Accessing ModelRun Predictions
@@ -160,14 +149,6 @@ model_run.iloc(0)
160
149
model_run.loc(" dataset_item_id" )
161
150
```
162
151
163
- ### Commit ModelRun
164
- The commit action indicates that the user is finished uploading predictions associated
165
- with this model run. Committing a model run kicks off Nucleus internal processes
166
- to calculate performance metrics like IoU. After being committed, a ModelRun object becomes immutable.
167
- ``` python
168
- model_run.commit()
169
- ```
170
-
171
152
### Delete ModelRun
172
153
Delete a model run using the target model_run_id.
173
154
0 commit comments