Skip to content

Commit

Permalink
Merge pull request #406 from claritychallenge/grd-hydra-set-version-b…
Browse files Browse the repository at this point in the history
…ase-and-chdir

Hydra explicit params
  • Loading branch information
jonbarker68 authored Sep 9, 2024
2 parents b383605 + a4cfc57 commit c191b4a
Show file tree
Hide file tree
Showing 54 changed files with 77 additions and 44 deletions.
4 changes: 3 additions & 1 deletion recipes/cad1/task1/baseline/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ evaluate:
# hydra config
hydra:
run:
dir: ${path.exp_folder}
dir: ${path.exp_folder}
job:
chdir: True
2 changes: 1 addition & 1 deletion recipes/cad1/task1/baseline/enhance.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def save_flac_signal(
FlacEncoder().encode(signal, output_sample_rate, filename)


@hydra.main(config_path="", config_name="config")
@hydra.main(config_path="", config_name="config", version_base=None)
def enhance(config: DictConfig) -> None:
"""
Run the music enhancement.
Expand Down
2 changes: 1 addition & 1 deletion recipes/cad1/task1/baseline/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _evaluate_song_listener(
return float(combined_score), per_instrument_score


@hydra.main(config_path="", config_name="config")
@hydra.main(config_path="", config_name="config", version_base=None)
def run_calculate_aq(config: DictConfig) -> None:
"""Evaluate the enhanced signals using the HAAQI-RMS metric."""
# Load test songs
Expand Down
2 changes: 1 addition & 1 deletion recipes/cad1/task1/baseline/merge_batches_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from omegaconf import DictConfig


@hydra.main(config_path="", config_name="config")
@hydra.main(config_path="", config_name="config", version_base=None)
def join_batches(config: DictConfig) -> None:
"""
Join batches scores into a single file.
Expand Down
2 changes: 1 addition & 1 deletion recipes/cad1/task1/baseline/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def pack_submission(
)


@hydra.main(config_path="", config_name="config")
@hydra.main(config_path="", config_name="config", version_base=None)
def enhance(config: DictConfig) -> None:
"""
Run the music enhancement.
Expand Down
4 changes: 3 additions & 1 deletion recipes/cad1/task2/baseline/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ evaluate:
# hydra config
hydra:
run:
dir: ${path.exp_folder}
dir: ${path.exp_folder}
job:
chdir: True
2 changes: 1 addition & 1 deletion recipes/cad1/task2/baseline/enhance.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def enhance_song(
return out_left, out_right


@hydra.main(config_path="", config_name="config")
@hydra.main(config_path="", config_name="config", version_base=None)
def enhance(config: DictConfig) -> None:
"""
Run the music enhancement.
Expand Down
2 changes: 1 addition & 1 deletion recipes/cad1/task2/baseline/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def evaluate_scene(
return aq_score_l, aq_score_r


@hydra.main(config_path="", config_name="config")
@hydra.main(config_path="", config_name="config", version_base=None)
def run_calculate_audio_quality(config: DictConfig) -> None:
"""Evaluate the enhanced signals using the HAAQI metric."""

Expand Down
2 changes: 1 addition & 1 deletion recipes/cad1/task2/baseline/merge_batches_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from omegaconf import DictConfig


@hydra.main(config_path="", config_name="config")
@hydra.main(config_path="", config_name="config", version_base=None)
def join_batches(config: DictConfig) -> None:
"""
Join batches scores into a single file.
Expand Down
2 changes: 1 addition & 1 deletion recipes/cad1/task2/baseline/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def pack_submission(
)


@hydra.main(config_path="", config_name="config")
@hydra.main(config_path="", config_name="config", version_base=None)
def enhance(config: DictConfig) -> None:
"""
Run the music enhancement.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def get_random_snr(min_snr, max_snr, round_to=4) -> float:
return float(np.round(np.random.uniform(min_snr, max_snr, 1), round_to))


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def run(cfg: DictConfig) -> None:
"""Main function to generate metadata for the scenes in the CAD-1 Task-2 challenge.
Expand Down
2 changes: 2 additions & 0 deletions recipes/cad1/task2/data_preparation/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ valid_seed: 2023
hydra:
run:
dir: .
job:
chdir: True
4 changes: 3 additions & 1 deletion recipes/cad_icassp_2024/baseline/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ evaluate:
# hydra config
hydra:
run:
dir: ${path.exp_folder}
dir: ${path.exp_folder}
job:
chdir: True
2 changes: 1 addition & 1 deletion recipes/cad_icassp_2024/baseline/enhance.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def process_remix_for_listener(
return np.stack([left_output, right_output], axis=1)


@hydra.main(config_path="", config_name="config")
@hydra.main(config_path="", config_name="config", version_base=None)
def enhance(config: DictConfig) -> None:
"""
Run the music enhancement.
Expand Down
2 changes: 1 addition & 1 deletion recipes/cad_icassp_2024/baseline/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def load_reference_stems(music_dir: str | Path) -> tuple[dict[str, ndarray], nda
return reference_stems, read_signal(Path(music_dir) / "mixture.wav")


@hydra.main(config_path="", config_name="config")
@hydra.main(config_path="", config_name="config", version_base=None)
def run_calculate_aq(config: DictConfig) -> None:
"""Evaluate the enhanced signals using the HAAQI metric."""

Expand Down
2 changes: 1 addition & 1 deletion recipes/cad_icassp_2024/baseline/merge_batches_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from omegaconf import DictConfig


@hydra.main(config_path="", config_name="config")
@hydra.main(config_path="", config_name="config", version_base=None)
def join_batches(config: DictConfig) -> None:
"""
Join batches scores into a single file.
Expand Down
2 changes: 2 additions & 0 deletions recipes/cad_icassp_2024/generate_dataset/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ scene_listener:
hydra:
run:
dir: .
job:
chdir: True
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def find_precreated_samples(source_dir: str | Path) -> list[str]:
return previous_tracks


@hydra.main(config_path="", config_name="config")
@hydra.main(config_path="", config_name="config", version_base=None)
def run(cfg: DictConfig) -> None:
"""Main function of the script."""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def generate_scene_listener(cfg: DictConfig) -> None:
json.dump(scene_listeners, f, indent=4)


@hydra.main(config_path="", config_name="config")
@hydra.main(config_path="", config_name="config", version_base=None)
def run(cfg: DictConfig) -> None:
"""Module generates the scenes and scene-listeners metadata files for training."""
generate_scenes(cfg)
Expand Down
2 changes: 2 additions & 0 deletions recipes/cec1/baseline/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,5 @@ hydra:
output_subdir: Null
run:
dir: .
job:
chdir: True
2 changes: 1 addition & 1 deletion recipes/cec1/baseline/enhance.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from clarity.utils.audiogram import Listener


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def enhance(cfg: DictConfig) -> None:
enhanced_folder = Path(cfg.path.exp_folder) / "enhanced_signals"
enhanced_folder.mkdir(parents=True, exist_ok=True)
Expand Down
2 changes: 1 addition & 1 deletion recipes/cec1/baseline/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def listen(ear, signal: ndarray, listener: Listener):
return np.concatenate([out_l, out_r]).T


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def run_HL_processing(cfg: DictConfig) -> None:
output_path = Path(cfg.path.exp_folder) / "eval_signals"
output_path.mkdir(parents=True, exist_ok=True)
Expand Down
4 changes: 3 additions & 1 deletion recipes/cec1/data_preparation/data_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@ defaults:
hydra:
output_subdir: Null
run:
dir: .
dir: .
job:
chdir: True
2 changes: 1 addition & 1 deletion recipes/cec1/data_preparation/prepare_cec1_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def prepare_data(
)


@hydra.main(config_path=".", config_name="data_config")
@hydra.main(config_path=".", config_name="data_config", version_base=None)
def run(cfg: DictConfig) -> None:
for dataset in cfg["datasets"]:
prepare_data(
Expand Down
2 changes: 2 additions & 0 deletions recipes/cec1/e009_sheffield/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,5 @@ hydra:
# output_subdir: ${path.exp_folder}.hydra
run:
dir: ${path.exp_folder}
job:
chdir: True
2 changes: 1 addition & 1 deletion recipes/cec1/e009_sheffield/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from clarity.enhancer.dsp.filter import AudiometricFIR


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def run(cfg: DictConfig) -> None:
exp_folder = Path(cfg.path.exp_folder)
output_folder = exp_folder / f"enhanced_{cfg.listener.id}"
Expand Down
2 changes: 1 addition & 1 deletion recipes/cec1/e009_sheffield/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def train_amp(cfg, ear):
torch.save(amp_module.model.state_dict(), str(exp_dir / "best_model.pth"))


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def run(cfg: DictConfig) -> None:
logger.info("Begin training left ear enhancement module.")
train_den(cfg, ear="left")
Expand Down
2 changes: 2 additions & 0 deletions recipes/cec2/baseline/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ evaluate:
hydra:
run:
dir: ${path.exp_folder}
job:
chdir: True
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ render_params:
hydra:
run:
dir: .
job:
chdir: True

defaults:
- override hydra/launcher: cec2_submitit_local
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def instantiate_scenes(cfg):
logger.info(f"scenes.{dataset}.json has existed, skip")


@hydra.main(config_path=".", config_name="additional_data_config")
@hydra.main(config_path=".", config_name="additional_data_config", version_base=None)
def run(cfg: DictConfig) -> None:
logger.info("Instantiating scenes for additional training data")
instantiate_scenes(cfg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def render_scenes(cfg):
scene_renderer.render_scenes(scenes)


@hydra.main(config_path=".", config_name="additional_data_config")
@hydra.main(config_path=".", config_name="additional_data_config", version_base=None)
def run(cfg: DictConfig) -> None:
logger.info("Rendering scenes")
render_scenes(cfg)
Expand Down
2 changes: 1 addition & 1 deletion recipes/cec2/baseline/enhance.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
logger = logging.getLogger(__name__)


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def enhance(cfg: DictConfig) -> None:
enhanced_folder = Path(cfg.path.exp_folder) / "enhanced_signals"
enhanced_folder.mkdir(parents=True, exist_ok=True)
Expand Down
2 changes: 1 addition & 1 deletion recipes/cec2/baseline/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def read_csv_scores(file: Path) -> Dict[str, float]:
return score_dict


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def run_calculate_SI(cfg: DictConfig) -> None:
with Path(cfg.path.scenes_listeners_file).open("r", encoding="utf-8") as fp:
scenes_listeners = json.load(fp)
Expand Down
2 changes: 1 addition & 1 deletion recipes/cec2/data_preparation/build_scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def instantiate_scenes(cfg):
logger.info(f"scenes.{dataset}.json exists, skip")


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def run(cfg: DictConfig) -> None:
logger.info("Building rooms")
build_rooms_from_rpf(cfg)
Expand Down
2 changes: 2 additions & 0 deletions recipes/cec2/data_preparation/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ render_params:
hydra:
run:
dir: .
job:
chdir: True

defaults:
- override hydra/launcher: cec2_submitit_local
2 changes: 1 addition & 1 deletion recipes/cec2/data_preparation/render_scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def render_scenes(cfg):
scene_renderer.render_scenes(scenes)


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def run(cfg: DictConfig) -> None:
logger.info("Rendering scenes")
render_scenes(cfg)
Expand Down
2 changes: 1 addition & 1 deletion recipes/cpc1/baseline/compute_scores.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def read_data(pred_csv: Path, label_json: Path):
return data


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def run(cfg: DictConfig) -> None:
logger.info("Run evaluation on the closed set.")
data_tr = read_data(
Expand Down
2 changes: 2 additions & 0 deletions recipes/cpc1/baseline/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ hydra:
output_subdir: Null
run:
dir: .
job:
chdir: True
2 changes: 1 addition & 1 deletion recipes/cpc1/baseline/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def run_calculate_SI(cfg, path) -> None:
csv_writer.writerow(line)


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def run(cfg: DictConfig) -> None:
logger.info("Prediction with MSGB + MBSTOI for train set")
run_HL_processing(cfg, cfg.train_path)
Expand Down
2 changes: 2 additions & 0 deletions recipes/cpc1/e029_sheffield/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ hydra:
output_subdir: Null
run:
dir: .
job:
chdir: True
2 changes: 1 addition & 1 deletion recipes/cpc1/e029_sheffield/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def read_data(pred_json: Path, label_json: Path):
return np.array(prediction), np.array(label)


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def run(cfg: DictConfig) -> None:
if cfg.cpc1_track == "open":
track = "_indep"
Expand Down
2 changes: 1 addition & 1 deletion recipes/cpc1/e029_sheffield/infer.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def compute_uncertainty(left_proc_path, asr_model, bos_index, _tokenizer):
return conf, neg_ent


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def run(cfg: DictConfig) -> None:
if cfg.cpc1_track == "open":
track = "_indep"
Expand Down
7 changes: 4 additions & 3 deletions recipes/cpc1/e029_sheffield/prepare_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,9 @@ def generate_data_split(
if if_msbg:
wav_file = orig_signal_folder / f"{snt_id}_HL-output.wav"
elif if_ref:
wav_file = orig_signal_folder / (
f"../../scenes/{snt_id.split('_')[0]}_target_anechoic.wav"
wav_file = (
orig_signal_folder
/ f"../../scenes/{snt_id.split('_')[0]}_target_anechoic.wav"
)
else:
wav_file = orig_signal_folder / f"{snt_id}.wav"
Expand Down Expand Up @@ -293,7 +294,7 @@ def run_signal_generation_test(cfg, track):
)


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def run(cfg: DictConfig) -> None:
if cfg.cpc1_track == "open":
track = "_indep"
Expand Down
2 changes: 2 additions & 0 deletions recipes/cpc1/e032_sheffield/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ hydra:
output_subdir: Null
run:
dir: .
job:
chdir: True
2 changes: 1 addition & 1 deletion recipes/cpc1/e032_sheffield/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def read_data(pred_json: Path, label_json: Path):
return np.array(prediction), np.array(label)


@hydra.main(config_path=".", config_name="config")
@hydra.main(config_path=".", config_name="config", version_base=None)
def run(cfg: DictConfig) -> None:
if cfg.cpc1_track == "open":
track = "_indep"
Expand Down
Loading

0 comments on commit c191b4a

Please sign in to comment.