mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-04-25 06:19:00 +08:00
fix formating
This commit is contained in:
parent
5968b875cf
commit
56dc761ad3
@ -12,17 +12,21 @@ from modules.ui_common import plaintext_to_html
|
|||||||
import gradio as gr
|
import gradio as gr
|
||||||
import safetensors.torch
|
import safetensors.torch
|
||||||
|
|
||||||
|
|
||||||
def pnginfo_format_string(plain_text):
|
def pnginfo_format_string(plain_text):
|
||||||
content = "<br>\n".join(html.escape(x) for x in str(plain_text).split('\n'))
|
content = "<br>\n".join(html.escape(x) for x in str(plain_text).split('\n'))
|
||||||
return content
|
return content
|
||||||
|
|
||||||
|
|
||||||
def pnginfo_format_setting(name, value):
|
def pnginfo_format_setting(name, value):
|
||||||
cls_name = 'geninfo-setting-string' if value.startswith('"') else 'geninfo-setting-value'
|
cls_name = 'geninfo-setting-string' if value.startswith('"') else 'geninfo-setting-value'
|
||||||
return f"<span class='geninfo-setting-name'>{html.escape(name)}:</span> <span class='{cls_name}' onclick='uiCopyElementText(this)'>{html.escape(value)}</span>"
|
return f"<span class='geninfo-setting-name'>{html.escape(name)}:</span> <span class='{cls_name}' onclick='uiCopyElementText(this)'>{html.escape(value)}</span>"
|
||||||
|
|
||||||
|
|
||||||
def pnginfo_format_quicklink(name):
|
def pnginfo_format_quicklink(name):
|
||||||
return f"<span class='geninfo-quick-link' onclick='uiCopyPngInfo(this, \"{name}\")'>[{html.escape(name)}]</span>"
|
return f"<span class='geninfo-quick-link' onclick='uiCopyPngInfo(this, \"{name}\")'>[{html.escape(name)}]</span>"
|
||||||
|
|
||||||
|
|
||||||
def run_pnginfo(image):
|
def run_pnginfo(image):
|
||||||
if image is None:
|
if image is None:
|
||||||
return '', '', ''
|
return '', '', ''
|
||||||
@ -248,8 +252,8 @@ def run_modelmerger(id_task, primary_model_name, secondary_model_name, tertiary_
|
|||||||
if a.shape[1] == 4 and b.shape[1] == 8:
|
if a.shape[1] == 4 and b.shape[1] == 8:
|
||||||
raise RuntimeError("When merging instruct-pix2pix model with a normal one, A must be the instruct-pix2pix model.")
|
raise RuntimeError("When merging instruct-pix2pix model with a normal one, A must be the instruct-pix2pix model.")
|
||||||
|
|
||||||
if a.shape[1] == 8 and b.shape[1] == 4:#If we have an Instruct-Pix2Pix model...
|
if a.shape[1] == 8 and b.shape[1] == 4: # If we have an Instruct-Pix2Pix model...
|
||||||
theta_0[key][:, 0:4, :, :] = theta_func2(a[:, 0:4, :, :], b, multiplier)#Merge only the vectors the models have in common. Otherwise we get an error due to dimension mismatch.
|
theta_0[key][:, 0:4, :, :] = theta_func2(a[:, 0:4, :, :], b, multiplier) # Merge only the vectors the models have in common. Otherwise we get an error due to dimension mismatch.
|
||||||
result_is_instruct_pix2pix_model = True
|
result_is_instruct_pix2pix_model = True
|
||||||
else:
|
else:
|
||||||
assert a.shape[1] == 9 and b.shape[1] == 4, f"Bad dimensions for merged layer {key}: A={a.shape}, B={b.shape}"
|
assert a.shape[1] == 9 and b.shape[1] == 4, f"Bad dimensions for merged layer {key}: A={a.shape}, B={b.shape}"
|
||||||
@ -358,7 +362,7 @@ def run_modelmerger(id_task, primary_model_name, secondary_model_name, tertiary_
|
|||||||
|
|
||||||
_, extension = os.path.splitext(output_modelname)
|
_, extension = os.path.splitext(output_modelname)
|
||||||
if extension.lower() == ".safetensors":
|
if extension.lower() == ".safetensors":
|
||||||
safetensors.torch.save_file(theta_0, output_modelname, metadata=metadata if len(metadata)>0 else None)
|
safetensors.torch.save_file(theta_0, output_modelname, metadata=metadata if len(metadata) > 0 else None)
|
||||||
else:
|
else:
|
||||||
torch.save(theta_0, output_modelname)
|
torch.save(theta_0, output_modelname)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user