Giter VIP home page Giter VIP logo

labelme2yolo's Introduction

Labelme2YOLO

Forked from rooneysh/Labelme2YOLO

PyPI - Version PyPI - Downloads PyPI - Python Version Codacy Badge

Help converting LabelMe Annotation Tool JSON format to YOLO text file format. If you've already marked your segmentation dataset by LabelMe, it's easy to use this tool to help converting to YOLO format dataset.

New

  • export data as yolo polygon annotation (for YOLOv5 v7.0 segmentation)
  • Now you can choose the output format of the label text. The available options are plygon and bbox.

Installation

pip install labelme2yolo

Parameters Explain

--json_dir LabelMe JSON files folder path.

--val_size (Optional) Validation dataset size, for example 0.2 means 20% for validation.

--test_size (Optional) Test dataset size, for example 0.2 means 20% for Test.

--json_name (Optional) Convert single LabelMe JSON file.

--output_format (Optional) The output format of label.

How to Use

1. Convert JSON files, split training, validation and test dataset by --val_size and --test_size

Put all LabelMe JSON files under labelme_json_dir, and run this python command.

labelme2yolo --json_dir /path/to/labelme_json_dir/ --val_size 0.15 --test_size 0.15

Script would generate YOLO format dataset labels and images under different folders, for example,

/path/to/labelme_json_dir/YOLODataset/labels/train/
/path/to/labelme_json_dir/YOLODataset/labels/test/
/path/to/labelme_json_dir/YOLODataset/labels/val/
/path/to/labelme_json_dir/YOLODataset/images/train/
/path/to/labelme_json_dir/YOLODataset/images/test/
/path/to/labelme_json_dir/YOLODataset/images/val/

/path/to/labelme_json_dir/YOLODataset/dataset.yaml

2. Convert JSON files, split training and validation dataset by folder

If you already split train dataset and validation dataset for LabelMe by yourself, please put these folder under labelme_json_dir, for example,

/path/to/labelme_json_dir/train/
/path/to/labelme_json_dir/val/

Put all LabelMe JSON files under labelme_json_dir. Script would read train and validation dataset by folder. Run this python command.

labelme2yolo --json_dir /path/to/labelme_json_dir/

Script would generate YOLO format dataset labels and images under different folders, for example,

/path/to/labelme_json_dir/YOLODataset/labels/train/
/path/to/labelme_json_dir/YOLODataset/labels/val/
/path/to/labelme_json_dir/YOLODataset/images/train/
/path/to/labelme_json_dir/YOLODataset/images/val/

/path/to/labelme_json_dir/YOLODataset/dataset.yaml

3. Convert single JSON file

Put LabelMe JSON file under labelme_json_dir. , and run this python command.

labelme2yolo --json_dir /path/to/labelme_json_dir/ --json_name 2.json

Script would generate YOLO format text label and image under labelme_json_dir, for example,

/path/to/labelme_json_dir/2.text
/path/to/labelme_json_dir/2.png

How to build package/wheel

  1. install hatch
  2. Run the following command:
hatch build

License

labelme2yolo is distributed under the terms of the MIT license.

labelme2yolo's People

Contributors

greatv avatar rooneysh avatar dependabot[bot] avatar arshadoid avatar

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.