(cfg, name)
| 280 | |
| 281 | # Returns the directory path of the best matching preprocessed dataset |
| 282 | def get_preproc_data_dir(cfg, name): |
| 283 | # Get all preprocessed versions of the requested dataset |
| 284 | data_dirs = sorted([f for f in glob(os.path.join(cfg.preproc_dir, name + '.*')) if os.path.isdir(f)]) |
| 285 | |
| 286 | # Iterate over all dataset versions |
| 287 | best_dir = None |
| 288 | best_num_channels = None |
| 289 | |
| 290 | for data_dir in data_dirs: |
| 291 | # Load the dataset config if it exists (ignore corrupted datasets) |
| 292 | if os.path.isfile(get_config_filename(data_dir)): |
| 293 | data_cfg = load_config(data_dir) |
| 294 | |
| 295 | # Backward compatibility |
| 296 | if not hasattr(data_cfg, 'clean_aux'): |
| 297 | data_cfg.clean_aux = False |
| 298 | if not hasattr(data_cfg, 'aux_results'): |
| 299 | data_cfg.aux_results = [] |
| 300 | |
| 301 | # Check whether the dataset matches the requirements |
| 302 | if get_main_feature(data_cfg.features) == get_main_feature(cfg.features) and \ |
| 303 | all(f in data_cfg.features for f in cfg.features) and \ |
| 304 | data_cfg.clean_aux == cfg.clean_aux and \ |
| 305 | (not data_cfg.aux_results if not cfg.aux_results else \ |
| 306 | all(r in data_cfg.aux_results for r in cfg.aux_results)) and \ |
| 307 | data_cfg.transfer == cfg.transfer: |
| 308 | # Select the most recent version with the minimal amount of channels stored |
| 309 | num_channels = len(get_dataset_channels(data_cfg.features)) |
| 310 | if best_dir is None or num_channels <= best_num_channels: |
| 311 | best_dir = data_dir |
| 312 | best_num_channels = num_channels |
| 313 | |
| 314 | if best_dir is None: |
| 315 | error('no matching preproccessed dataset found') |
| 316 | return best_dir |
| 317 | |
| 318 | class PreprocessedDataset(Dataset): |
| 319 | def __init__(self, cfg, name): |
no test coverage detected