Skip to content

deeplabcut.create_project.demo_data

Functions:

Name Description
load_demo_data

Loads the demo data -- subset from trail-tracking data in Mathis et al. 2018.

transform_data

This function adds the full path to labeling dataset.

load_demo_data

load_demo_data(config: str | Path, createtrainingset: bool = True, engine: Engine = Engine.PYTORCH)

Loads the demo data -- subset from trail-tracking data in Mathis et al. 2018. When loading, it sets paths correctly to run this project on your system.

Parameters:

Name Type Description Default

config

str | Path

Full path of the config.yaml file of the provided demo dataset.

required

createtrainingset

bool

Boolean variable indicating if a training set shall be created.

True

engine

Engine

The Engine to create the training set for if a training set shall be created.

PYTORCH

Examples:

deeplabcut.load_demo_data("config.yaml")

Source code in deeplabcut/create_project/demo_data.py
def load_demo_data(
    config: str | Path,
    createtrainingset: bool = True,
    engine: Engine = Engine.PYTORCH,
):
    """Loads the demo data -- subset from trail-tracking data in Mathis et al. 2018.
    When loading, it sets paths correctly to run this project on your system.

    Args:
        config (str | Path): Full path of the config.yaml file of the provided demo
            dataset.
        createtrainingset (bool): Boolean variable indicating if a training set shall be
            created.
        engine (Engine): The Engine to create the training set for if a training set
            shall be created.

    Examples:
            deeplabcut.load_demo_data("config.yaml")
    """
    config = Path(config).absolute()

    transform_data(config)
    if createtrainingset:
        print("Loaded, now creating training data...")
        deeplabcut.create_training_dataset(config, num_shuffles=1, engine=engine)

transform_data

transform_data(config: Path) -> None

This function adds the full path to labeling dataset.

It also adds the correct path to the video file in the config file.

Source code in deeplabcut/create_project/demo_data.py
def transform_data(config: Path) -> None:
    """This function adds the full path to labeling dataset.

    It also adds the correct path to the video file in the config file.
    """
    config = Path(config).absolute()
    project_path = config.parent
    cfg = auxiliaryfunctions.read_config(config)
    cfg["project_path"] = project_path
    if "Reaching" in project_path.parts:
        video_file = project_path / "videos" / "reachingvideo1.avi"
    elif "openfield" in project_path.parts:
        video_file = project_path / "videos" / "m4s1.mp4"
    else:
        print("This is not an official demo dataset.")
        return

    if "WILL BE AUTOMATICALLY UPDATED BY DEMO CODE" in cfg["video_sets"].keys():
        cfg["video_sets"][os.fspath(video_file)] = cfg["video_sets"].pop("WILL BE AUTOMATICALLY UPDATED BY DEMO CODE")

    auxiliaryfunctions.write_config(config, cfg)