Coder Social home page Coder Social logo

fcakyon / labelme2coco Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xcrobert/labelme2coco

247.0 3.0 63.0 196 KB

A lightweight package for converting your labelme annotations into COCO object detection format.

License: GNU General Public License v3.0

Python 100.00%
labelme coco object-detection instance-segmentation semantic-segmentation image-classification deep-learning machine-learning computer-vision windows linux macos python annotation-conversion

labelme2coco's Introduction

labelme2coco

downloads pypi version ci fcakyon twitter

A lightweight package for converting your labelme annotations into COCO object detection format.

teaser

Convert LabelMe annotations to COCO format in one step

labelme is a widely used is a graphical image annotation tool that supports classification, segmentation, instance segmentation and object detection formats. However, widely used frameworks/models such as Yolact/Solo, Detectron, MMDetection etc. requires COCO formatted annotations.

You can use this package to convert labelme annotations to COCO format.

Getting started

Installation

pip install -U labelme2coco

Basic Usage

labelme2coco path/to/labelme/dir
labelme2coco path/to/labelme/dir --train_split_rate 0.85
labelme2coco path/to/labelme/dir --category_id_start 1

Advanced Usage

# import package
import labelme2coco

# set directory that contains labelme annotations and image files
labelme_folder = "tests/data/labelme_annot"

# set export dir
export_dir = "tests/data/"

# set train split rate
train_split_rate = 0.85

# set category ID start value
category_id_start = 1

# convert labelme annotations to coco
labelme2coco.convert(labelme_folder, export_dir, train_split_rate, category_id_start=category_id_start)
# import functions
from labelme2coco import get_coco_from_labelme_folder, save_json

# set labelme training data directory
labelme_train_folder = "tests/data/labelme_annot"

# set labelme validation data directory
labelme_val_folder = "tests/data/labelme_annot"

# set path for coco json to be saved
export_dir = "tests/data/"

# set category ID start value
category_id_start = 1

# create train coco object
train_coco = get_coco_from_labelme_folder(labelme_train_folder, category_id_start=category_id_start)

# export train coco json
save_json(train_coco.json, export_dir+"train.json")

# create val coco object
val_coco = get_coco_from_labelme_folder(labelme_val_folder, coco_category_list=train_coco.json_categories, category_id_start=category_id_start)

# export val coco json
save_json(val_coco.json, export_dir+"val.json")

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.