Merge pull request #1 from Bowen-Z/add_lora_loading

Added capability to load Lora models
This commit is contained in:
Bowen 2023-02-20 14:30:21 +00:00 committed by GitHub
commit 9b18b83448
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -328,6 +328,7 @@
"!mkdir -p \"{model_storage_dir}/vae\"\n",
"!mkdir -p \"{repo_storage_dir}/stable-diffusion-webui/models/hypernetworks\"\n",
"!mkdir -p \"{repo_storage_dir}/stable-diffusion-webui/models/VAE\"\n",
"!mkdir -p \"{repo_storage_dir}/stable-diffusion-webui/models/Lora\"\n",
"!mkdir -p \"{repo_storage_dir}/stable-diffusion-webui/log/images\"\n",
"\n",
"!echo -e \"\\n===================================\\nDone! If you're seeing this the process has exited successfully.\\n\""
@ -1003,6 +1004,7 @@
"webui_sd_model_path = Path(webui_root_model_path, 'Stable-diffusion')\n",
"webui_hypernetwork_path = Path(webui_root_model_path, 'hypernetworks')\n",
"webui_vae_path = Path(webui_root_model_path, 'VAE')\n",
"webui_lora_model_path = Path(webui_root_model_path, 'Lora')\n",
"\n",
"def delete_broken_symlinks(dir):\n",
" deleted = False\n",
@ -1027,6 +1029,7 @@
"delete_broken_symlinks(webui_sd_model_path)\n",
"delete_broken_symlinks(webui_hypernetwork_path)\n",
"delete_broken_symlinks(webui_vae_path)\n",
"delete_broken_symlinks(webui_lora_model_path)\n",
"\n",
"def link_ckpts(source_path):\n",
" # Link .ckpt and .safetensor/.st files (recursive)\n",
@ -1063,6 +1066,15 @@
"else:\n",
" print('VAE storage directory not found:', vae_source_path)\n",
"\n",
"# Link Lora\n",
"print('\\nLinking Loras...')\n",
"lora_source_path = Path(model_storage_dir, 'Lora')\n",
"if lora_source_path.is_dir():\n",
" for file in lora_source_path.iterdir():\n",
" create_symlink(lora_source_path / file, webui_lora_model_path)\n",
"else:\n",
" print('Lora storage directory not found:', lora_source_path)\n",
"\n",
"# Link the NovelAI files for each of the NovelAI models\n",
"print('\\nLinking NovelAI files for each of the NovelAI models...')\n",
"for model in model_storage_dir.glob('novelai-*.ckpt'):\n",