add --lora-dir commandline option

This commit is contained in:
AUTOMATIC 2023-01-21 23:11:37 +03:00
parent 4a8fe09652
commit 500d9a32c7
3 changed files with 11 additions and 6 deletions

View File

@ -177,12 +177,12 @@ def lora_Conv2d_forward(self, input):
def list_available_loras():
available_loras.clear()
os.makedirs(lora_dir, exist_ok=True)
os.makedirs(shared.cmd_opts.lora_dir, exist_ok=True)
candidates = \
glob.glob(os.path.join(lora_dir, '**/*.pt'), recursive=True) + \
glob.glob(os.path.join(lora_dir, '**/*.safetensors'), recursive=True) + \
glob.glob(os.path.join(lora_dir, '**/*.ckpt'), recursive=True)
glob.glob(os.path.join(shared.cmd_opts.lora_dir, '**/*.pt'), recursive=True) + \
glob.glob(os.path.join(shared.cmd_opts.lora_dir, '**/*.safetensors'), recursive=True) + \
glob.glob(os.path.join(shared.cmd_opts.lora_dir, '**/*.ckpt'), recursive=True)
for filename in sorted(candidates):
if os.path.isdir(filename):
@ -193,7 +193,6 @@ def list_available_loras():
available_loras[name] = LoraOnDisk(name, filename)
lora_dir = os.path.join(shared.models_path, "Lora")
available_loras = {}
loaded_loras = []

View File

@ -0,0 +1,6 @@
import os
from modules import paths
def preload(parser):
parser.add_argument("--lora-dir", type=str, help="Path to directory with Lora networks.", default=os.path.join(paths.models_path, 'Lora'))

View File

@ -31,5 +31,5 @@ class ExtraNetworksPageLora(ui_extra_networks.ExtraNetworksPage):
}
def allowed_directories_for_previews(self):
return [lora.lora_dir]
return [shared.cmd_opts.lora_dir]