Skip to content

Commit 31d4dc0

Browse files
ovalle15ovalle15
authored andcommitted
Include method to access the mask url
1 parent 4a7b2ec commit 31d4dc0

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

examples/basics/export_data.ipynb

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,20 +345,43 @@
345345
{
346346
"metadata": {},
347347
"source": [
348-
"## How to access a `Mask` URL \n",
349-
"Only applicable for Image and Video data types"
348+
"## How to access a `mask` URL \n",
349+
"\n",
350+
"Annotations of the kind `ImageSegmentationMask` and `VideoSegmentationMask` can only be present in labels made on image or video data rows, respectively. In order to access the mask data, you must pass your Labelbox API key stored in `client.headers` in an API request.\n",
351+
"\n",
352+
"When you grab a URL from the mask annotation in the export, the `project_id` and `feature_id` will already be in place. Here, we provide the framework for structuring a URL with any project ID and feature ID."
350353
],
351354
"cell_type": "markdown"
352355
},
353356
{
354357
"metadata": {},
355358
"source": [
356-
"mask_url = f\"https://api.labelbox.com/api/v1/projects/{project_id}/annotations/{feature_id}/index/1/mask\"\n",
357-
"req = urllib.request.Request(mask_url, headers=client.headers)\n",
359+
"# Provide a project ID and feature ID. Alternatively, replace the entire mask_url with a URL grabbed from your export.\n",
360+
"project_id = \"\"\n",
361+
"feature_id = \"\"\n",
358362
"\n",
359-
"## Print the image \n",
363+
"mask_url = f\"https://api.labelbox.com/api/v1/projects/{project_id}/annotations/{feature_id}/index/1/mask\""
364+
],
365+
"cell_type": "code",
366+
"outputs": [],
367+
"execution_count": null
368+
},
369+
{
370+
"metadata": {},
371+
"source": [
372+
"# Make the API request \n",
373+
"req = urllib.request.Request(mask_url, headers=client.headers)"
374+
],
375+
"cell_type": "code",
376+
"outputs": [],
377+
"execution_count": null
378+
},
379+
{
380+
"metadata": {},
381+
"source": [
382+
"# Print the image of the mask\n",
360383
"image = Image.open(urllib.request.urlopen(req))\n",
361-
"image"
384+
"image\n"
362385
],
363386
"cell_type": "code",
364387
"outputs": [

0 commit comments

Comments
 (0)