mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-04-23 03:00:31 -04:00
further improvements to initial load
- Migration process will not crash if duplicate model files are found, one in legacy location and the other in new location. The model in the legacy location will be deleted in this case. - Added a hint to stable-diffusion-2.1 telling people it will work best with 768 pixel images. - Added the anything-4.0 model.
This commit is contained in:
@@ -753,16 +753,20 @@ class ModelManager(object):
|
||||
|
||||
print('** Legacy version <= 2.2.5 model directory layout detected. Reorganizing.')
|
||||
print('** This is a quick one-time operation.')
|
||||
from shutil import move
|
||||
from shutil import move, rmtree
|
||||
|
||||
# transformer files get moved into the hub directory
|
||||
hub = models_dir / 'hub'
|
||||
os.makedirs(hub, exist_ok=True)
|
||||
for model in legacy_locations:
|
||||
source = models_dir /model
|
||||
source = models_dir / model
|
||||
dest = hub / model.stem
|
||||
print(f'** {source} => {dest}')
|
||||
if source.exists():
|
||||
print(f'DEBUG: Moving {models_dir / model} into hub')
|
||||
move(models_dir / model, hub)
|
||||
if dest.exists():
|
||||
rmtree(source)
|
||||
else:
|
||||
move(source, dest)
|
||||
|
||||
# anything else gets moved into the diffusers directory
|
||||
diffusers = models_dir / 'diffusers'
|
||||
@@ -773,7 +777,12 @@ class ModelManager(object):
|
||||
if full_path.is_relative_to(hub) or full_path.is_relative_to(diffusers):
|
||||
continue
|
||||
if Path(dir).match('models--*--*'):
|
||||
move(full_path,diffusers)
|
||||
dest = diffusers / dir
|
||||
print(f'** {full_path} => {dest}')
|
||||
if dest.exists():
|
||||
rmtree(full_path)
|
||||
else:
|
||||
move(full_path,dest)
|
||||
|
||||
# now clean up by removing any empty directories
|
||||
empty = [root for root, dirs, files, in os.walk(models_dir) if not len(dirs) and not len(files)]
|
||||
|
||||
Reference in New Issue
Block a user