ITADN

fix: use initialize_config_dir to support custom Hydra config roots and prevent reinitialization errors

#101Pull Requestanujonthemove 创建于 2025-05-13
A
anujonthemovecommented
This patch replaces the direct call to `compose()` with a safer and more flexible Hydra pattern using `initialize_config_dir`. It resolves issues encountered when: - Running without `hydra.main()` (e.g., in scripts or notebooks) - Using custom config directories not in Hydra's default search path - Reusing Hydra within the same Python process (caused GlobalHydra reinitialization errors) The fix: - Explicitly initializes Hydra with the given `config_root` - Clears existing Hydra state before initialization to prevent errors - Adds logging and error handling for better debuggability This makes the `build_sam2()` function robust across different environments and ensures compatibility with Hydra ≥ 1.3.2.
合并状态:未合并 0 条评论