ryouchinsa / Rectlabel-support

RectLabel is an offline image annotation tool for object detection and segmentation.
https://rectlabel.com
507 stars 73 forks source link

Attribute support in COCO-style exporting #196

Closed panchgonzalez closed 2 years ago

panchgonzalez commented 2 years ago

Currently looks like object attributes aren't exporting properly to COCO format.

Minimal Example Object with a single attribute (e.g., color)

Screen Shot 2022-03-28 at 1 31 06 PM

Exporting to COCO JSON gives the following

{
    "images": [
        {
            "id": 1,
            "file_name": "Bell-peppers.jpg",
            "width": 800,
            "height": 499
        }
    ],
    "annotations": [
        {
            "area": 125330,
            "iscrowd": 0,
            "id": 1,
            "image_id": 1,
            "category_id": 1,
            "segmentation": [
                [
                    298,
                    475,
                    712,
                    475,
                    712,
                    174,
                    298,
                    174
                ]
            ],
            "bbox": [
                298,
                174,
                415,
                302
            ]
        }
    ],
    "categories": [
        {
            "name": "pepper",
            "id": 1
        }
    ]
}

Is there any way around this? In particular, I'm thinking adding a "metadata" entry each annotation entry would be useful, e.g.,

{
    "images": [
        {
            "id": 1,
            "file_name": "Bell-peppers.jpg",
            "width": 800,
            "height": 499
        }
    ],
    "annotations": [
        {
            "area": 125330,
            "iscrowd": 0,
            "id": 1,
            "image_id": 1,
            "category_id": 1,
            "segmentation": [
                [
                    298,
                    475,
                    712,
                    475,
                    712,
                    174,
                    298,
                    174
                ]
            ],
            "bbox": [
                298,
                174,
                415,
                302
            ],
            "metadata": {"color": "red"}
        }
    ],
    "categories": [
        {
            "name": "pepper",
            "id": 1
        }
    ]
}
ryouchinsa commented 2 years ago

Thanks for writing the issue.

As you said, RectLabel should export attribute names in the COCO JSON file in addition to object names. The reason why we did not implement it was almost object detection training tools are not supporting to train attribute names. They just train object names. But some users have customized training modules which train both object names and attribute names, so that we should implement it.

When we could implement it, we will let you know.

ryouchinsa commented 2 years ago

The new update version 35 was released. To show the new update on Mac App Store, press command + R to reload.

You can export/import a COCO JSON file with attributes.

Let us know your opinion.

{
    "annotations": [
    {
        "area": 261596,
        "iscrowd": 0,
        "id": 1,
        "image_id": 1,
        "category_id": 1,
        "bbox": [651, 158, 382, 685],
        "segmentation": [
            [651, 842, 1031, 842, 1031, 158, 651, 158]
        ],
        "attributes":
        {
            "color": ["purple"],
            "type": "cabernet sauvignon"
        }
    }],
    "categories": [
    {
        "id": 1,
        "name": "grape",
        "attributes": ["type", "color"]
    }],
    "images": [
    {
        "id": 1,
        "file_name": "howard-lawrence-b-652058-unsplash.jpg",
        "width": 1440,
        "height": 956
    }],
    "attributes": [
    {
        "prefix": "",
        "name": "color",
        "type": "Multiple select",
        "items": ["purple", "green"]
    },
    {
        "prefix": "",
        "name": "type",
        "type": "Single select",
        "items": ["cabernet sauvignon"]
    }]
}
ryouchinsa commented 2 years ago

Currently If you need our support to fix this problem, please let us know.