add --lora-dir commandline option
This commit is contained in:
parent
4a8fe09652
commit
500d9a32c7
3 changed files with 11 additions and 6 deletions
|
@ -177,12 +177,12 @@ def lora_Conv2d_forward(self, input):
|
||||||
def list_available_loras():
|
def list_available_loras():
|
||||||
available_loras.clear()
|
available_loras.clear()
|
||||||
|
|
||||||
os.makedirs(lora_dir, exist_ok=True)
|
os.makedirs(shared.cmd_opts.lora_dir, exist_ok=True)
|
||||||
|
|
||||||
candidates = \
|
candidates = \
|
||||||
glob.glob(os.path.join(lora_dir, '**/*.pt'), recursive=True) + \
|
glob.glob(os.path.join(shared.cmd_opts.lora_dir, '**/*.pt'), recursive=True) + \
|
||||||
glob.glob(os.path.join(lora_dir, '**/*.safetensors'), recursive=True) + \
|
glob.glob(os.path.join(shared.cmd_opts.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, '**/*.ckpt'), recursive=True)
|
||||||
|
|
||||||
for filename in sorted(candidates):
|
for filename in sorted(candidates):
|
||||||
if os.path.isdir(filename):
|
if os.path.isdir(filename):
|
||||||
|
@ -193,7 +193,6 @@ def list_available_loras():
|
||||||
available_loras[name] = LoraOnDisk(name, filename)
|
available_loras[name] = LoraOnDisk(name, filename)
|
||||||
|
|
||||||
|
|
||||||
lora_dir = os.path.join(shared.models_path, "Lora")
|
|
||||||
available_loras = {}
|
available_loras = {}
|
||||||
loaded_loras = []
|
loaded_loras = []
|
||||||
|
|
||||||
|
|
6
extensions-builtin/Lora/preload.py
Normal file
6
extensions-builtin/Lora/preload.py
Normal 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'))
|
|
@ -31,5 +31,5 @@ class ExtraNetworksPageLora(ui_extra_networks.ExtraNetworksPage):
|
||||||
}
|
}
|
||||||
|
|
||||||
def allowed_directories_for_previews(self):
|
def allowed_directories_for_previews(self):
|
||||||
return [lora.lora_dir]
|
return [shared.cmd_opts.lora_dir]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue