Skip to content

Commit

Permalink
[SD] Fix custom model path for WebUI
Browse files Browse the repository at this point in the history
-- This commit fixes custom model path for WebUI.

Signed-off-by: Abhishek Varma <abhishek@nod-labs.com>
  • Loading branch information
Abhishek Varma committed Mar 29, 2023
1 parent d6f740b commit b9c5102
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion apps/stable_diffusion/web/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
# Clear all gradio tmp images from the last session
clear_gradio_tmp_imgs_folder()
# Create the custom model folder if it doesn't already exist
get_custom_model_path().mkdir(parents=True, exist_ok=True)
dir = ["models", "vae", "lora"]
for root in dir:
get_custom_model_path(root).mkdir(parents=True, exist_ok=True)

if args.clear_all:
clear_all()
Expand Down
14 changes: 10 additions & 4 deletions apps/stable_diffusion/web/ui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,20 @@ def resource_path(relative_path):


def get_custom_model_path(model="models"):
prefix = Path(args.ckpt_dir) if args.ckpt_dir else Path(Path.cwd())
# If `--ckpt_dir` is provided it'd override the heirarchical folder
# structure in WebUI :-
# model
# |___lora
# |___vae
if args.ckpt_dir:
return Path(args.ckpt_dir)
match model:
case "models":
return Path(prefix, "models")
return Path(Path.cwd(), "models")
case "vae":
return Path(prefix, "models/vae")
return Path(Path.cwd(), "models/vae")
case "lora":
return Path(prefix, "models/lora")
return Path(Path.cwd(), "models/lora")
case _:
return ""

Expand Down

0 comments on commit b9c5102

Please sign in to comment.