You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"print(f\"Failed data rows: {task.failed_data_rows}\")"
126
+
],
127
+
"cell_type": "code",
128
+
"outputs": [
129
+
{
130
+
"name": "stdout",
131
+
"output_type": "stream",
132
+
"text": [
133
+
"Errors: None\n",
134
+
"Failed data rows: None\n"
135
+
]
136
+
}
137
+
],
138
+
"execution_count": null
139
+
},
140
+
{
141
+
"metadata": {},
142
+
"source": [
143
+
"## Step 2: Create/select an ontology that matches model\n",
144
+
"\n",
145
+
"Your project should have the correct ontology setup with all the tools and classifications supported for your model and data type.\n",
146
+
"\n",
147
+
"For example, when using Amazon Rekognition you would need to create a bounding box annotation for your ontology since it only supports object detection. Likewise when using YOLOv8 you would need to create a classification annotation for your ontology since it only supports image classification. \n",
148
+
"\n",
149
+
"In this tutorial, we will use Amazon Rekognition to detect objects in an image dataset. "
150
+
],
151
+
"cell_type": "markdown"
152
+
},
153
+
{
154
+
"metadata": {},
155
+
"source": [
156
+
"# Create ontology with two bounding boxes that is included with Amazon Rekognition: Car and Person \n",
"Currently we do not support this workflow through the SDK\n",
200
+
"#### Workflow:\n",
201
+
"\n",
202
+
"1. Navigate to model and select ***Create*** > ***App***\n",
203
+
"\n",
204
+
"2. Select ***Amazon Rekognition*** and name your foundry application\n",
205
+
"\n",
206
+
"3. Customize your perimeters and then select ***Save & Create***"
207
+
],
208
+
"cell_type": "markdown"
209
+
},
210
+
{
211
+
"metadata": {},
212
+
"source": [
213
+
"#Select your foundry application inside the UI and copy the APP ID from the top right corner\n",
214
+
"AMAZON_REKOGNITION_APP_ID = \"\""
215
+
],
216
+
"cell_type": "code",
217
+
"outputs": [],
218
+
"execution_count": null
219
+
},
220
+
{
221
+
"metadata": {},
222
+
"source": [
223
+
"## Step 5: Run foundry app on data rows\n",
224
+
"\n",
225
+
"This step is meant to generate annotations that can later be reused as pre-labels in a project. You must provide your app ID from the previous step for this method to run, please see the [Foundry Apps Guide](https://docs.labelbox.com/docs/foundry-apps#run-app-using-sdk) for more information.\n"
" [global_key] # Provide a list of global keys \n",
235
+
" ), \n",
236
+
" app_id=AMAZON_REKOGNITION_APP_ID)\n",
237
+
"\n",
238
+
"task.wait_till_done()\n",
239
+
"\n",
240
+
"print(f\"Errors: {task.errors}\") \n",
241
+
"\n",
242
+
"#Obtain model run ID from task\n",
243
+
"MODEL_RUN_ID = task.metadata[\"modelRunId\"]"
244
+
],
245
+
"cell_type": "code",
246
+
"outputs": [
247
+
{
248
+
"name": "stdout",
249
+
"output_type": "stream",
250
+
"text": [
251
+
"Errors: None\n"
252
+
]
253
+
}
254
+
],
255
+
"execution_count": null
256
+
},
257
+
{
258
+
"metadata": {},
259
+
"source": [
260
+
"## Step 6: Map ontology through the UI\n",
261
+
"\n",
262
+
"Mapping a model's ontology to a project's ontology is currently not supported through the SDK, however, to showcase how to send foundry predictions to a project, we are going to generate the mapping of the foundry app ontology to the project ontology through the UI.\n",
263
+
"\n",
264
+
"#### Workflow\n",
265
+
"\n",
266
+
"1. Navigate to your dataset you created for your model run\n",
267
+
"2. Select **Select all** in the top right corner\n",
268
+
"3. Select **Manage selection** > **Send to Annotate**\n",
269
+
"4. Specify the project we created from the project dropdown menu\n",
270
+
"5. Selecting a workflow step is not required since we are not sending annotations from the UI to a project using this notebook \n",
271
+
"6. Mark **Include model predictions** then scroll down and select **Map**\n",
272
+
"7. Select the incoming ontology and matching ontology feature for both Car and Person\n",
273
+
"8. Once both features are mapped press the **Copy ontology mapping as JSON** in the top right corner\n",
274
+
"9. Do not save this configuration, since we are not sending predictions to a project using this UI modal. We will be sending predictions in the following steps using the SDK"
275
+
],
276
+
"cell_type": "markdown"
277
+
},
278
+
{
279
+
"metadata": {},
280
+
"source": [
281
+
"# Copy map ontology through the UI then paste JSON file here\n",
282
+
"PREDICTIONS_ONTOLOGY_MAPPING = {}"
283
+
],
284
+
"cell_type": "code",
285
+
"outputs": [],
286
+
"execution_count": null
287
+
},
288
+
{
289
+
"metadata": {},
290
+
"source": [
291
+
"## Step 7: Send model generated annotations from catalog to annotate\n",
292
+
"\n",
293
+
"### Parameters\n",
294
+
"\n",
295
+
"When you send predicted data rows to annotate from catalog, you may choose to include or exclude certain parameters, at a minimum a predictions_ontology_mapping will need to be provided:\n",
296
+
"\n",
297
+
"* `predictions_ontology_mapping`\n",
298
+
" - A dictionary containing the mapping of the model's ontology feature schema ids to the project's ontology feature schema ids\n",
299
+
"* `exclude_data_rows_in_project`\n",
300
+
" - Excludes data rows that are already in the project. \n",
301
+
"* `override_existing_annotations_rule` \n",
302
+
" - The strategy defining how to handle conflicts in classifications between the data rows that already exist in the project and incoming predictions from the source model run or annotations from the source project. \n",
303
+
" * Defaults to ConflictResolutionStrategy.KeepExisting\n",
" task_queue_id=None, #ID of workflow task, set ID to None if you want to convert pre-labels to ground truths or obtain task queue id through project.task_queues().\n",
329
+
" batch_name=\"Foundry Demo Batch\",\n",
330
+
" data_rows=lb.GlobalKeys(\n",
331
+
" [global_key] # Provide a list of global keys from foundry app task\n",
0 commit comments