further improvements to initial load (#2330)

- 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:
Lincoln Stein 2023-01-17 23:21:14 -05:00 committed by GitHub
commit e4ea98c277
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 52 additions and 31 deletions

View File

@ -1,18 +1,32 @@
stable-diffusion-2.1-768:
description: Stable Diffusion version 2.1 diffusers model, trained on 768x768 images (5.21 GB)
repo_id: stabilityai/stable-diffusion-2-1
format: diffusers
recommended: True
stable-diffusion-2.1-base:
description: Stable Diffusion version 2.1 diffusers base model, trained on 512x512 images (5.21 GB)
repo_id: stabilityai/stable-diffusion-2-1-base
format: diffusers
recommended: False
stable-diffusion-1.5:
description: Stable Diffusion version 1.5 weight file (4.27 GB)
repo_id: runwayml/stable-diffusion-v1-5
format: diffusers
recommended: True
default: True
vae:
repo_id: stabilityai/sd-vae-ft-mse
default: True
stable-diffusion-2.1:
description: Stable Diffusion version 2.1 diffusers model (5.21 GB)
repo_id: stabilityai/stable-diffusion-2-1
stable-diffusion-1.4:
description: The original Stable Diffusion version 1.4 weight file (4.27 GB)
repo_id: CompVis/stable-diffusion-v1-4
recommended: False
format: diffusers
recommended: True
vae:
repo_id: stabilityai/sd-vae-ft-mse
width: 512
height: 512
inpainting-1.5:
description: RunwayML SD 1.5 model optimized for inpainting (4.27 GB)
description: RunwayML SD 1.5 model optimized for inpainting (ckpt version) (4.27 GB)
repo_id: runwayml/stable-diffusion-inpainting
config: v1-inpainting-inference.yaml
file: sd-v1-5-inpainting.ckpt
@ -23,19 +37,13 @@ inpainting-1.5:
recommended: True
width: 512
height: 512
stable-diffusion-1.4:
description: The original Stable Diffusion version 1.4 weight file (4.27 GB)
repo_id: CompVis/stable-diffusion-v1-4
recommended: False
format: diffusers
vae:
repo_id: stabilityai/sd-vae-ft-mse
waifu-diffusion-1.4:
description: Waifu diffusion 1.4
description: Latest waifu diffusion 1.4 (diffusers version)
format: diffusers
repo_id: hakurei/waifu-diffusion
recommended: True
waifu-diffusion-1.3:
description: Stable Diffusion 1.4 fine tuned on anime-styled images (4.27 GB)
description: Stable Diffusion 1.4 fine tuned on anime-styled images (ckpt version) (4.27 GB)
repo_id: hakurei/waifu-diffusion-v1-3
config: v1-inference.yaml
file: model-epoch09-float32.ckpt
@ -53,8 +61,8 @@ trinart-2.0:
recommended: False
vae:
repo_id: stabilityai/sd-vae-ft-mse
trinart_characters-2.0:
description: An SD model finetuned with 19.2M anime/manga style images (4.27 GB)
trinart_characters-2_0:
description: An SD model finetuned with 19.2M anime/manga style images (ckpt version) (4.27 GB)
repo_id: naclbit/trinart_derrida_characters_v2_stable_diffusion
config: v1-inference.yaml
file: derrida_final.ckpt
@ -65,6 +73,11 @@ trinart_characters-2.0:
recommended: False
width: 512
height: 512
anything-4.0:
description: High-quality, highly detailed anime style images with just a few prompts
format: diffusers
repo_id: andite/anything-v4.0
recommended: False
papercut-1.0:
description: SD 1.5 fine-tuned for papercut art (use "PaperCut" in your prompts) (2.13 GB)
repo_id: Fictiverse/Stable_Diffusion_PaperCut_Model
@ -72,8 +85,6 @@ papercut-1.0:
vae:
repo_id: stabilityai/sd-vae-ft-mse
recommended: False
width: 512
height: 512
voxel_art-1.0:
description: Stable Diffusion trained on voxel art (use "VoxelArt" in your prompts) (4.27 GB)
repo_id: Fictiverse/Stable_Diffusion_VoxelArt_Model

View File

@ -613,8 +613,6 @@ def import_diffuser_model(path_or_repo:str, gen, opt, completer)->str:
description = model_description):
print('** model failed to import')
return None
if input('Make this the default model? [n] ').startswith(('y','Y')):
manager.set_default_model(model_name)
return model_name
def import_ckpt_model(path_or_url:str, gen, opt, completer)->str:
@ -647,8 +645,6 @@ def import_ckpt_model(path_or_url:str, gen, opt, completer)->str:
print('** model failed to import')
return None
if input('Make this the default model? [n] ').startswith(('y','Y')):
manager.set_model_default(model_name)
return model_name
def _verify_load(model_name:str, gen)->bool:
@ -726,6 +722,9 @@ def del_config(model_name:str, gen, opt, completer):
if model_name == current_model:
print("** Can't delete active model. !switch to another model first. **")
return
if model_name not in gen.model_manager.config:
print(f"** Unknown model {model_name}")
return
gen.model_manager.del_model(model_name)
gen.model_manager.commit(opt.conf)
print(f'** {model_name} deleted')

View File

@ -230,6 +230,9 @@ class ModelManager(object):
Delete the named model.
'''
omega = self.config
if model_name not in omega:
print(f'** Unknown model {model_name}')
return
del omega[model_name]
if model_name in self.stack:
self.stack.remove(model_name)
@ -253,9 +256,8 @@ class ModelManager(object):
assert (clobber or model_name not in omega), f'attempt to overwrite existing model definition "{model_name}"'
if model_name not in omega:
omega[model_name] = dict()
OmegaConf.update(omega,model_name,model_attributes,merge=False)
omega[model_name] = model_attributes
if 'weights' in omega[model_name]:
omega[model_name]['weights'].replace('\\','/')
@ -753,16 +755,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'** 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 +779,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)]