Spaces:
Sleeping
Sleeping
File size: 976 Bytes
8960670 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | """
Configuration loader for DCA-Net training.
"""
import yaml
from pathlib import Path
def load_config(config_path="configs/training_config.yaml"):
"""Load YAML configuration file.
Args:
config_path: Path to YAML config file
Returns:
dict: Configuration dictionary
"""
config_path = Path(config_path)
if not config_path.exists():
raise FileNotFoundError(f"Config file not found: {config_path}")
with open(config_path, 'r') as f:
config = yaml.safe_load(f)
# Ensure all directories exist
for dir_key in ['checkpoint_dir', 'log_dir']:
if dir_key in config.get('logging', {}):
Path(config['logging'][dir_key]).mkdir(parents=True, exist_ok=True)
for dir_key in ['model_save_dir', 'log_dir', 'figures_dir']:
if dir_key in config.get('paths', {}):
Path(config['paths'][dir_key]).mkdir(parents=True, exist_ok=True)
return config
|