def make_avenue_dataset(
    root: Path,
    gt_dir: Path,
    split: Split | str | None = None,
) -> DataFrame:
    """Create CUHK Avenue dataset by parsing the file structure.

    The files are expected to follow the structure:
        path/to/dataset/[training_videos|testing_videos]/video_filename.avi
        path/to/ground_truth/mask_filename.mat

    Args:
        root (Path): Path to dataset root directory
        gt_dir (Path): Path to ground truth directory
        split (Split | str | None, optional): Dataset split (train/test).
            Defaults to ``None``.

    Example:
        Get testing samples from Avenue dataset:

        >>> root = Path("./avenue")
        >>> gt_dir = Path("./avenue/masks")
        >>> samples = make_avenue_dataset(root, gt_dir, split="test")
        >>> samples.head()
           root     folder    image_path    mask_path   split
        0  ./avenue testing  01.avi        01_label.mat test
        1  ./avenue testing  02.avi        02_label.mat test

    Returns:
        DataFrame: Dataframe containing samples for the requested split
    """
    root = validate_path(root)

    samples_list = [(str(root),) + filename.parts[-2:] for filename in root.glob("**/*.avi")]
    samples = DataFrame(samples_list, columns=["root", "folder", "image_path"])

    samples.loc[samples.folder == "testing_videos", "mask_path"] = (
        samples.image_path.str.split(".").str[0].str.lstrip("0") + "_label.mat"
    )
    samples.loc[samples.folder == "testing_videos", "mask_path"] = (
        str(gt_dir) + "/testing_label_mask/" + samples.mask_path
    )
    samples.loc[samples.folder == "training_videos", "mask_path"] = ""

    samples["image_path"] = samples.root + "/" + samples.folder + "/" + samples.image_path

    samples.loc[samples.folder == "training_videos", "split"] = "train"
    samples.loc[samples.folder == "testing_videos", "split"] = "test"

    # infer the task type
    samples.attrs["task"] = "classification" if (samples["mask_path"] == "").all() else "segmentation"

    if split:
        samples = samples[samples.split == split]
        samples = samples.reset_index(drop=True)

    return samples
Create CUHK Avenue dataset by parsing the file structure.

    The files are expected to follow the structure:
        path/to/dataset/[training_videos|testing_videos]/video_filename.avi
        path/to/ground_truth/mask_filename.mat

    Args:
        root (Path): Path to dataset root directory
        gt_dir (Path): Path to ground truth directory
        split (Split | str | None, optional): Dataset split (train/test).
            Defaults to ``None``.

    Example:
        Get testing samples from Avenue dataset:

        >>> root = Path("./avenue")
        >>> gt_dir = Path("./avenue/masks")
        >>> samples = make_avenue_dataset(root, gt_dir, split="test")
        >>> samples.head()
           root     folder    image_path    mask_path   split
        0  ./avenue testing  01.avi        01_label.mat test
        1  ./avenue testing  02.avi        02_label.mat test

    Returns:
        DataFrame: Dataframe containing samples for the requested split
    
src/anomalib/data/datasets/video/avenue.py