facebookresearch / facebookresearch/sam2

path inconsistencies between filesystem and hydra

Open
#701 2 comments 2 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
19.9k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

Great work, but config paths are more complex than they ought to be.
* you have 2 different way to define paths, one for the pth the other for the configs. Cloning and running does not by default work ( probably unless `cwd` is something specific). Hydra may be elegant for some specific pipelines but definitely not for me.

What id like? To use this great project without the hydra mess.

I made it work for me by clearing the default sam2 hydra initialization
```python
import os
from hydra.core.global_hydra import GlobalHydra
from hydra import initialize, compose

from sam2.build_sam import build_sam2 # hydra paths get set on class init

# to use ones own paths clear hydra
GlobalHydra.instance().clear()

sam2_checkpoint = os.path.join(checkpoint_path, "sam2.1_hiera_large.pt") # OK
config_file = os.path.join(config_path, "sam2.1_hiera_l.yaml") # <- this won't work unless one re initializes hydra

# instead do this and overwrite the hydra paths
config_file = "sam2.1_hiera_l.yaml"
config_path = "../some/path/relative/to/cwd"

with initialize(version_base=None, config_path=config_path):
sam2_model = build_sam2(config_file, sam2_checkpoint, device=device, apply_postprocessing=False)
```
also see this https://github.com/facebookresearch/hydra/issues/3060

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.