mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Migrate legacy models (pre-2.3.0) to 🤗 cache directory if exists
This commit is contained in:
parent
2282e681f7
commit
aa4e8d8cf3
@ -758,7 +758,11 @@ class ModelManager(object):
|
||||
from shutil import move, rmtree
|
||||
|
||||
# transformer files get moved into the hub directory
|
||||
if cls._is_huggingface_hub_directory_present():
|
||||
hub = global_cache_dir() / 'hub'
|
||||
else:
|
||||
hub = models_dir / 'hub'
|
||||
|
||||
os.makedirs(hub, exist_ok=True)
|
||||
for model in legacy_locations:
|
||||
source = models_dir / model
|
||||
@ -771,7 +775,11 @@ class ModelManager(object):
|
||||
move(source, dest)
|
||||
|
||||
# anything else gets moved into the diffusers directory
|
||||
if cls._is_huggingface_hub_directory_present():
|
||||
diffusers = global_cache_dir() / 'diffusers'
|
||||
else:
|
||||
diffusers = models_dir / 'diffusers'
|
||||
|
||||
os.makedirs(diffusers, exist_ok=True)
|
||||
for root, dirs, _ in os.walk(models_dir, topdown=False):
|
||||
for dir in dirs:
|
||||
@ -962,3 +970,7 @@ class ModelManager(object):
|
||||
print(f'** Could not load VAE {name_or_path}: {str(deferred_error)}')
|
||||
|
||||
return vae
|
||||
|
||||
@staticmethod
|
||||
def _is_huggingface_hub_directory_present() -> bool:
|
||||
return os.getenv('HF_HOME') is not None or os.getenv('XDG_CACHE_HOME') is not None
|
||||
|
Loading…
Reference in New Issue
Block a user