{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Create a 3D Point Cloud Labeling Job with Amazon SageMaker Ground Truth\n", "\n", "\n", "This sample notebook takes you through an end-to-end workflow to demonstrate the functionality of SageMaker Ground Truth 3D point cloud built-in task types. \n", "\n", "### What is a Point Cloud\n", "\n", "A point cloud frame is defined as a collection of 3D points describing a 3D scene. Each point is described using three coordinates, x, y, and z. To add color and/or variations in point intensity to the point cloud, points may have additional attributes, such as i for intensity or values for the red (r), green (g), and blue (b) color channels (8-bit). All of the positional coordinates (x, y, z) are in meters. Point clouds are most commonly created from data that was collected by scanning the real world through various scanning methods, such as laser scanning and photogrammetry. Ground Truth currently also supports sensor fusion with video camera data. \n", "\n", "\n", "### 3D Point Cloud Built in Task Types\n", "\n", "You can use Ground Truth 3D point cloud labeling built-in task types to annotate 3D point cloud data. The following list briefly describes each task type. See [3D Point Cloud Task types](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-point-cloud-task-types.html) for more information.\n", "\n", "* 3D point cloud object detection – Use this task type when you want workers to indentify the location of and classify objects in a 3D point cloud by drawing 3D cuboids around objects. You can include one or more attributes for each class (label) you provide.\n", "\n", "\n", "* 3D point cloud object tracking – Use this task type when you want workers to track the trajectory of an object across a sequence of 3D point cloud frames. For example, you can use this task type to ask workers to track the movement of vehicles across a sequence of point cloud frames. This task type can also be used sensor fusion, i.e. when you want workers to link 3D point cloud annotations with 2D images annotations and also link 2D image annotations among various cameras. Note that sensor fusion uses a different label category configuration file.\n", "\n", "\n", "* 3D point cloud semantic segmentation – Use this task type when you want workers to create a point-level semantic segmentation mask by painting objects in a 3D point cloud using different colors where each color is assigned to one of the classes you specify.\n", "\n", "\n", "You can use the Adjustment task types to verify and adjust annotations created for the task types above." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "!pip install boto3==1.14.8\n", "!pip install -U botocore" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 1\n", "import boto3\n", "import botocore\n", "import time\n", "import pprint\n", "import json\n", "import sagemaker\n", "from sagemaker import get_execution_role\n", "from datetime import datetime, timezone\n", "\n", "pp = pprint.PrettyPrinter(indent=4)\n", "\n", "sess = sagemaker.session.Session()\n", "role = sagemaker.get_execution_role()\n", "region = boto3.session.Session().region_name\n", "\n", "sagemaker_client = boto3.client(\"sagemaker\")\n", "s3 = boto3.client(\"s3\")\n", "iam = boto3.client(\"iam\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 2\n", "session = sagemaker.Session()\n", "default_bucket = session.default_bucket()\n", "BUCKET = default_bucket\n", "EXP_NAME = \"3d-point-cloud\" # Any valid S3 prefix, leave it empty unless there is a subfolder for labeling artifacts." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 3\n", "\n", "# Make sure the bucket is in the same region as this notebook.\n", "bucket_region = s3.head_bucket(Bucket=BUCKET)[\"ResponseMetadata\"][\"HTTPHeaders\"][\n", " \"x-amz-bucket-region\"\n", "]\n", "assert (\n", " bucket_region == region\n", "), \"Your S3 bucket {} and this notebook need to be in the same region.\".format(BUCKET)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Copy and modify files from the sample bucket\n", "\n", "The sample files for this demo are in a public bucket to provide you with the inputs to try this demo. In order for this demo to work, we will need to copy these files from local notebook environment to the default S3 bucket so that there are in a place where you have read/write access." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "%%bash -s \"$BUCKET\"\n", "\n", "find ./sample_files/ -type f -name \"*.json\" -print0 | xargs -0 sed -i -e \"s/\\$BUCKET/$1/g\"\n", "\n", "aws s3 cp ./sample_files/ s3://$1/artifacts/gt-point-cloud-demos/ --quiet --recursive" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The Dataset and Resources" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The dataset and resources used in this notebook are located in the following Amazon S3 bucket. The buckets contain: The data to be labeled, configuration files that configure label tasks, input manifest files that Ground Truth uses to read the data files, and output manifest files. The output file contains the results of the labeling job. All the datasets used here are referred from the blog https://github.com/aws/amazon-sagemaker-examples/tree/main/ground_truth_labeling_jobs/3d_point_cloud_demo" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 5\n", "!aws s3 ls s3://$BUCKET/artifacts/gt-point-cloud-demos/" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Input Data and Input Manifest File\n", "\n", "The following task types (and associated adjustment labeling jobs) require the following types of input manifest files. \n", "\n", "* 3D point cloud object detection – frame input manifest\n", "* 3D point cloud semantic segmentation – frame input manifest\n", "* 3D point cloud object tracking – sequence frame input manifest \n", "* 3D-2D point cloud object tracking – sequence frame input manifest " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 6\n", "## Set up manifest_s3_uri_map, to be used to set up Input ManifestS3Uri\n", "\n", "manifest_s3_uri_map = {\n", " \"3DPointCloudObjectDetection\": f\"s3://{BUCKET}/artifacts/gt-point-cloud-demos/manifests/SingleFrame-manifest.json\",\n", " \"3DPointCloudObjectTracking\": f\"s3://{BUCKET}/artifacts/gt-point-cloud-demos/manifests/OT-manifest-10-frame.json\",\n", " \"3DPointCloudSemanticSegmentation\": f\"s3://{BUCKET}/artifacts/gt-point-cloud-demos/manifests/SS-manifest.json\",\n", " \"Adjustment3DPointCloudObjectDetection\": f\"s3://{BUCKET}/artifacts/gt-point-cloud-demos/manifests/OD-adjustment-manifest.json\",\n", " \"Adjustment3DPointCloudObjectTracking\": f\"s3://{BUCKET}/artifacts/gt-point-cloud-demos/manifests/OT-adjustment-manifest.json\",\n", " \"Adjustment3DPointCloudSemanticSegmentation\": f\"s3://{BUCKET}/artifacts/gt-point-cloud-demos/manifests/SS-audit-manifest-5-17.json\",\n", "}" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "### Label Category Configuration File\n", "\n", "Your label category configuration file is used to specify labels, or classes, for your labeling job.\n", "\n", "When you use the object detection or object tracking task types, you can also include [label category attributes](http://docs.aws.amazon.com/sagemaker/latest/dg/sms-point-cloud-general-information.html#sms-point-cloud-worker-task-ui) in your label category configuration file. Workers can assign one or more attributes you provide to annotations to give more information about that object. For example, you may want to use the attribute *occluded* to have workers identify when an object is partially obstructed. " ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "To learn more about the label category configuration file, see [Create a Label Category Configuration File](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-point-cloud-label-category-config.html).\n", "\n", "Run the following cell to identify the labeling category configuration file." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 7\n", "label_category_file_s3_uri_map = {\n", " \"3DPointCloudObjectDetection\": f\"s3://{BUCKET}/artifacts/gt-point-cloud-demos/label-category-config/label-category.json\",\n", " \"3DPointCloudObjectTracking\": f\"s3://{BUCKET}/artifacts/gt-point-cloud-demos/label-category-config/label-category.json\",\n", " \"3DPointCloudSemanticSegmentation\": f\"s3://{BUCKET}/artifacts/gt-point-cloud-demos/label-category-config/label-category.json\",\n", " \"Adjustment3DPointCloudObjectDetection\": f\"s3://{BUCKET}/artifacts/gt-point-cloud-demos/label-category-config/od-adjustment-label-categories-file.json\",\n", " \"Adjustment3DPointCloudObjectTracking\": f\"s3://{BUCKET}/artifacts/gt-point-cloud-demos/label-category-config/ot-adjustment-label-categories-file.json\",\n", " \"Adjustment3DPointCloudSemanticSegmentation\": f\"s3://{BUCKET}/artifacts/gt-point-cloud-demos/label-category-config/SS-audit-5-17-updated-manually-created-label-categories-file.json\",\n", "}" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 8\n", "# You can use this to identify your labeling job by appending these abbreviations to your lableing job name.\n", "name_abbreviation_map = {\n", " \"3DPointCloudObjectDetection\": \"OD\",\n", " \"3DPointCloudObjectTracking\": \"OT\",\n", " \"3DPointCloudSemanticSegmentation\": \"SS\",\n", " \"Adjustment3DPointCloudObjectDetection\": \"OD-ADJ\",\n", " \"Adjustment3DPointCloudObjectTracking\": \"OT-ADJ\",\n", " \"Adjustment3DPointCloudSemanticSegmentation\": \"SS-ADJ\",\n", "}" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "### Identify Resources for Labeling Job" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following will be used to select the HumanTaskUiArn. When you create a 3D point cloud labeling job, Ground Truth provides the worker task UI. The following cell identifies the correct HumanTaskUiArn to use a worker UI that is specific to your task type. You can see examples of the worker UIs on the [3D Point Cloud Task Type](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-point-cloud-task-types.html) pages. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 9\n", "## Set up human_task_ui_arn map\n", "\n", "human_task_ui_arn_map = {\n", " \"3DPointCloudObjectDetection\": f\"arn:aws:sagemaker:{region}:394669845002:human-task-ui/PointCloudObjectDetection\",\n", " \"3DPointCloudObjectTracking\": f\"arn:aws:sagemaker:{region}:394669845002:human-task-ui/PointCloudObjectTracking\",\n", " \"3DPointCloudSemanticSegmentation\": f\"arn:aws:sagemaker:{region}:394669845002:human-task-ui/PointCloudSemanticSegmentation\",\n", " \"Adjustment3DPointCloudObjectDetection\": f\"arn:aws:sagemaker:{region}:394669845002:human-task-ui/PointCloudObjectDetection\",\n", " \"Adjustment3DPointCloudObjectTracking\": f\"arn:aws:sagemaker:{region}:394669845002:human-task-ui/PointCloudObjectTracking\",\n", " \"Adjustment3DPointCloudSemanticSegmentation\": f\"arn:aws:sagemaker:{region}:394669845002:human-task-ui/PointCloudSemanticSegmentation\",\n", "}\n", "\n", "ac_arn_map = {\n", " \"us-west-2\": \"081040173940\",\n", " \"us-east-1\": \"432418664414\",\n", " \"us-east-2\": \"266458841044\",\n", " \"eu-west-1\": \"568282634449\",\n", " \"ap-northeast-1\": \"477331159723\",\n", "}" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "## Select a 3D Point Cloud Labeling Job Task Type" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "In the following cell, select a [3D Point Cloud Task Type](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-point-cloud-task-types.html) by sepcifying a value for `task_type`. The supported task types include: \"3DPointCloudObjectDetection\", \"3DPointCloudObjectTracking\", \"3DPointCloudSemanticSegmentation\", \"Adjustment3DPointCloudObjectDetection\", \"Adjustment3DPointCloudObjectTracking\", \"Adjustment3DPointCloudSemanticSegmentation\"" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "### 3D Point Cloud Object Detection" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 10\n", "task_type = \"3DPointCloudObjectDetection\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For this task type, you will use a **manifest with single-frame per task**. To learn more about the types of 3D Point Cloud input manfiest files, see [3D Point Cloud Input Data](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-point-cloud-input-data.html).\n", "\n", "#### Input Manifest File With Single Frame Per Task\n", "\n", "When you use a frame input manifest for 3D point cloud object detection and semantic segmentation task types, each line in the input manifest will identify the location of a single point cloud file in Amazon S3. When a task is created, workers will be asked to classify or add a segmentation mask to objects in that frame (depending on the task type). \n", "\n", "Let's look at the single-frame input manfiest. You'll see that this manifest file contains the location of a point cloud file in `source-ref`, as well as the pose of the vehicle used to collect the data (ego-vehicle), image pose information and other image data used for sensor fusion. See [Create a Point Cloud Frame Input Manifest File](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-point-cloud-single-frame-input-data.html) to learn more about these parameters. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 11\n", "print(\"\\nThe single-frame input manifest file:\")\n", "with open(\"./sample_files/manifests/SingleFrame-manifest.json\", \"r\") as j:\n", " json_data = json.load(j)\n", " print(\"\\n\", json.dumps(json_data, indent=4, sort_keys=True))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The point cloud data in the file, `0.txt`, identified in the manfiest above is in ASCII format. Each line in the point cloud file contains information about a single point. The first three values are x, y, and z location coordinates, and the last element is the pixel intensity. To learn more about this raw data format, see [ASCII Format](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-point-cloud-raw-data-types.html#sms-point-cloud-raw-data-ascii-format)." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 12\n", "frame = open(\"./sample_files/frames/0.txt\")\n", "print(\"\\nA single line from the point cloud file with x, y, z and pixel intensity values: \\n\")\n", "frame.readline()" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "#### Set up Human Task Configuration\n", "\n", "`HumanTaskConfig` is used to specify your work team, and configure your labeling job tasks. \n", "\n", "If you want to preview the worker task UI, [create a private work team](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-create-private-console.html) and add yourself as a worker. \n", "\n", "If you have already created a private workforce, follow the instructions in [Add or Remove Workers](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-management-private-console.html#add-remove-workers-sm) to add yourself to the work team you use to create a lableing job. \n", "\n", "To find workteam_arn, go to SageMaker console -> Ground Truth -> Labeling workforces -> Private -> copy ARN of the correp" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 13\n", "## Set up Human Task Config\n", "workteam_arn = \"Your-WorkTeam_ARN\"\n", "## Modify the following\n", "task_description = \"Object Detection in 3D point cloud\"\n", "# example keywords\n", "task_keywords = [\"lidar\", \"pointcloud\"]\n", "# add a task title\n", "task_title = \"Bounding Cars\"\n", "# add a job name to identify your labeling job\n", "job_name = \"SF-area1-car-detection-0505-fix\"\n", "\n", "prehuman_arn = \"arn:aws:lambda:{}:{}:function:PRE-{}\".format(region, ac_arn_map[region], task_type)\n", "acs_arn = \"arn:aws:lambda:{}:{}:function:ACS-{}\".format(region, ac_arn_map[region], task_type)\n", "\n", "human_task_config = {\n", " \"AnnotationConsolidationConfig\": {\n", " \"AnnotationConsolidationLambdaArn\": acs_arn,\n", " },\n", " \"WorkteamArn\": workteam_arn,\n", " \"PreHumanTaskLambdaArn\": prehuman_arn,\n", " \"MaxConcurrentTaskCount\": 200, # 200 data objects (frames for OD and SS or sequences for OT) will be sent at a time to the workteam.\n", " \"NumberOfHumanWorkersPerDataObject\": 1, # One worker will work on each task\n", " \"TaskAvailabilityLifetimeInSeconds\": 18000, # Your workteam has 5 hours to complete all pending tasks.\n", " \"TaskDescription\": task_description,\n", " \"TaskKeywords\": task_keywords,\n", " \"TaskTimeLimitInSeconds\": 3600, # Each seq/frame must be labeled within 1 hour.\n", " \"TaskTitle\": task_title,\n", "}\n", "\n", "\n", "human_task_config[\"UiConfig\"] = {\"HumanTaskUiArn\": \"{}\".format(human_task_ui_arn_map[task_type])}\n", "# print(json.dumps(human_task_config, indent=4, sort_keys=True))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Set up Create Labeling Request" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following formats your labeling job request. For 3D point cloud object tracking, 2D-3D point cloud object tracking, and semantic segmentation task types, the `LabelAttributeName` must end in `-ref`. For other task types, the label attribute name may not end in `-ref`. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 14\n", "## Set up Create Labeling Request\n", "\n", "labelAttributeName = job_name + \"-ref\"\n", "\n", "if (\n", " task_type == \"3DPointCloudObjectDetection\"\n", " or task_type == \"Adjustment3DPointCloudObjectDetection\"\n", "):\n", " labelAttributeName = job_name\n", "\n", "\n", "ground_truth_request = {\n", " \"InputConfig\": {\n", " \"DataSource\": {\n", " \"S3DataSource\": {\n", " \"ManifestS3Uri\": \"{}\".format(manifest_s3_uri_map[task_type]),\n", " }\n", " },\n", " \"DataAttributes\": {\n", " \"ContentClassifiers\": [\"FreeOfPersonallyIdentifiableInformation\", \"FreeOfAdultContent\"]\n", " },\n", " },\n", " \"OutputConfig\": {\n", " \"S3OutputPath\": f\"s3://{BUCKET}/{EXP_NAME}/output/\",\n", " },\n", " \"HumanTaskConfig\": human_task_config,\n", " \"LabelingJobName\": job_name,\n", " \"RoleArn\": role,\n", " \"LabelAttributeName\": labelAttributeName,\n", " \"LabelCategoryConfigS3Uri\": label_category_file_s3_uri_map[task_type],\n", "}\n", "\n", "# print(json.dumps(ground_truth_request, indent=4, sort_keys=True))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Call CreateLabelingJob to Create 3D Point Cloud Object Detection Job" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 15\n", "sagemaker_client.create_labeling_job(**ground_truth_request)\n", "print(f\"Labeling Job Name: {job_name}\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "describeLabelingJob = sagemaker_client.describe_labeling_job(LabelingJobName=job_name)\n", "print(describeLabelingJob)" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "### 3D(-2D) Point Cloud Object Tracking" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 16\n", "task_type = \"3DPointCloudObjectTracking\"" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "#### Input Manifest File With Multi-Frame Sequence Per Task\n", "\n", "When you chooose a sequence input manifest file, each line in the input manifest will point to a *sequence file* in Amazon S3. A sequence specifies a temporal series of point cloud frames. When a task is created using a sequence file, all point cloud frames in the sequence are sent to a worker to label. Workers can navigate back and forth between and annotate (with 3D cuboids) the sequence of frames to track the trajectory of objects across frames. \n", "\n", "Let's look at the sequence input manifest file. You'll see that this input manifest contains the location of a single sequence file. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 17\n", "print(\"\\nThe multi-frame input manifest file:\")\n", "with open(\"./sample_files/manifests/OT-manifest-10-frame.json\", \"r\") as j:\n", " json_data = json.load(j)\n", " print(\"\\n\", json.dumps(json_data, indent=4, sort_keys=True))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's look at the sequence file, seq1.json. You will see that this single sequence file contains the location of 10 frames, as well as pose information on the vehicle (ego-vehicle) and camera. See [Create a Point Cloud Frame Sequence Input Manifest](http://docs.aws.amazon.com/sagemaker/latest/dg/sms-point-cloud-multi-frame-input-data.html) to learn more about these parameters." ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 18\n", "with open(\"./sample_files/sequences/seq1.json\", \"r\") as j:\n", " json_data = json.load(j)\n", " print(\"\\nA single sequence file: \\n\\n\", json.dumps(json_data, indent=4, sort_keys=True))" ] }, { "cell_type": "markdown", "metadata": { "tags": [] }, "source": [ "#### Set up Human Task Configuration\n", "\n", "`HumanTaskConfig` is used to specify your work team, and configure your labeling job tasks. \n", "\n", "If you want to preview the worker task UI, create a private work team and add yourself as a worker. \n", "\n", "If you have already created a private workforce, follow the instructions in [Add or Remove Workers](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-management-private-console.html#add-remove-workers-sm) to add yourself to the work team you use to create a lableing job. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 19\n", "## Set up Human Task Config\n", "\n", "## Modify the following\n", "task_description = \"Object Tracking in 3D point cloud\"\n", "# example keywords\n", "task_keywords = [\"lidar\", \"pointcloud\"]\n", "# add a task title\n", "task_title = \"Tracking Cars\"\n", "# add a job name to identify your labeling job\n", "job_name = \"\"\n", "\n", "prehuman_arn = \"arn:aws:lambda:{}:{}:function:PRE-{}\".format(region, ac_arn_map[region], task_type)\n", "acs_arn = \"arn:aws:lambda:{}:{}:function:ACS-{}\".format(region, ac_arn_map[region], task_type)\n", "\n", "human_task_config = {\n", " \"AnnotationConsolidationConfig\": {\n", " \"AnnotationConsolidationLambdaArn\": acs_arn,\n", " },\n", " \"WorkteamArn\": workteam_arn,\n", " \"PreHumanTaskLambdaArn\": prehuman_arn,\n", " \"MaxConcurrentTaskCount\": 200, # 200 data objects (frames for OD and SS or sequences for OT) will be sent at a time to the workteam.\n", " \"NumberOfHumanWorkersPerDataObject\": 1, # One worker will work on each task\n", " \"TaskAvailabilityLifetimeInSeconds\": 18000, # Your workteam has 5 hours to complete all pending tasks.\n", " \"TaskDescription\": task_description,\n", " \"TaskKeywords\": task_keywords,\n", " \"TaskTimeLimitInSeconds\": 3600, # Each seq/frame must be labeled within 1 hour.\n", " \"TaskTitle\": task_title,\n", "}\n", "\n", "\n", "human_task_config[\"UiConfig\"] = {\"HumanTaskUiArn\": \"{}\".format(human_task_ui_arn_map[task_type])}" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Set up Create Labeling Request" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The following formats your labeling job request. For 3D point cloud object tracking, 2D-3D point cloud object tracking, and semantic segmentation task types, the `LabelAttributeName` must end in `-ref`. For other task types, the label attribute name may not end in `-ref`. " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 20\n", "## Set up Create Labeling Request\n", "\n", "labelAttributeName = job_name + \"-ref\"\n", "\n", "if (\n", " task_type == \"3DPointCloudObjectDetection\"\n", " or task_type == \"Adjustment3DPointCloudObjectDetection\"\n", "):\n", " labelAttributeName = job_name\n", "\n", "\n", "ground_truth_request = {\n", " \"InputConfig\": {\n", " \"DataSource\": {\n", " \"S3DataSource\": {\n", " \"ManifestS3Uri\": \"{}\".format(manifest_s3_uri_map[task_type]),\n", " }\n", " },\n", " \"DataAttributes\": {\n", " \"ContentClassifiers\": [\"FreeOfPersonallyIdentifiableInformation\", \"FreeOfAdultContent\"]\n", " },\n", " },\n", " \"OutputConfig\": {\n", " \"S3OutputPath\": f\"s3://{BUCKET}/{EXP_NAME}/output/\",\n", " },\n", " \"HumanTaskConfig\": human_task_config,\n", " \"LabelingJobName\": job_name,\n", " \"RoleArn\": role,\n", " \"LabelAttributeName\": labelAttributeName,\n", " # Note that sensor fusion job uses a different label category configuration file\n", " # IF it's a 3D object tracking task, keep as it is\n", " # IF it's a sensor fusion task, replace label_category_file_s3_uri_map[task_type] \n", " # with\n", " # f\"s3://{BUCKET}/artifacts/gt-point-cloud-demos/label-category-config/linking-lcc.json\"\n", " \"LabelCategoryConfigS3Uri\": label_category_file_s3_uri_map[task_type],\n", "}\n", "\n", "print(json.dumps(ground_truth_request, indent=4, sort_keys=True))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Call CreateLabelingJob to Create 3D Point Cloud Object Detection Job" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 21\n", "sagemaker_client.create_labeling_job(**ground_truth_request)\n", "print(f\"Labeling Job Name: {job_name}\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Check Status of Labeling Job" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "tags": [] }, "outputs": [], "source": [ "# cell 22\n", "## call describeLabelingJob\n", "describeLabelingJob = sagemaker_client.describe_labeling_job(LabelingJobName=job_name)\n", "print(describeLabelingJob)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Start Working on tasks\n", "\n", "When you add yourself to a private work team, you recieve an email invitation to access the worker portal. Use this invitation to sign in to the portal and view your 3D point cloud annotation tasks. Tasks may take up to 10 minutes to show up the worker portal. \n", "\n", "Once you are done working on the tasks, click **Submit**. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### View Output Data\n", "\n", "Once you have completed all of the tasks, you can view your output data in the S3 location you specified in `OutputConfig`. \n", "\n", "To read more about Ground Truth output data format for your task type, see [Output Data](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-data-output.html)." ] } ], "metadata": { "instance_type": "ml.t3.medium", "kernelspec": { "display_name": "Python 3 (Data Science)", "language": "python", "name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-1:081325390199:image/datascience-1.0" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.10" } }, "nbformat": 4, "nbformat_minor": 4 }