D2Y Functions#
convert()#
- deeplabcut2yolo.convert(dataset_path, pickle_paths=None, config_path=None, train_paths=None, val_paths=None, data_yml_path=None, skeleton_symmetric_pairs=None, override_classes=None, class_names=None, precision=6, verbose=False)[source]#
Convert DeepLabCut dataset to YOLO format
DeepLabCut labels can be found in the pickled label file(s), the CollectedData CSV, the CollectedData HDF (.h5) in the dataset iteration directory and in the image directories. They consists of the datapoint classes, keypoint IDs and their coordinates. This library utilizes the pickled label file located in the subdirectory training-dataset/. The number of classes and number of keypoints per datapoint are obtained from the config.yaml found in the dataset root directory.
The YOLO format requires the class IDs, their bounding box positions (x, y) and dimensions (w, h), and the keypoints (px, py, visibility). These data need to be normalized.
If multiple pickled label files are found, d2y will attempt to convert all the files.
- Parameters:
dataset_path (
Path | str
) – Path to the dataset root directorypickle_paths (
Path | str | list[Path] | list[str] | None, optional
) – Path to the dataset pickled labels. Specify this argument if the dataset directory structure does not match typical DeepLabCut structure. Defaults to None.config_path (
Path | str | None, optional
) – Path to the dataset config.yaml. Specify this argument if the dataset directory structure does not match typical DeepLabCut structure. Defaults to None.train_paths (
list[Path] | list[str] | Path | str | None, optional
) – Path(s) to the training directories. Required when specifying data_yml_path. Defaults to None.val_paths (
list[Path] | list[str] | Path | str | None, optional
) – Path(s) to the validation directories. Required when specifying data_yml_path. Defaults to None.data_yml_path (
Path | str | None, optional
) – Path to create the data.yml file. Leaving the parameter as None will not create the data.yml file. Defaults to None.skeleton_symmetric_pairs (
list[tuple[int, int]] | None, optional
) – A list of symmetric keypoint indices. For example, with head=0, left_eye=1, right_eye=2, and body=3, the skeleton_symmetric_pairs will be [(1, 2)]. YOLO performs better when symmetric pairs are appropriately defined. Leave as None if there is no symmetric pair. Defaults to None.override_classes (
list[int] | str | None, optional
) – Overriding class IDs to map from the original dataset class IDs. For example, the original classes are 0, 1, and 2. To override 0 and 1 to class 0 and 2 to class 1, this argument will be [0, 0, 1] in the list format or “001” in the string format. Defaults to None.class_names (
list[str] | list[int] | None, optional
) – A list of class names. If None, then the class names will be 0, 1, 2, … or corresponding to the unique indices in the provided override_classes. Defaults to None.precision (
int, optional
) – The number of decimals of the converted label. Defaults to 6.verbose (
bool, optional
) – Print the conversion information and status. If set to true, you can optionally install tqdm to enabele progress bar. Defaults to False.