Skip to content

Commit 701feab

Browse files
authored
Fix: --sd_model in "Promts from file or textbox" script is not working
Fix for bug report AUTOMATIC1111#8079
1 parent 5ef669d commit 701feab

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

scripts/prompts_from_file.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@
55
import modules.scripts as scripts
66
import gradio as gr
77

8-
from modules import sd_samplers, errors
8+
from modules import sd_samplers, errors, sd_models
99
from modules.processing import Processed, process_images
1010
from modules.shared import state
1111

1212

13+
def process_model_tag(tag):
14+
info = sd_models.get_closet_checkpoint_match(tag)
15+
assert info is not None, f'Unknown checkpoint: {tag}'
16+
return info.name
17+
18+
1319
def process_string_tag(tag):
1420
return tag
1521

@@ -27,7 +33,7 @@ def process_boolean_tag(tag):
2733

2834

2935
prompt_tags = {
30-
"sd_model": None,
36+
"sd_model": process_model_tag,
3137
"outpath_samples": process_string_tag,
3238
"outpath_grids": process_string_tag,
3339
"prompt_for_display": process_string_tag,
@@ -156,7 +162,10 @@ def run(self, p, checkbox_iterate, checkbox_iterate_batch, prompt_txt: str):
156162

157163
copy_p = copy.copy(p)
158164
for k, v in args.items():
159-
setattr(copy_p, k, v)
165+
if k == "sd_model":
166+
copy_p.override_settings['sd_model_checkpoint'] = v
167+
else:
168+
setattr(copy_p, k, v)
160169

161170
proc = process_images(copy_p)
162171
images += proc.images

0 commit comments

Comments
 (0)