Compare commits

...

8 Commits

Author SHA1 Message Date
w-e-w 9bc3332d86 make process_boolean_tag case insensitive 2024-08-06 19:25:30 +09:00
w-e-w f8395750f4 add Usage Syntax to Prompts from file or textbox 2024-08-06 19:25:30 +09:00
AUTOMATIC1111 48239090f1 Merge branch 'master' into dev 2024-07-27 15:50:26 +03:00
AUTOMATIC1111 82a973c043 changelog 2024-07-27 15:49:39 +03:00
AUTOMATIC1111 1d7e9eca09 Merge pull request #16275 from AUTOMATIC1111/fix-image-upscale-on-cpu
fix image upscale on cpu
2024-07-27 15:48:22 +03:00
AUTOMATIC1111 850e14923e Merge pull request #16275 from AUTOMATIC1111/fix-image-upscale-on-cpu
fix image upscale on cpu
2024-07-27 15:47:49 +03:00
w-e-w 8e0881d9ab fix image upscale on cpu
for some reason upscale using cpu will fail with
RuntimeError: Inplace update to inference tensor outside InferenceMode
switch from no_grad to inference_mode seems to have fixed it
2024-07-27 21:28:10 +09:00
AUTOMATIC1111 834297b13d Merge branch 'master' into dev 2024-07-27 07:09:08 +03:00
3 changed files with 37 additions and 3 deletions
+6
View File
@@ -1,3 +1,9 @@
## 1.10.1
### Bug Fixes:
* fix image upscale on cpu ([#16275](https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/16275))
## 1.10.0 ## 1.10.0
### Features: ### Features:
+1 -1
View File
@@ -41,7 +41,7 @@ def upscale_pil_patch(model, img: Image.Image) -> Image.Image:
""" """
param = torch_utils.get_param(model) param = torch_utils.get_param(model)
with torch.no_grad(): with torch.inference_mode():
tensor = pil_image_to_torch_bgr(img).unsqueeze(0) # add batch dimension tensor = pil_image_to_torch_bgr(img).unsqueeze(0) # add batch dimension
tensor = tensor.to(device=param.device, dtype=param.dtype) tensor = tensor.to(device=param.device, dtype=param.dtype)
with devices.without_autocast(): with devices.without_autocast():
+30 -2
View File
@@ -11,25 +11,30 @@ from modules.shared import state
def process_model_tag(tag): def process_model_tag(tag):
"""\"mode-name\""""
info = sd_models.get_closet_checkpoint_match(tag) info = sd_models.get_closet_checkpoint_match(tag)
assert info is not None, f'Unknown checkpoint: {tag}' assert info is not None, f'Unknown checkpoint: {tag}'
return info.name return info.name
def process_string_tag(tag): def process_string_tag(tag):
"""\"str\""""
return tag return tag
def process_int_tag(tag): def process_int_tag(tag):
"""int-number"""
return int(tag) return int(tag)
def process_float_tag(tag): def process_float_tag(tag):
"""float-number"""
return float(tag) return float(tag)
def process_boolean_tag(tag): def process_boolean_tag(tag):
return True if (tag == "true") else False """true|false"""
return True if (tag.lower() == "true") else False
prompt_tags = { prompt_tags = {
@@ -60,6 +65,27 @@ prompt_tags = {
} }
def doc_md():
md = '<details><summary>Usage Syntax</summary><p>\n\n'
for key, func in prompt_tags.items():
md += f'`--{key}` `{func.__doc__}`\n'
md += '''
<details><summary>Example</summary><p>
```shell
--prompt "photo of sunset"
--prompt "photo of sunset" --negative_prompt "orange, pink, red, sea, water, lake" --width 1024 --height 768 --sampler_name "DPM++ 2M Karras" --steps 10 --batch_size 2 --cfg_scale 3 --seed 9
--prompt "photo of winter mountains" --steps 7 --sampler_name "DDIM"
--prompt "photo of winter mountains" --width 1024
```
</p></details>
'''
md += '</p></details>'
return md
def cmdargs(line): def cmdargs(line):
args = shlex.split(line) args = shlex.split(line)
pos = 0 pos = 0
@@ -84,7 +110,6 @@ def cmdargs(line):
res[tag] = prompt res[tag] = prompt
continue continue
func = prompt_tags.get(tag, None) func = prompt_tags.get(tag, None)
assert func, f'unknown commandline option: {arg}' assert func, f'unknown commandline option: {arg}'
@@ -125,6 +150,9 @@ class Script(scripts.Script):
# We don't shrink back to 1, because that causes the control to ignore [enter], and it may # We don't shrink back to 1, because that causes the control to ignore [enter], and it may
# be unclear to the user that shift-enter is needed. # be unclear to the user that shift-enter is needed.
prompt_txt.change(lambda tb: gr.update(lines=7) if ("\n" in tb) else gr.update(lines=2), inputs=[prompt_txt], outputs=[prompt_txt], show_progress=False) prompt_txt.change(lambda tb: gr.update(lines=7) if ("\n" in tb) else gr.update(lines=2), inputs=[prompt_txt], outputs=[prompt_txt], show_progress=False)
gr.Markdown(doc_md())
return [checkbox_iterate, checkbox_iterate_batch, prompt_position, prompt_txt] return [checkbox_iterate, checkbox_iterate_batch, prompt_position, prompt_txt]
def run(self, p, checkbox_iterate, checkbox_iterate_batch, prompt_position, prompt_txt: str): def run(self, p, checkbox_iterate, checkbox_iterate_batch, prompt_position, prompt_txt: str):