Skip to content

coco_segm_annotation_to_normalized_vertices does not handle nested segmentation field #1751

@robmarkcole

Description

@robmarkcole

In the importing_coco.ipynb example, the function coco_segm_annotation_to_normalized_vertices doesn't handle nested segmentation. This is demonstrated below:

def test_coco_segm_annotation_to_normalized_vertices():
    # Sample COCO annotation data
    coco_ann = {
        "segmentation": [
                [
                    [
                        1842.8,
                        1322.2,
                        1848.1,
                        1320.2,
                        1845,
                        1311.8,
                        1839.7,
                        1313.8
                    ]
                ]
            ],
        "iscrowd": 0
    }
    img_width = 8000  # Example image width
    img_height = 6000  # Example image height

    normalized_vertices = coco_segm_annotation_to_normalized_vertices(
        coco_ann=coco_ann,
        img_width=img_width,
        img_height=img_height
    )

    print("Normalized Vertices:")
    for vertices in normalized_vertices:
        for vertex in vertices:
            print(vertex)

test_coco_segm_annotation_to_normalized_vertices()

Ideally I would be able to upload cocojson to the platform, but in the meantime I suggest improving this example

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions