to_yolov7#

Dataset.to_yolov7(output_path: Path | str, copy_images: bool = False, overwrite_images: bool = True, overwrite_labels: bool = True, split_name_mapping: dict[str, str] | None = None, create_split_folder: bool = False) None[source]#

Save dataset in format readable by Yolov7 . Save each split in its dedicated split file containing paths to corresponding images, separate images and annotations with the folders images and labels, and save corresponding info in data.yaml, at the root of the output path.

Optionally, remap the split values so that it fits the training script. Normally, yolov5 expect train, val and test sets. The default mapping replaces valid and validation to val, and eval to test.

Note

The only difference with to_yolov5() is the fact that path to split list files are absolute and not relative to the yaml file parent folder.

Parameters:
  • output_path – folder where images and annotations will be stored

  • copy_images – If set to False, will create a symbolic link instead of copying. Much faster, but needs to keep original images in the same relative path. Defaults to False.

  • overwrite_images – if set to False, will skip images that are already copied. Defaults to True.

  • overwrite_labels – if set to False, will skip annotation that are already created. Defaults to True.

  • split_name_mapping – mapping dict to replace split names to other ones. split names not present in mapping will not be modified. If set to None, will apply yolov5 conventional mapping, i.e. {'valid': 'val', 'validation': 'val', 'eval': 'test'}. Defaults to None

  • create_split_folder – if set to True, will create a dedicated folder for each split and will save images in it. Image paths in {split}.txt will be changed accordingly. Note that this changes the dataset structure. Defaults to False