コード例 #1
0
def test_supervisely_convert_object(tmpdir):
    input_dir = Path(
        'tests'
    ) / 'converter_test' / 'Supervisely' / 'input' / 'toSuperAnnotate' / 'vector'
    out_dir = Path(tmpdir) / 'object_detection_desktop'
    sa.import_annotation_format(input_dir, out_dir, 'Supervisely', '',
                                'Vector', 'object_detection', 'Desktop')
コード例 #2
0
def test_coco_vector_object_instance(tmpdir):
    input_dir = Path(
        "tests"
    ) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "instance_segmentation"
    out_dir = Path(tmpdir) / "object_vector_instance_desktop"
    sa.import_annotation_format(input_dir, out_dir, "COCO", "instances_test",
                                "Vector", "instance_segmentation", "Desktop")
コード例 #3
0
def coco_desktop_object(tmpdir):
    out_dir = tmpdir / "coco_from_desktop"
    final_dir = tmpdir / "coco_to_Web"

    sa.export_annotation_format(
        "tests/converter_test/COCO/input/fromSuperAnnotate/cats_dogs_desktop",
        str(out_dir), "COCO", "object_test", "Vector", "object_detection",
        "Desktop")

    image_list = glob(str(out_dir / 'train_set' / '*.jpg'))

    for image in image_list:
        shutil.copy(image, out_dir / Path(image).name)
    shutil.rmtree(out_dir / 'train_set')

    sa.import_annotation_format(str(out_dir), str(final_dir), "COCO",
                                "object_test_train", "Vector",
                                "object_detection", "Web")

    project_name = "coco2sa_object_pipline"

    projects = sa.search_projects(project_name, True)
    if projects:
        sa.delete_project(projects[0])
    project = sa.create_project(project_name, "converter vector", "Vector")

    sa.create_annotation_classes_from_classes_json(
        project, final_dir / "classes" / "classes.json")
    sa.upload_images_from_folder_to_project(project, final_dir)
    sa.upload_annotations_from_folder_to_project(project, final_dir)

    return 0
コード例 #4
0
def test_voc_vector_object(tmpdir):
    input_dir = Path(
        "tests"
    ) / "converter_test" / "VOC" / "input" / "fromPascalVOCToSuperAnnotate" / "VOC2012"
    out_dir = Path(tmpdir) / "object_vector"
    sa.import_annotation_format(input_dir, out_dir, "VOC", "", "Vector",
                                "object_detection", "Desktop")
コード例 #5
0
def test_sagemaker_object_detection(tmpdir):
    input_dir = Path(
        'tests'
    ) / 'converter_test' / 'SageMaker' / 'input' / 'toSuperAnnotate' / 'object_detection'
    out_dir = Path(tmpdir) / "object_detection"
    sa.import_annotation_format(input_dir, out_dir, 'SageMaker',
                                'test-obj-detect', 'Vector',
                                'object_detection', 'Desktop')
コード例 #6
0
def yolo_object_detection_desktop(tmpdir):
    out_dir = tmpdir / "vector_annotation_desktop"
    sa.import_annotation_format(
        'tests/converter_test/YOLO/input/toSuperAnnotate', str(out_dir), 'YOLO',
        '', 'Vector', 'object_detection', 'Desktop'
    )

    return 0
コード例 #7
0
def test_googlecloud_convert_desktop(tmpdir):
    input_dir = Path(
        "tests"
    ) / "converter_test" / "GoogleCloud" / "input" / "toSuperAnnotate"
    out_dir = Path(tmpdir) / "output_desktop"
    sa.import_annotation_format(
        input_dir, out_dir, "GoogleCloud", "image_object_detection", "Vector",
        "object_detection", "Desktop"
    )
コード例 #8
0
def test_dataloop_convert_object(tmpdir):
    input_dir = Path(
        'tests'
    ) / 'converter_test' / 'DataLoop' / 'input' / 'toSuperAnnotate'
    out_dir = Path(tmpdir) / 'output_object'
    sa.import_annotation_format(
        input_dir, out_dir, 'DataLoop', '', 'Vector', 'object_detection',
        'Desktop'
    )
コード例 #9
0
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_format(
        input_dir, out_path, "COCO", "person_keypoints_test", "Vector",
        "keypoint_detection"
    )
コード例 #10
0
def test_vott_convert_instance(tmpdir):
    input_dir = Path(
        "tests"
    ) / "converter_test" / "VoTT" / "input" / "toSuperAnnotate"
    out_dir = Path(tmpdir) / "instance_segmentation"
    sa.import_annotation_format(
        input_dir, out_dir, "VoTT", "", "Vector", "instance_segmentation",
        "Desktop"
    )
コード例 #11
0
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_format(
        input_dir, out_path, "COCO", "panoptic_test", "Pixel",
        "panoptic_segmentation"
    )
コード例 #12
0
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_format(
        input_dir, out_path, "COCO", "instances_test", "Vector",
        "instance_segmentation"
    )
コード例 #13
0
def preannotations_upload(args, annotations=False):
    parser = argparse.ArgumentParser()
    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)

    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 = sa.project_type_int_to_str(
            sa.get_project_metadata(args.project)["type"])

        tempdir = tempfile.TemporaryDirectory()
        tempdir_path = Path(tempdir.name)
        sa.import_annotation_format(args.folder, tempdir_path, "COCO",
                                    args.dataset_name, project_type, args.task)
        args.folder = tempdir_path
    sa.create_annotation_classes_from_classes_json(
        args.project,
        Path(args.folder) / "classes" / "classes.json")

    if annotations:
        sa.upload_annotations_from_folder_to_project(project=args.project,
                                                     folder_path=args.folder)
    else:
        sa.upload_preannotations_from_folder_to_project(
            project=args.project, folder_path=args.folder)
コード例 #14
0
def instance_segmentation_coco2sa(tmpdir):
    out_path = tmpdir / "toSuperAnnotate/instances_test"
    try:
        sa.import_annotation_format(
            "tests/converter_test/COCO/input/toSuperAnnotate/instance_segmentation",
            str(out_path), "COCO", "instances_test", "Vector",
            "instance_segmentation")
    except Exception as e:
        return 1
    return 0
コード例 #15
0
def panoptic_segmentation_coco2sa(tmpdir):
    out_path = tmpdir / "toSuperAnnotate/panoptic_test"
    try:
        sa.import_annotation_format(
            "tests/converter_test/COCO/input/toSuperAnnotate/panoptic_segmentation",
            str(out_path), "COCO", "panoptic_test", "Pixel",
            "panoptic_segmentation")
    except Exception as e:
        return 1
    return 0
コード例 #16
0
def keypoint_detection_coco2sa(tmpdir):
    out_path = tmpdir / "toSuperAnnotate/keypoint_test"
    try:
        sa.import_annotation_format(
            "tests/converter_test/COCO/input/toSuperAnnotate/keypoint_detection",
            str(out_path), "COCO", "person_keypoints_test", "Vector",
            "keypoint_detection")
    except Exception as e:
        return 1
    return 0
コード例 #17
0
def test_coco_pixel_instance_desktop(tmpdir):
    input_dir = Path(
        "tests"
    ) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "instance_segmentation"
    out_dir = Path(tmpdir) / "instance_pixel_desktop"

    with pytest.raises(sa.SABaseException) as e:
        sa.import_annotation_format(input_dir, out_dir, "COCO",
                                    "instances_test", "Pixel",
                                    "instance_segmentation", "Desktop")
    assert e.value.message == "Sorry, but Desktop Application doesn't support 'Pixel' projects."
コード例 #18
0
def labelbox_convert_instance(tmpdir):
    out_dir = tmpdir / "output_insance"
    dataset_name = 'labelbox_example'
    sa.import_annotation_format(
        'tests/converter_test/LabelBox/input/toSuperAnnotate', str(out_dir),
        'LabelBox', dataset_name, 'Vector', 'instance_segmentation', 'Desktop')

    all_files = os.listdir(out_dir)
    json_files = set([
        file.replace('___objects.json', '') for file in all_files
        if os.path.splitext(file) == '.json'
    ])
    image_files = set(
        [file for file in all_files if os.path.splitext(file) == '.jpg'])

    if json_files != image_files:
        return 1
    return 0
コード例 #19
0
def test_vgg_convert_object(tmpdir):
    input_dir = Path(
        "tests") / "converter_test" / "VGG" / "input" / "toSuperAnnotate"
    out_dir = Path(tmpdir) / "object_detection"
    sa.import_annotation_format(input_dir, out_dir, "VGG", "vgg_test",
                                "Vector", "object_detection", "Web")

    project_name = "vgg_test_object"

    projects = sa.search_projects(project_name, True)
    if projects:
        sa.delete_project(projects[0])
    project = sa.create_project(project_name, "converter vector", "Vector")

    sa.create_annotation_classes_from_classes_json(
        project, out_dir / "classes" / "classes.json")
    sa.upload_images_from_folder_to_project(project, out_dir)
    sa.upload_annotations_from_folder_to_project(project, out_dir)
コード例 #20
0
def test_supervisely_convert_instance(tmpdir):
    input_dir = Path(
        'tests'
    ) / 'converter_test' / 'Supervisely' / 'input' / 'toSuperAnnotate' / 'vector'
    out_dir = Path(tmpdir) / 'instance_segmentation'
    sa.import_annotation_format(input_dir, out_dir, 'Supervisely', '',
                                'Vector', 'instance_segmentation', 'Web')
    project_name = "supervisely_test_vector_convert_instance"

    projects = sa.search_projects(project_name, True)
    if projects:
        sa.delete_project(projects[0])
    project = sa.create_project(project_name, "converter vector", "Vector")

    sa.create_annotation_classes_from_classes_json(
        project, out_dir / "classes" / "classes.json")
    sa.upload_images_from_folder_to_project(project, out_dir)
    sa.upload_annotations_from_folder_to_project(project, out_dir)
コード例 #21
0
def test_yolo_object_detection_web(tmpdir):
    input_dir = Path(
        'tests') / 'converter_test' / 'YOLO' / 'input' / 'toSuperAnnotate'
    out_dir = Path(tmpdir) / "vector_annotation_web"
    sa.import_annotation_format(input_dir, out_dir, 'YOLO', '', 'Vector',
                                'object_detection', 'Web')

    project_name = "yolo_object_detection"

    projects = sa.search_projects(project_name, True)
    if projects:
        sa.delete_project(projects[0])
    project = sa.create_project(project_name, "converter vector", "Vector")

    sa.create_annotation_classes_from_classes_json(
        project, out_dir / "classes" / "classes.json")
    sa.upload_images_from_folder_to_project(project, out_dir)
    sa.upload_annotations_from_folder_to_project(project, out_dir)
コード例 #22
0
def dataloop_convert_vector(tmpdir):
    out_dir = tmpdir / 'output_vector'
    sa.import_annotation_format(
        'tests/converter_test/DataLoop/input/toSuperAnnotate', str(out_dir),
        'DataLoop', '', 'Vector', 'vector_annotation', 'Web')
    # project_name = "dataloop_test"

    # projects = sa.search_projects(project_name, True)
    # if projects:
    #     sa.delete_project(projects[0])
    # project = sa.create_project(project_name, "converter vector", "Vector")

    # sa.create_annotation_classes_from_classes_json(
    #     project, out_dir + "/classes/classes.json"
    # )
    # sa.upload_images_from_folder_to_project(project, out_dir)
    # sa.upload_annotations_from_folder_to_project(project, out_dir)
    return 0
コード例 #23
0
def supervisely_convert_keypoint(tmpdir):
    out_dir = tmpdir / 'keypoint_detection'
    sa.import_annotation_format(
        'tests/converter_test/Supervisely/input/toSuperAnnotate/keypoints',
        str(out_dir), 'Supervisely', '', 'Vector', 'keypoint_detection', 'Web')

    project_name = "supervisely_test_keypoint"

    projects = sa.search_projects(project_name, True)
    if projects:
        sa.delete_project(projects[0])
    project = sa.create_project(project_name, "converter vector", "Vector")

    sa.create_annotation_classes_from_classes_json(
        project, out_dir / "classes" / "classes.json")
    sa.upload_images_from_folder_to_project(project, out_dir)
    sa.upload_annotations_from_folder_to_project(project, out_dir)

    return 0
コード例 #24
0
def test_coco_vector_instance(tmpdir):
    input_dir = Path(
        "tests"
    ) / "converter_test" / "COCO" / "input" / "toSuperAnnotate" / "instance_segmentation"
    out_dir = Path(tmpdir) / "instance_vector"
    sa.import_annotation_format(input_dir, out_dir, "COCO", "instances_test",
                                "Vector", "instance_segmentation", "Web")

    project_name = "coco2sa_vector_instance"

    projects = sa.search_projects(project_name, True)
    if projects:
        sa.delete_project(projects[0])
    project = sa.create_project(project_name, "converter vector", "Vector")

    sa.create_annotation_classes_from_classes_json(
        project, out_dir / "classes" / "classes.json")
    sa.upload_images_from_folder_to_project(project, out_dir)
    sa.upload_annotations_from_folder_to_project(project, out_dir)
コード例 #25
0
def vott_convert_vector(tmpdir):
    out_dir = tmpdir / "vector_annotation"
    sa.import_annotation_format(
        "tests/converter_test/VoTT/input/toSuperAnnotate", str(out_dir),
        "VoTT", "", "Vector", "vector_annotation", "Web")

    project_name = "vott_vector"

    projects = sa.search_projects(project_name, True)
    if projects:
        sa.delete_project(projects[0])
    project = sa.create_project(project_name, "converter vector", "Vector")

    sa.create_annotation_classes_from_classes_json(
        project, out_dir / "classes" / "classes.json")
    sa.upload_images_from_folder_to_project(project, out_dir)
    sa.upload_annotations_from_folder_to_project(project, out_dir)

    return 0
コード例 #26
0
def test_sagemaker_instance_segmentation(tmpdir):
    input_dir = Path(
        'tests'
    ) / 'converter_test' / 'SageMaker' / 'input' / 'toSuperAnnotate' / 'instance_segmentation'
    out_dir = Path(tmpdir) / "instance_segmentation"
    sa.import_annotation_format(input_dir, out_dir, 'SageMaker',
                                'test-obj-detect', 'Pixel',
                                'instance_segmentation', 'Web')

    project_name = "sagemaker_instance_segmentation"

    projects = sa.search_projects(project_name, True)
    if projects:
        sa.delete_project(projects[0])
    project = sa.create_project(project_name, "converter vector", "Pixel")

    sa.create_annotation_classes_from_classes_json(
        project, out_dir / "classes" / "classes.json")
    sa.upload_images_from_folder_to_project(project, out_dir)
    sa.upload_annotations_from_folder_to_project(project, out_dir)
コード例 #27
0
def sagemaker_object_detection(tmpdir):
    out_dir = tmpdir / "object_detection"
    sa.import_annotation_format(
        'tests/converter_test/SageMaker/input/toSuperAnnotate/object_detection',
        str(out_dir), 'SageMaker', 'test-obj-detect', 'Vector',
        'object_detection', 'Web')

    project_name = "sagemaker_object_detection"

    projects = sa.search_projects(project_name, True)
    if projects:
        sa.delete_project(projects[0])
    project = sa.create_project(project_name, "converter vector", "Vector")

    sa.create_annotation_classes_from_classes_json(
        project, out_dir + "/classes/classes.json")
    sa.upload_images_from_folder_to_project(project, out_dir)
    sa.upload_annotations_from_folder_to_project(project, out_dir)

    return 0
コード例 #28
0
def coco_vector_object(tmpdir):
    out_dir = tmpdir / "object_vector"
    sa.import_annotation_format(
        "tests/converter_test/COCO/input/toSuperAnnotate/instance_segmentation/",
        str(out_dir), "COCO", "instances_test", "Vector", "object_detection",
        "Desktop")

    # project_name = "coco2sa_vector_object"

    # projects = sa.search_projects(project_name, True)
    # if projects:
    #     sa.delete_project(projects[0])
    # project = sa.create_project(project_name, "converter vector", "Vector")

    # sa.create_annotation_classes_from_classes_json(
    #     project, out_dir / "classes" / "classes.json"
    # )
    # sa.upload_images_from_folder_to_project(project, out_dir)
    # sa.upload_annotations_from_folder_to_project(project, out_dir)
    return 0
コード例 #29
0
def coco_vector_keypoint(tmpdir):
    out_dir = tmpdir / "vector_keypoint"
    sa.import_annotation_format(
        "tests/converter_test/COCO/input/toSuperAnnotate/keypoint_detection/",
        str(out_dir), "COCO", "person_keypoints_test", "Vector",
        "keypoint_detection", "Web")

    project_name = "coco2sa_keypoint"

    projects = sa.search_projects(project_name, True)
    if projects:
        sa.delete_project(projects[0])
    project = sa.create_project(project_name, "converter vector", "Vector")

    sa.create_annotation_classes_from_classes_json(
        project, out_dir / "classes" / "classes.json")
    sa.upload_images_from_folder_to_project(project, out_dir)
    sa.upload_annotations_from_folder_to_project(project, out_dir)

    return 0
コード例 #30
0
def coco_pixel_instance(tmpdir):
    out_dir = tmpdir / "instance_pixel"
    sa.import_annotation_format(
        "tests/converter_test/COCO/input/toSuperAnnotate/instance_segmentation/",
        str(out_dir), "COCO", "instances_test", "Pixel",
        "instance_segmentation", "Web")

    project_name = "coco2sa_pixel_instance"

    projects = sa.search_projects(project_name, True)
    if projects:
        sa.delete_project(projects[0])
    project = sa.create_project(project_name, "converter vector", "Pixel")

    sa.create_annotation_classes_from_classes_json(
        project, out_dir / "classes" / "classes.json")
    sa.upload_images_from_folder_to_project(project, out_dir)
    sa.upload_annotations_from_folder_to_project(project, out_dir)

    return 0