Code Monkey home page Code Monkey logo

coco2yolo's Introduction

coco2yolo

A CLI tool can create a specific task-dataset you want based on COCO dataset.
Given the annotation JSON file, this tool will help you download the data and set the symbolic links from data_dir to task_dir !!

Installation

Dependency Packages

$ pip3 install pycocotools requests click

Clon the Repository

$ git clone [email protected]:tw-yshuang/coco2yolo.git
  # or
$ git clone https://github.com/tw-yshuang/coco2yolo.git

Execute

$ chmod +x coco2yolo # add execute permission on UNIX/Linux
$ ./coco2yolo [OPTIONS] [CAT_INFOS]
  # or
$ python3 coco2yolo  [OPTIONS] [CAT_INFOS]

Usage

Usage: coco2yolo [OPTIONS] [CAT_INFOS]...

Options:
  --help                          Show this message and exit.
  -ann-path, --annotation-path TEXT
                                  JSON file. Path for label.  [required]
  -img-dir, --image-download-dir TEXT
                                  The directory of the image data place.
  -task-dir, --task-categories-dir TEXT
                                  Build a directory that follows the task-required categories.
  -cat-t, --category-type TEXT    Category input type. (interactive | file)  [default: interactive]
  -set, --set-computing-type TEXT
                                  Set Computing for the data. (union | intersection)  [default: union]

Locate The Annotation

It is a must option to execute this tool:

$ ./coco2yolo -ann-path <annotations/instances_xxx.json>

Category Type

Choose the category input type you want:

$ ./coco2yolo -ann-path <annotations/instances_xxx.json> -cat-t <interactive | file>

Mode

interactive : type the categories name you wish. (default)
file: locate a categories JSON file, e.g.

# example.json
["person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck"]

Set Computing Type

Choose the set computing type you want:

$ ./coco2yolo -ann-path <annotations/instances_xxx.json> -set <union | intersection>

Mode

union: collect the data that contain the categories you set from COCO images. (default)
interesction: collect the data that only satisfy the categories you set from COCO images.

Note

It will automatically create the directory that you given.
If you do not have the COCO images data in -img-dir <img_dir>, this tool will automatically download the images data to <img_dir> by task.
In the <task_dir> the images data will set the symbolic links from <img_dir> to <task_dir>

Example

$ ./coco2yolo -ann-path ./annotations/instances_train2017.json
...
Enter the directory that you save COCO images:
Enter the directory that you want to save the task:
$ ./coco2yolo -ann-path ./annotations/instances_train2017.json -img-dir ./train2017 -task-dir ./task -set intersection
...
Enter the categories name you wish(split: ', '):
$ ./coco2yolo -ann-path ./annotations/instances_train2017.json -img-dir ./train2017 -task-dir ./task  -cat-t file -set intersection
...
Enter the category JSON file you want:

coco2yolo's People

Contributors

tw-yshuang 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.