https://github.com/akarazniewicz/cocosplit
Simple tool to split COCO annotations into train/test datasets.
https://github.com/akarazniewicz/cocosplit
coco datapreprocessing deeplearning
Last synced: 7 months ago
JSON representation
Simple tool to split COCO annotations into train/test datasets.
- Host: GitHub
- URL: https://github.com/akarazniewicz/cocosplit
- Owner: akarazniewicz
- Created: 2019-09-06T13:13:33.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-08-15T15:00:04.000Z (over 2 years ago)
- Last Synced: 2023-11-07T19:29:29.833Z (about 2 years ago)
- Topics: coco, datapreprocessing, deeplearning
- Language: Python
- Homepage:
- Size: 9.77 KB
- Stars: 215
- Watchers: 3
- Forks: 87
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Simple tool to split a multi-label coco annotation dataset with preserving class distributions among train and test sets.
The code is an updated version from [akarazniewicz/cocosplit](https://github.com/akarazniewicz/cocosplit) original repo, where the functionality of splitting multi-class data while preserving distributions is added.
## Installation
``cocosplit`` requires python 3 and basic set of dependencies:
specifically, in addition to the requirements of the original repo, (``scikit-multilearn``) is required, it is included the requirements.txt file
```
pip install -r requirements
```
## Usage
The same as the original repo, with adding an argument (``--multi-class``) to preserve class distributions
The argument is optional to ensure backward compatibility
```
$ python cocosplit.py -h
usage: cocosplit.py [-h] -s SPLIT [--having-annotations]
coco_annotations train test
Splits COCO annotations file into training and test sets.
positional arguments:
coco_annotations Path to COCO annotations file.
train Where to store COCO training annotations
test Where to store COCO test annotations
optional arguments:
-h, --help show this help message and exit
-s SPLIT A percentage of a split; a number in (0, 1)
--having-annotations Ignore all images without annotations. Keep only these
with at least one annotation
--multi-class Split a multi-class dataset while preserving class
distributions in train and test sets
```
# Running
```
$ python cocosplit.py --having-annotations --multi-class -s 0.8 /path/to/your/coco_annotations.json train.json test.json
```
will split ``coco_annotation.json`` into ``train.json`` and ``test.json`` with ratio 80%/20% respectively. It will skip all
images (``--having-annotations``) without annotations.