mirror of
https://github.com/Stability-AI/generative-models.git
synced 2025-12-21 23:34:22 +01:00
Set up Python packaging (#17)
* Sort .gitignore; add dist and *.py[cod] * Use pyproject.toml + Hatch instead of setup.py Sibling of https://github.com/Stability-AI/stablediffusion/pull/269 * Add packaging documentation
This commit is contained in:
18
sgm/util.py
18
sgm/util.py
@@ -229,3 +229,21 @@ def load_model_from_config(config, ckpt, verbose=True, freeze=True):
|
||||
|
||||
model.eval()
|
||||
return model
|
||||
|
||||
|
||||
def get_configs_path() -> str:
|
||||
"""
|
||||
Get the `configs` directory.
|
||||
For a working copy, this is the one in the root of the repository,
|
||||
but for an installed copy, it's in the `sgm` package (see pyproject.toml).
|
||||
"""
|
||||
this_dir = os.path.dirname(__file__)
|
||||
candidates = (
|
||||
os.path.join(this_dir, "configs"),
|
||||
os.path.join(this_dir, "..", "configs"),
|
||||
)
|
||||
for candidate in candidates:
|
||||
candidate = os.path.abspath(candidate)
|
||||
if os.path.isdir(candidate):
|
||||
return candidate
|
||||
raise FileNotFoundError(f"Could not find SGM configs in {candidates}")
|
||||
|
||||
Reference in New Issue
Block a user