aboutsummaryrefslogtreecommitdiff
path: root/modules/generation_parameters_copypaste.py
diff options
context:
space:
mode:
authoryfszzx <yfszzx@gmail.com>2022-10-23 16:17:37 +0800
committeryfszzx <yfszzx@gmail.com>2022-10-23 16:17:37 +0800
commit6a9ea40d7f64139f23d634efd7c2fb2c743a546f (patch)
tree8d420a5590c09e1d4c005a709166479856e70580 /modules/generation_parameters_copypaste.py
parent67b78f0ea6f196bfdca49932da062631bb40d0b1 (diff)
parent1ef32c8b8fa3e16a1e7b287eb19d4fc943d1f2a5 (diff)
Move browser and Inspiration into extension
Diffstat (limited to 'modules/generation_parameters_copypaste.py')
-rw-r--r--modules/generation_parameters_copypaste.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py
index 0f041449..f73647da 100644
--- a/modules/generation_parameters_copypaste.py
+++ b/modules/generation_parameters_copypaste.py
@@ -4,13 +4,22 @@ import gradio as gr
from modules.shared import script_path
from modules import shared
-re_param_code = r"\s*([\w ]+):\s*([^,]+)(?:,|$)"
+re_param_code = r'\s*([\w ]+):\s*("(?:\\|\"|[^\"])+"|[^,]*)(?:,|$)'
re_param = re.compile(re_param_code)
re_params = re.compile(r"^(?:" + re_param_code + "){3,}$")
re_imagesize = re.compile(r"^(\d+)x(\d+)$")
type_of_gr_update = type(gr.update())
+def quote(text):
+ if ',' not in str(text):
+ return text
+
+ text = str(text)
+ text = text.replace('\\', '\\\\')
+ text = text.replace('"', '\\"')
+ return f'"{text}"'
+
def parse_generation_parameters(x: str):
"""parses generation parameters string, the one you see in text field under the picture in UI:
```
@@ -83,7 +92,12 @@ def connect_paste(button, paste_fields, input_comp, js=None):
else:
try:
valtype = type(output.value)
- val = valtype(v)
+
+ if valtype == bool and v == "False":
+ val = False
+ else:
+ val = valtype(v)
+
res.append(gr.update(value=val))
except Exception:
res.append(gr.update())