
import os
import yaml


def load_dataset_config(config_path=None):
    """加载数据集配置
    
    Args:
        config_path: 配置文件路径，默认使用项目根目录的 dataset.yaml
    
    Returns:
        dict: 数据集配置
    """
    if config_path is None:
        # 默认使用项目根目录的 dataset.yaml
        project_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
        config_path = os.path.join(project_root, 'dataset.yaml')
    
    if not os.path.exists(config_path):
        raise FileNotFoundError(f"配置文件不存在: {config_path}")

    with open(config_path, 'r', encoding='utf-8') as f:
        return yaml.safe_load(f)
