This code is used to convert a dataset in COCO format to a dataset in Yolo format which can be used to train a YoloV5 model.
Install the dependencies with pipenv: pipenv install
and activate the environment: pipenv shell
.
Use:
python src/sbb2yolo.py --coco-input-folders PATH_TO_COCO_INPUT_FOLDER1 PATH_TO_COCO_INPUT_FOLDER2 \
--yolo-output-folder PATH_TO_OUTPUT_FOLDER \
--yolo-config-file CONFIG_FILE_NAME \
--dataset-split-pivot RATIO_TRAIN_TO_VAL
- The conversion script takes the Coco input folders (folder containing all images as well as an annotation file). Several Coco datasets can be specified, in which case the script combines all the datasets.
- It creates a datast in Yolo format in
PATH_TO_OUTPUT_FOLDER
. This dataset contains the configuration file, as well as animages
andlabels
folder - The name of the YAML config file can be changed (
--yolo-config-file
) - The proportion of the data to use for test is specified with
--dataset-split-pivot
, e.g. 0.8 means 80% for the training set and the remaining 20% for the validation set.
In order to run the tests, use:
pytest
- Stefan Aebischer
- Jeanne Fleury