Sai Dinesh Pola
Sai Dinesh Pola

Reputation: 103

How to use fiftyone for exploring the instance segmentation of custom coco data?

How to use fiftyone for exploring the instance segmentation of custom coco data? It has documentation for coco dataset but I couldn't find any resource for custom coco dataset.

Upvotes: 1

Views: 3634

Answers (2)

Eric Hofesmann
Eric Hofesmann

Reputation: 584

You can find documentation for importing custom COCODetectionDatasets here.

In short, as long as your data follows the expected COCO format:

{
    "info": {...},
    "licenses": [
        {
            "id": 1,
            "name": "Attribution-NonCommercial-ShareAlike License",
            "url": "http://creativecommons.org/licenses/by-nc-sa/2.0/",
        },
        ...
    ],
    "categories": [
        ...
        {
            "id": 2,
            "name": "cat",
            "supercategory": "animal",
            "keypoints": ["nose", "head", ...],
            "skeleton": [[12, 14], [14, 16], ...]
        },
        ...
    ],
    "images": [
        {
            "id": 1,
            "license": 1,
            "file_name": "<filename0>.<ext>",
            "height": 480,
            "width": 640,
            "date_captured": null
        },
        ...
    ],
    "annotations": [
        {
            "id": 1,
            "image_id": 1,
            "category_id": 2,
            "bbox": [260, 177, 231, 199],
            "segmentation": [...],
            "keypoints": [224, 226, 2, ...],
            "num_keypoints": 10,
            "score": 0.95,
            "area": 45969,
            "iscrowd": 0
        },
        ...
    ]
}

The segmentation field format is defined here.

Then you can load it into FiftyOne with the following Python code:

import fiftyone as fo

name = "my-dataset"
dataset_dir = "/path/to/coco-detection-dataset"

# Create the dataset
dataset = fo.Dataset.from_dir(
    dataset_dir=dataset_dir,
    dataset_type=fo.types.COCODetectionDataset,
    name=name,
)

# View summary info about the dataset
print(dataset)

# Print the first few samples in the dataset
print(dataset.head())

Upvotes: 2

Sai Dinesh Pola
Sai Dinesh Pola

Reputation: 103

It can be done by using COCODetectionDatasetImporter Class and set label_types=["detections","segmentations"] for seeing mask annotated images

Upvotes: 1

Related Questions