Skip to content

Commit ecda3c9

Browse files
authored
Merge pull request #25 from scaleapi/v0.5
V0.5
2 parents 0d1058b + 4e4c96a commit ecda3c9

16 files changed

+973
-444
lines changed

.DS_Store

6 KB
Binary file not shown.

README.md

Lines changed: 26 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ client = nucleus.NucleusClient("YOUR_API_KEY_HERE")
3939

4040
### Create Dataset
4141
```python
42-
response = client.create_dataset({"name": "My Dataset"})
43-
dataset = client.get_dataset(response["dataset_id"])
42+
dataset = client.create_dataset("My Dataset")
4443
```
4544

4645
### List Datasets
@@ -56,28 +55,17 @@ client.delete_dataset("YOUR_DATASET_ID")
5655
```
5756

5857
### 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.
6159
```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"})
6462
```
6563

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:
6765
```python
68-
response = dataset.append({"items": [datasetItem2]})
66+
response = dataset.append([dataset_item_1, dataset_item_2])
6967
```
7068

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-
8169
### Get Dataset Info
8270
Tells us the dataset name, number of dataset items, model_runs, and slice_ids.
8371
```python
@@ -104,7 +92,9 @@ item = dataset.loc("dataset_item_id")
10492
Upload groundtruth annotations for the items in your dataset.
10593
Box2DAnnotation has same format as https://dashboard.scale.com/nucleus/docs/api#add-ground-truth
10694
```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])
10898
```
10999

110100
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.
114104
Models are independent of any dataset.
115105

116106
```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"})
118108
```
119109

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
127115
```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])
129120
```
130121

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.
133126
```python
134-
model_run.info
127+
model_run.commit()
135128
```
136129

137-
### Upload Predictions to ModelRun
138-
This method populates the model_run object with predictions.
130+
### Get ModelRun Info
139131
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
142132
```python
143-
payload = {"annotations": List[Box2DPrediction]}
144-
model_run.predict(payload)
133+
model_run.info
145134
```
146135

147136
### Accessing ModelRun Predictions
@@ -160,14 +149,6 @@ model_run.iloc(0)
160149
model_run.loc("dataset_item_id")
161150
```
162151

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-
171152
### Delete ModelRun
172153
Delete a model run using the target model_run_id.
173154

0 commit comments

Comments
 (0)