in gt_converter/convert_coco.py [0:0]
def convert_job(self, job_name, output_coco_json_path):
"""
Converts a SageMaker Ground Truth job's manifest file to COCO format.
:param job_name: Name of the GT job (str)
:param output_coco_json_path: Path to write output file
"""
job_description = self.sm_client.describe_labeling_job(LabelingJobName=job_name)
job_state = job_description["LabelingJobStatus"]
job_task_keywords = job_description["HumanTaskConfig"]["TaskKeywords"]
if job_state == "Completed":
if "Images" not in job_task_keywords and "Video" not in job_task_keywords:
raise NotImplementedError(
"GT Conversion only supports image and video labeling tasks at the moment."
)
manifest_path = job_description["LabelingJobOutput"]["OutputDatasetS3Uri"]
if "bounding boxes" in job_task_keywords:
self._convert_bbox_manifest(
manifest_path, job_name, output_coco_json_path
)
elif "image segmentation" in job_task_keywords:
self._convert_segmentation_manifest(
manifest_path, job_name, output_coco_json_path
)
elif "Video" in job_task_keywords and "tracking" in job_task_keywords:
self._convert_video_tracking_manifest(
manifest_path, job_name, output_coco_json_path
)
else:
raise ValueError(
"Could not determine the type of labeling job. Currently, Bounding Box and Semantic Segmentation are supported."
)
else:
raise ValueError(
"Job is not in `Completed` state. Currently: {}".format(job_state)
)