Exemple #1
0
def preannotations_upload(command_name, args):
    parser = argparse.ArgumentParser(prog=_CLI_COMMAND + " " + command_name)
    parser.add_argument('--project',
                        required=True,
                        help='Project name to upload')
    parser.add_argument(
        '--folder',
        required=True,
        help=
        'Folder (SuperAnnotate format) or JSON path (COCO format) from which to upload'
    )
    parser.add_argument('--format',
                        required=False,
                        default="SuperAnnotate",
                        help='Input preannotations format.')
    parser.add_argument(
        '--dataset-name',
        required=False,
        help='Input annotations dataset name for COCO projects')
    parser.add_argument(
        '--task',
        required=False,
        help=
        'Task type for COCO projects can be panoptic_segmentation (Pixel), instance_segmentation (Pixel), instance_segmentation (Vector), keypoint_detection (Vector)'
    )

    args = parser.parse_args(args)
    project_metadata, folder_metadata = sa.get_project_and_folder_metadata(
        args.project)

    if args.format != "SuperAnnotate":
        if args.format != "COCO":
            raise sa.SABaseException(
                0, "Not supported annotations format " + args.format)
        if args.dataset_name is None:
            raise sa.SABaseException(
                0, "Dataset name should be present for COCO format upload.")
        if args.task is None:
            raise sa.SABaseException(
                0, "Task name should be present for COCO format upload.")

        logger.info("Annotations in format %s.", args.format)
        project_type = project_metadata["type"]

        tempdir = tempfile.TemporaryDirectory()
        tempdir_path = Path(tempdir.name)
        sa.import_annotation(args.folder, tempdir_path, "COCO",
                             args.dataset_name, project_type, args.task)
        args.folder = tempdir_path

    sa.create_annotation_classes_from_classes_json(
        project_metadata,
        Path(args.folder) / "classes" / "classes.json")

    if "pre" not in command_name:
        sa.upload_annotations_from_folder_to_project(
            (project_metadata, folder_metadata), folder_path=args.folder)
    else:
        sa.upload_preannotations_from_folder_to_project(
            (project_metadata, folder_metadata), folder_path=args.folder)
def test_instance_segmentation_coco2sa(tmpdir):
    input_dir = Path(
        "tests"
    ) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "instance_segmentation"
    out_path = Path(tmpdir) / "toSuperAnnotate" / "instances_test"
    sa.import_annotation(
        input_dir, out_path, "COCO", "instances_test", "Vector",
        "instance_segmentation"
    )
def test_keypoint_detection_coco2sa(tmpdir):
    input_dir = Path(
        "tests"
    ) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "keypoint_detection"
    out_path = Path(tmpdir) / "toSuperAnnotate" / "keypoint_test"
    sa.import_annotation(
        input_dir, out_path, "COCO", "person_keypoints_test", "Vector",
        "keypoint_detection"
    )
def test_panoptic_segmentation_coco2sa(tmpdir):
    input_dir = Path(
        "tests"
    ) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "panoptic_segmentation"
    out_path = Path(tmpdir) / "toSuperAnnotate" / "panoptic_test"
    sa.import_annotation(
        input_dir, out_path, "COCO", "panoptic_test", "Pixel",
        "panoptic_segmentation"
    )
Exemple #5
0
def test_vott_convert_object(tmpdir):
    project_name = "vott_object"
    input_dir = Path(
        "tests") / "converter_test" / "VoTT" / "input" / "toSuperAnnotate"
    out_dir = Path(tmpdir) / project_name
    sa.import_annotation(input_dir, out_dir, "VoTT", "", "Vector",
                         "object_detection")

    description = 'vott object detection'
    ptype = 'Vector'
    upload_project(out_dir, project_name, description, ptype)
Exemple #6
0
def test_vott_convert_instance(tmpdir):
    project_name = "vott_vector_instance"
    input_dir = Path(
        "tests") / "converter_test" / "VoTT" / "input" / "toSuperAnnotate"
    out_dir = Path(tmpdir) / project_name
    sa.import_annotation(input_dir, out_dir, "VoTT", "", "Vector",
                         "instance_segmentation")

    description = 'vott instance segmentation'
    ptype = 'Vector'
    upload_project(out_dir, project_name, description, ptype)
def test_dataloop_convert_instance(tmpdir):
    project_name = "dataloop2sa_vector_instance"

    input_dir = Path(
        'tests') / 'converter_test' / 'DataLoop' / 'input' / 'toSuperAnnotate'
    out_dir = Path(tmpdir) / project_name
    sa.import_annotation(input_dir, out_dir, 'DataLoop', '', 'Vector',
                         'instance_segmentation')
    description = 'dataloop instance segmentation'
    ptype = 'Vector'
    upload_project(out_dir, project_name, description, ptype)
Exemple #8
0
def test_vgg_convert_vector(tmpdir):
    project_name = "vgg_test_vector"

    input_dir = Path(
        "tests") / "converter_test" / "VGG" / "input" / "toSuperAnnotate"
    out_dir = Path(tmpdir) / project_name
    sa.import_annotation(input_dir, out_dir, "VGG", "vgg_test", "Vector",
                         "vector_annotation")

    description = 'vgg vector annotation'
    ptype = 'Vector'
    upload_project(out_dir, project_name, description, ptype)
Exemple #9
0
def test_yolo_object_detection_web(tmpdir):
    project_name = "yolo_object_detection"

    input_dir = Path(
        'tests') / 'converter_test' / 'YOLO' / 'input' / 'toSuperAnnotate'
    out_dir = Path(tmpdir) / project_name
    sa.import_annotation(input_dir, out_dir, 'YOLO', '', 'Vector',
                         'object_detection')

    description = 'yolo object detection'
    ptype = 'Vector'
    upload_project(out_dir, project_name, description, ptype)
Exemple #10
0
def test_coco_vector_instance(tmpdir):
    project_name = "coco2sa_vector_instance"

    input_dir = Path(
        "tests"
    ) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "instance_segmentation"
    out_dir = Path(tmpdir) / project_name
    sa.import_annotation(input_dir, out_dir, "COCO", "instances_test",
                         "Vector", "instance_segmentation")

    description = 'coco vector instance segmentation'
    ptype = 'Vector'
    upload_project(out_dir, project_name, description, ptype)
Exemple #11
0
def test_coco_panoptic(tmpdir):
    project_name = "coco2sa_panoptic"

    input_dir = Path(
        "tests"
    ) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "panoptic_segmentation"
    out_dir = Path(tmpdir) / project_name
    sa.import_annotation(input_dir, out_dir, "COCO", "panoptic_test", "Pixel",
                         "panoptic_segmentation")

    description = 'coco pixel panoptic segmentation'
    ptype = 'Pixel'
    upload_project(out_dir, project_name, description, ptype)
Exemple #12
0
def test_coco_vector_keypoint(tmpdir):
    project_name = "coco2sa_keypoint"

    input_dir = Path(
        "tests"
    ) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "keypoint_detection/"
    out_dir = Path(tmpdir) / project_name
    sa.import_annotation(input_dir, out_dir, "COCO", "person_keypoints_test",
                         "Vector", "keypoint_detection")

    description = 'coco vector keypoint detection'
    ptype = 'Vector'
    upload_project(out_dir, project_name, description, ptype)
Exemple #13
0
def test_sagemaker_instance_segmentation(tmpdir):
    project_name = "sagemaker_instance_pixel"

    input_dir = Path(
        'tests'
    ) / 'converter_test' / 'SageMaker' / 'input' / 'toSuperAnnotate' / 'instance_segmentation'
    out_dir = Path(tmpdir) / project_name
    sa.import_annotation(input_dir, out_dir, 'SageMaker', 'test-obj-detect',
                         'Pixel', 'instance_segmentation')

    description = 'sagemaker vector instance segmentation'
    ptype = 'Pixel'
    upload_project(out_dir, project_name, description, ptype)
Exemple #14
0
def test_sagemaker_object_detection(tmpdir):
    project_name = "sagemaker_object_vector"

    input_dir = Path(
        'tests'
    ) / 'converter_test' / 'SageMaker' / 'input' / 'toSuperAnnotate' / 'object_detection'
    out_dir = Path(tmpdir) / project_name
    sa.import_annotation(input_dir, out_dir, 'SageMaker', 'test-obj-detect',
                         'Vector', 'object_detection')

    description = 'sagemaker object detection'
    ptype = 'Vector'
    upload_project(out_dir, project_name, description, ptype)
Exemple #15
0
def test_voc_pixel(tmpdir):
    project_name = "voc2sa_pixel_instance"
    input_dir = Path(
        "tests"
    ) / "converter_test" / "VOC" / "input" / "fromPascalVOCToSuperAnnotate" / "VOC2012"
    out_dir = Path(tmpdir) / project_name
    sa.import_annotation(
        input_dir, out_dir, "VOC", "", "Pixel", "instance_segmentation"
    )

    description = 'voc pixel instance segmentation'
    ptype = 'Pixel'
    upload_project(out_dir, project_name, description, ptype)
Exemple #16
0
def test_googlecloud_convert_web(tmpdir):
    project_name = "googlcloud_object"

    input_dir = Path(
        "tests"
    ) / "converter_test" / "GoogleCloud" / "input" / "toSuperAnnotate"
    out_dir = Path(tmpdir) / project_name
    sa.import_annotation(input_dir, out_dir, "GoogleCloud",
                         "image_object_detection", "Vector",
                         "object_detection")

    description = 'googlecloud object detection'
    ptype = 'Vector'
    upload_project(out_dir, project_name, description, ptype)
def test_labelbox_convert_vector(tmpdir):
    project_name = "labelbox_vector_annotation"

    input_dir = Path(
        'tests'
    ) / 'converter_test' / 'LabelBox' / 'vector_annotations' / 'toSuperAnnotate'
    out_dir = Path(tmpdir) / project_name
    dataset_name = 'labelbox_example'
    sa.import_annotation(input_dir, out_dir, 'LabelBox', dataset_name,
                         'Vector', 'vector_annotation')

    description = 'labelbox vector vector annotation'
    ptype = 'Vector'
    upload_project(out_dir, project_name, description, ptype)
def test_labelbox_convert_instance_pixel(tmpdir):
    project_name = "labelbox_pixel_instance"

    input_dir = Path(
        'tests'
    ) / 'converter_test' / 'LabelBox' / 'instance_segmentation' / 'toSuperAnnotate'
    out_dir = Path(tmpdir) / project_name
    dataset_name = 'labelbox_example'
    sa.import_annotation(input_dir, out_dir, 'LabelBox', dataset_name, 'Pixel',
                         'instance_segmentation')

    description = 'labelbox pixel instance_segmentation'
    ptype = 'Pixel'
    upload_project(out_dir, project_name, description, ptype)
Exemple #19
0
def test_voc_vector_object(tmpdir):
    project_name = "voc2sa_vector_object"

    input_dir = Path(
        "tests"
    ) / "converter_test" / "VOC" / "input" / "fromPascalVOCToSuperAnnotate" / "VOC2012"
    out_dir = Path(tmpdir) / project_name
    sa.import_annotation(
        input_dir, out_dir, "VOC", "", "Vector", "object_detection"
    )

    description = 'voc vector object detection'
    ptype = 'Vector'
    upload_project(out_dir, project_name, description, ptype)
Exemple #20
0
def test_sa_to_coco_to_sa(tmpdir):
    input_dir = Path("tests") / "sample_project_pixel"
    output1 = Path(tmpdir) / 'to_coco'
    output2 = Path(tmpdir) / 'to_sa'

    sa.export_annotation(input_dir, output1, "COCO", "object_test", "Pixel",
                         "instance_segmentation")

    sa.import_annotation(output1, output2, "COCO", "object_test", "Pixel",
                         "instance_segmentation", 'image_set')

    project_name = 'coco_pipeline_new'
    description = 'test_instane'
    ptype = 'Pixel'
    upload_project(output2, project_name, description, ptype)