示例#1
0
def test_coco_desktop_object(tmpdir):
    input_dir = Path(
        "tests"
    ) / "converter_test" / "COCO" / "input" / "fromSuperAnnotate" / "cats_dogs_desktop"
    out_dir = Path(tmpdir) / "coco_from_desktop"
    sa.export_annotation_format(input_dir, out_dir, "COCO", "object_test",
                                "Vector", "object_detection", "Desktop")
示例#2
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
def test_instance_segmentation_sa2coco_vector(tmpdir):
    input_dir = Path(
        "tests"
    ) / "converter_test" / "COCO" / "input" / "fromSuperAnnotate" / "cats_dogs_vector_instance_segm"
    out_path = Path(tmpdir) / "fromSuperAnnotate" / "instance_test_vector"
    sa.export_annotation_format(
        input_dir, out_path, "COCO", "instance_test_vector", "Vector",
        "instance_segmentation"
    )
def test_keypoint_detection_sa2coco(tmpdir):
    input_dir = Path(
        "tests"
    ) / "converter_test" / "COCO" / "input" / "fromSuperAnnotate" / "cats_dogs_vector_keypoint_det"
    out_path = Path(tmpdir) / "fromSuperAnnotate" / "keypoint_test_vector"
    sa.export_annotation_format(
        input_dir, out_path, "COCO", "keypoint_test_vector", "Vector",
        "keypoint_detection"
    )
def test_panoptic_segmentation_sa2coco(tmpdir):
    input_dir = Path(
        "tests"
    ) / "converter_test" / "COCO" / "input" / "fromSuperAnnotate" / "cats_dogs_panoptic_segm"
    out_path = Path(tmpdir) / "fromSuperAnnotate" / "panoptic_test"
    sa.export_annotation_format(
        input_dir, out_path, "COCO", "panoptic_test", "Pixel",
        "panoptic_segmentation"
    )
示例#6
0
def instance_segmentation_sa2coco_vector(tmpdir):
    out_path = tmpdir / "fromSuperAnnotate/instance_test_vector"
    try:
        sa.export_annotation_format(
            "tests/converter_test/COCO/input/fromSuperAnnotate/cats_dogs_vector_instance_segm",
            str(out_path), "COCO", "instance_test_vector", "Vector",
            "instance_segmentation")
    except Exception as e:
        return 1
    return 0
示例#7
0
def keypoint_detection_sa2coco(tmpdir):
    out_path = tmpdir / "fromSuperAnnotate/keypoint_test_vector"
    try:
        sa.export_annotation_format(
            "tests/converter_test/COCO/input/fromSuperAnnotate/cats_dogs_vector_keypoint_det",
            str(out_path), "COCO", "keypoint_test_vector", "Vector",
            "keypoint_detection")
    except Exception as e:
        return 1
    return 0
示例#8
0
def panoptic_segmentation_sa2coco(tmpdir):
    out_path = tmpdir / "fromSuperAnnotate/panoptic_test"
    try:
        sa.export_annotation_format(
            "tests/converter_test/COCO/input/fromSuperAnnotate/cats_dogs_panoptic_segm",
            str(out_path), "COCO", "panoptic_test", "Pixel",
            "panoptic_segmentation")
    except Exception as e:
        return 1
    return 0
示例#9
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_format(input_dir, output1, "COCO", "object_test",
                                "Pixel", "instance_segmentation", "Web")

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

    project_name = 'coco_pipeline_new'
    project = sa.search_projects(project_name, return_metadata=True)
    for pr in project:
        sa.delete_project(pr)

    project = sa.create_project(project_name, 'test_instane', 'Pixel')
    sa.upload_images_from_folder_to_project(project, output2)
    sa.create_annotation_classes_from_classes_json(
        project, output2 / "classes" / "classes.json")
    sa.upload_annotations_from_folder_to_project(project, output2)