<div align="center">
<h1>
labelme2coco
</h1>
<a href="https://pepy.tech/project/labelme2coco"><img src="https://pepy.tech/badge/labelme2coco" alt="downloads"></a>
<a href="https://badge.fury.io/py/labelme2coco"><img src="https://badge.fury.io/py/labelme2coco.svg" alt="pypi version"></a>
<a href="https://github.com/fcakyon/labelme2coco/actions/workflows/ci.yml"><img src="https://github.com/fcakyon/labelme2coco/workflows/CI/badge.svg" alt="ci"></a>
<a href="https://twitter.com/fcakyon"><img src="https://img.shields.io/badge/twitter-fcakyon_-blue?logo=twitter&style=flat" alt="fcakyon twitter">
<h4>
A lightweight package for converting your <a href="https://github.com/wkentaro/labelme">labelme</a> annotations into COCO object detection format.
</h4>
<h4>
<img width="700" alt="teaser" src="https://user-images.githubusercontent.com/34196005/148746639-9a7b9c08-2156-42ca-abae-a4e6aad095dd.gif">
</h4>
</div>
## Convert LabelMe annotations to COCO format in one step
[labelme](https://github.com/wkentaro/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
```python
labelme2coco path/to/labelme/dir
```
```python
labelme2coco path/to/labelme/dir --train_split_rate 0.85
```
```python
labelme2coco path/to/labelme/dir --category_id_start 1
```
### Advanced Usage
```python
# 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)
```
```python
# 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")
```
Raw data
{
"_id": null,
"home_page": "https://github.com/fcakyon/labelme2coco",
"name": "labelme2coco",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": null,
"author": "Fatih Cagatay Akyon",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/9f/1d/75147adf0981f4be135c6f4c2ffa5cea41b78362a5f38f7ebbd092b05183/labelme2coco-0.2.6.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n<h1>\n labelme2coco\n</h1>\n\n<a href=\"https://pepy.tech/project/labelme2coco\"><img src=\"https://pepy.tech/badge/labelme2coco\" alt=\"downloads\"></a>\n<a href=\"https://badge.fury.io/py/labelme2coco\"><img src=\"https://badge.fury.io/py/labelme2coco.svg\" alt=\"pypi version\"></a>\n<a href=\"https://github.com/fcakyon/labelme2coco/actions/workflows/ci.yml\"><img src=\"https://github.com/fcakyon/labelme2coco/workflows/CI/badge.svg\" alt=\"ci\"></a>\n<a href=\"https://twitter.com/fcakyon\"><img src=\"https://img.shields.io/badge/twitter-fcakyon_-blue?logo=twitter&style=flat\" alt=\"fcakyon twitter\">\n\n<h4>\n A lightweight package for converting your <a href=\"https://github.com/wkentaro/labelme\">labelme</a> annotations into COCO object detection format.\n</h4>\n\n<h4>\n <img width=\"700\" alt=\"teaser\" src=\"https://user-images.githubusercontent.com/34196005/148746639-9a7b9c08-2156-42ca-abae-a4e6aad095dd.gif\">\n</h4>\n</div>\n\n## Convert LabelMe annotations to COCO format in one step\n[labelme](https://github.com/wkentaro/labelme) is a widely used is a graphical image annotation tool that supports classification, segmentation, instance segmentation and object detection formats.\nHowever, widely used frameworks/models such as Yolact/Solo, Detectron, MMDetection etc. requires COCO formatted annotations.\n\nYou can use this package to convert labelme annotations to COCO format.\n\n## Getting started\n### Installation\n```\npip install -U labelme2coco\n```\n\n### Basic Usage\n\n```python\nlabelme2coco path/to/labelme/dir\n```\n\n```python\nlabelme2coco path/to/labelme/dir --train_split_rate 0.85\n```\n\n```python\nlabelme2coco path/to/labelme/dir --category_id_start 1\n```\n\n### Advanced Usage\n\n```python\n# import package\nimport labelme2coco\n\n# set directory that contains labelme annotations and image files\nlabelme_folder = \"tests/data/labelme_annot\"\n\n# set export dir\nexport_dir = \"tests/data/\"\n\n# set train split rate\ntrain_split_rate = 0.85\n\n# set category ID start value\ncategory_id_start = 1\n\n# convert labelme annotations to coco\nlabelme2coco.convert(labelme_folder, export_dir, train_split_rate, category_id_start=category_id_start)\n```\n\n```python\n# import functions\nfrom labelme2coco import get_coco_from_labelme_folder, save_json\n\n# set labelme training data directory\nlabelme_train_folder = \"tests/data/labelme_annot\"\n\n# set labelme validation data directory\nlabelme_val_folder = \"tests/data/labelme_annot\"\n\n# set path for coco json to be saved\nexport_dir = \"tests/data/\"\n\n# set category ID start value\ncategory_id_start = 1\n\n# create train coco object\ntrain_coco = get_coco_from_labelme_folder(labelme_train_folder, category_id_start=category_id_start)\n\n# export train coco json\nsave_json(train_coco.json, export_dir+\"train.json\")\n\n# create val coco object\nval_coco = get_coco_from_labelme_folder(labelme_val_folder, coco_category_list=train_coco.json_categories, category_id_start=category_id_start)\n\n# export val coco json\nsave_json(val_coco.json, export_dir+\"val.json\")\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "Convert labelme annotations into coco format in one step",
"version": "0.2.6",
"project_urls": {
"Homepage": "https://github.com/fcakyon/labelme2coco"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "898b3366bc652e2bfcb6387280b45da534ef01d4b04f958de84acf4746665fba",
"md5": "13d350ab906e3edc1ef2a132297bc94d",
"sha256": "9c86c1b4bcb2be5ca595af0ad9822445462414943ab9b2a251d29932534d5871"
},
"downloads": -1,
"filename": "labelme2coco-0.2.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "13d350ab906e3edc1ef2a132297bc94d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 19203,
"upload_time": "2024-04-20T12:26:09",
"upload_time_iso_8601": "2024-04-20T12:26:09.880348Z",
"url": "https://files.pythonhosted.org/packages/89/8b/3366bc652e2bfcb6387280b45da534ef01d4b04f958de84acf4746665fba/labelme2coco-0.2.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9f1d75147adf0981f4be135c6f4c2ffa5cea41b78362a5f38f7ebbd092b05183",
"md5": "16cf010885e1b68e4c5c72badce7038b",
"sha256": "25cb4b33e3de1d65763daa882e2bafc8091e3aa5cbf26fec386fa33941599db1"
},
"downloads": -1,
"filename": "labelme2coco-0.2.6.tar.gz",
"has_sig": false,
"md5_digest": "16cf010885e1b68e4c5c72badce7038b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 18174,
"upload_time": "2024-04-20T12:26:11",
"upload_time_iso_8601": "2024-04-20T12:26:11.171512Z",
"url": "https://files.pythonhosted.org/packages/9f/1d/75147adf0981f4be135c6f4c2ffa5cea41b78362a5f38f7ebbd092b05183/labelme2coco-0.2.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-20 12:26:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fcakyon",
"github_project": "labelme2coco",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "labelme2coco"
}