Merge pull request #75 from Bowen-Z/master

Added code to load Lora models
This commit is contained in:
Cyberes 2023-02-20 11:23:43 -07:00 committed by GitHub
commit e96e81d956
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 \"{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/hypernetworks\"\n",
"!mkdir -p \"{repo_storage_dir}/stable-diffusion-webui/models/VAE\"\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", "!mkdir -p \"{repo_storage_dir}/stable-diffusion-webui/log/images\"\n",
"\n", "\n",
"!echo -e \"\\n===================================\\nDone! If you're seeing this the process has exited successfully.\\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_sd_model_path = Path(webui_root_model_path, 'Stable-diffusion')\n",
"webui_hypernetwork_path = Path(webui_root_model_path, 'hypernetworks')\n", "webui_hypernetwork_path = Path(webui_root_model_path, 'hypernetworks')\n",
"webui_vae_path = Path(webui_root_model_path, 'VAE')\n", "webui_vae_path = Path(webui_root_model_path, 'VAE')\n",
"webui_lora_model_path = Path(webui_root_model_path, 'Lora')\n",
"\n", "\n",
"def delete_broken_symlinks(dir):\n", "def delete_broken_symlinks(dir):\n",
" deleted = False\n", " deleted = False\n",
@ -1027,6 +1029,7 @@
"delete_broken_symlinks(webui_sd_model_path)\n", "delete_broken_symlinks(webui_sd_model_path)\n",
"delete_broken_symlinks(webui_hypernetwork_path)\n", "delete_broken_symlinks(webui_hypernetwork_path)\n",
"delete_broken_symlinks(webui_vae_path)\n", "delete_broken_symlinks(webui_vae_path)\n",
"delete_broken_symlinks(webui_lora_model_path)\n",
"\n", "\n",
"def link_ckpts(source_path):\n", "def link_ckpts(source_path):\n",
" # Link .ckpt and .safetensor/.st files (recursive)\n", " # Link .ckpt and .safetensor/.st files (recursive)\n",
@ -1063,6 +1066,15 @@
"else:\n", "else:\n",
" print('VAE storage directory not found:', vae_source_path)\n", " print('VAE storage directory not found:', vae_source_path)\n",
"\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", "# Link the NovelAI files for each of the NovelAI models\n",
"print('\\nLinking 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", "for model in model_storage_dir.glob('novelai-*.ckpt'):\n",