Skip to content

Commit 2d0bcdb

Browse files
authored
Merge pull request #78 from kohya-ss/dev
merge dev to main
2 parents eb26730 + fe653ba commit 2d0bcdb

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ __Stable Diffusion web UI now seems to support LoRA trained by ``sd-scripts``.__
88

99
Note: Currently the models models for SD 2.x does not seem to be supported in Web UI. The models trained by the scripts 0.4.0 seem to be supported.
1010

11+
- 30 Jan. 2023, 2023/1/30
12+
- Fix to allow folder names containing commas in ``Extra paths to scan for LoRA models``. Enclose in ``"``. Thanks to shirayu!
13+
- ``Extra paths to scan for LoRA models`` でのモデルディレクトリの指定時にカンマを含むフォルダ名が使用できるようになりました。``"`` で囲んでください。shirayu氏に感謝します。
1114
- 29 Jan. 2023, 2023/1/29
1215
- Support multiple LoRA model directories. You can set a comma-separated list in ``Extra paths to scan for LoRA models`` at ``Settings`` tab. Thanks to space-nuko!
1316

preload.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44

55
def preload(parser):
6-
parser.add_argument("--addnet-max-model-count", type=int, help="The maximum number of additinal network model can be used.", default=5)
6+
parser.add_argument("--addnet-max-model-count", type=int, help="The maximum number of additional network model can be used.", default=5)

scripts/additional_networks.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,17 @@ def apply_weight_tenc(p, x, xs, i):
156156
update_script_args(p, True, 0)
157157
update_script_args(p, x, 5 + 4 * i) # enabled, separate_weights, (module, model, weight_unet, {weight_tenc}), ...
158158

159+
def split_path_list(path_list: str) -> list[str]:
160+
import csv
161+
from io import StringIO
162+
163+
pl = []
164+
with StringIO() as f:
165+
f.write(path_list)
166+
f.seek(0)
167+
for r in csv.reader(f):
168+
pl += r
169+
return pl
159170

160171
def format_lora_model(p, opt, x):
161172
model = find_closest_lora_model_name(x)
@@ -169,7 +180,7 @@ def format_lora_model(p, opt, x):
169180
if not metadata:
170181
return value
171182

172-
metadata_names = shared.opts.data.get("additional_networks_xy_grid_model_metadata", "").split(",")
183+
metadata_names = split_path_list(shared.opts.data.get("additional_networks_xy_grid_model_metadata", ""))
173184
if not metadata_names:
174185
return value
175186

@@ -384,7 +395,7 @@ def find_closest_lora_model_name(search: str):
384395
def update_lora_models():
385396
global lora_models, lora_model_names, legacy_model_names
386397
paths = [lora_models_dir]
387-
extra_lora_paths = shared.opts.data.get("additional_networks_extra_lora_path", "").split(",")
398+
extra_lora_paths = split_path_list(shared.opts.data.get("additional_networks_extra_lora_path", ""))
388399
for path in extra_lora_paths:
389400
if os.path.isdir(path):
390401
paths.append(path)
@@ -637,7 +648,7 @@ def update_metadata(module, model):
637648
def on_ui_settings():
638649
section = ('additional_networks', "Additional Networks")
639650
shared.opts.add_option("additional_networks_extra_lora_path", shared.OptionInfo(
640-
"", "Extra paths to scan for LoRA models, comma-separated", section=section))
651+
"", """Extra paths to scan for LoRA models, comma-separated. Paths containing commas must be enclosed in double quotes. In the path, " (one quote) must be replaced by "" (two quotes).""", section=section))
641652
shared.opts.add_option("additional_networks_sort_models_by", shared.OptionInfo(
642653
"name", "Sort LoRA models by", gr.Radio, {"choices": ["name", "date", "path name", "rating", "has user metadata"]}, section=section))
643654
shared.opts.add_option("additional_networks_model_name_filter", shared.OptionInfo("", "LoRA model name filter", section=section))

0 commit comments

Comments
 (0)