Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:PeterL1n BackgroundMattingV2 DATA PATH config

From Leeroopedia


Knowledge Sources
Domains Data_Management, Configuration
Last Updated 2026-02-09 00:00 GMT

Overview

Concrete configuration pattern for defining dataset directory paths provided by BackgroundMattingV2's data_path.py module.

Description

The DATA_PATH dictionary is a centralized configuration mapping that defines filesystem paths for all training and validation datasets. Each matting dataset entry maps a name (e.g., videomatte240k, photomatte13k, distinction, adobe) to train and valid splits, each containing fgr (foreground RGB) and pha (alpha matte) directory paths. A separate backgrounds key stores paths to background image directories used for compositing during training.

Usage

Edit data_path.py before running any training script. Replace all PATH_TO_IMAGES_DIR placeholder values with actual filesystem paths to your dataset directories.

Code Reference

Source Location

Signature

DATA_PATH: Dict[str, Dict[str, Union[str, Dict[str, str]]]] = {
    'videomatte240k': {
        'train': {'fgr': 'PATH_TO_IMAGES_DIR', 'pha': 'PATH_TO_IMAGES_DIR'},
        'valid': {'fgr': 'PATH_TO_IMAGES_DIR', 'pha': 'PATH_TO_IMAGES_DIR'},
    },
    'photomatte13k': {
        'train': {'fgr': 'PATH_TO_IMAGES_DIR', 'pha': 'PATH_TO_IMAGES_DIR'},
        'valid': {'fgr': 'PATH_TO_IMAGES_DIR', 'pha': 'PATH_TO_IMAGES_DIR'},
    },
    'distinction': {
        'train': {'fgr': 'PATH_TO_IMAGES_DIR', 'pha': 'PATH_TO_IMAGES_DIR'},
        'valid': {'fgr': 'PATH_TO_IMAGES_DIR', 'pha': 'PATH_TO_IMAGES_DIR'},
    },
    'adobe': {
        'train': {'fgr': 'PATH_TO_IMAGES_DIR', 'pha': 'PATH_TO_IMAGES_DIR'},
        'valid': {'fgr': 'PATH_TO_IMAGES_DIR', 'pha': 'PATH_TO_IMAGES_DIR'},
    },
    'backgrounds': {
        'train': 'PATH_TO_IMAGES_DIR',
        'valid': 'PATH_TO_IMAGES_DIR',
    },
}

Import

from data_path import DATA_PATH

I/O Contract

Inputs

Name Type Required Description
(user edit) str Yes Replace placeholder paths with actual filesystem paths

Outputs

Name Type Description
DATA_PATH Dict[str, Dict] Nested dictionary consumed by training scripts to construct ImagesDataset instances

Usage Examples

Configuring Dataset Paths

# Edit data_path.py to set actual paths:
DATA_PATH = {
    'videomatte240k': {
        'train': {
            'fgr': '/data/videomatte240k/train/fgr',
            'pha': '/data/videomatte240k/train/pha',
        },
        'valid': {
            'fgr': '/data/videomatte240k/valid/fgr',
            'pha': '/data/videomatte240k/valid/pha',
        },
    },
    'backgrounds': {
        'train': '/data/backgrounds/train',
        'valid': '/data/backgrounds/valid',
    },
}

Using in Training Script

from data_path import DATA_PATH
from dataset import ImagesDataset

# Construct datasets from configured paths
dataset_name = 'videomatte240k'
fgr_dataset = ImagesDataset(DATA_PATH[dataset_name]['train']['fgr'])
pha_dataset = ImagesDataset(DATA_PATH[dataset_name]['train']['pha'])
bgr_dataset = ImagesDataset(DATA_PATH['backgrounds']['train'])

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment