Giter Club home page Giter Club logo

coco_utils's Introduction

coco_utils

Utility script for handling COCO-style data

Installation

Requires python version >= 3.9

Clone the repository

git clone [email protected]:hoel-bagard/coco_utils.git --recurse-submodules

Convert

TODO

Merge

If necessary merge several coco json with:

python src/merge_coco.py <path_to_first_json> <path_to_second_json>
python src/merge_coco.py ../data/second_dataset/vott-json-export_brown/coco_annotations.json ../data/second_dataset/vott-json-export_blue/coco_annotations.json ../data/second_dataset/first_dataset/coco_annotations.json

Resize

Resize the dataset (if needed):

python src/resize_coco.py <path_to_image_dir> <path_to_json_annotations> <output_path> <size1> <size2>
python src/resize_coco.py ../data/original_dataset/train/images/ ../data/original_dataset/train/annotations.json ../data/resized_dataset/train 550 550

Rename

Change all the ids from strings to ints:

python src/coco_ids_to_int.py <path_to_annotation_file>
python src/coco_ids_to_int.py ../data/train/annotations.json

Grayscale (remove that part ?)

Convert images to grayscale if desired:

python src/imgs_to_grayscale.py <path_to_image_folder>
python src/imgs_to_grayscale.py ../data/validation/images/

Split

Split the dataset into train and validation datasets:

python src/split_train_val.py <path to image folder> <path to annotation file> <output path>
python src/split_train_val.py ../data/original_dataset ../data/original_dataset/coco_annotations.json ../data/split_dataset/

Visualize the data

Finally, check that everything works as expected by using:

python src/visualize_coco_data.py <path to image folder> <path to annotation file>
python src/visualize_coco_data.py ../data/train/images/ ../data/train/annotations.json

Development

Installation

pip install -r requirements-dev.txt
pre-commit install

Tests

A few tests have been written using Pytest. Once Pytest is installed, those tests can be run with:

python -m pytest -v

Formating

The code is trying to follow diverse PEPs conventions (notably PEP8). To have a similar dev environment you can install the following packages:

pip install flake8 flake8-docstrings pep8-naming flake8-import-order flake8-bugbear flake8-quotes flake8-comprehensions

Pre-commit

It's a good idea to run the hooks against all of the files when adding new hooks (usually pre-commit will only run on the changed files during git hooks).

pre-commit run --all-files

coco_utils's People

Contributors

hoel-bagard avatar

Watchers

 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.