aboutsummaryrefslogtreecommitdiffstats
path: root/modules/generation_parameters_copypaste.py
diff options
context:
space:
mode:
authorAUTOMATIC <16777216c@gmail.com>2022-10-29 05:42:34 +0000
committerAUTOMATIC <16777216c@gmail.com>2022-10-29 05:42:34 +0000
commit3c207ca68483b3406faf519bde2743b578dac222 (patch)
tree642808efe021d5864b5c20644fe7296a4f256dd5 /modules/generation_parameters_copypaste.py
parent45ca67f35a9dd4c05fae295e54b38bbbd9ae5a84 (diff)
downloadstable-diffusion-webui-gfx803-3c207ca68483b3406faf519bde2743b578dac222.tar.gz
stable-diffusion-webui-gfx803-3c207ca68483b3406faf519bde2743b578dac222.tar.bz2
stable-diffusion-webui-gfx803-3c207ca68483b3406faf519bde2743b578dac222.zip
add needed imports fr new code in copypaste.py
Diffstat (limited to 'modules/generation_parameters_copypaste.py')
-rw-r--r--modules/generation_parameters_copypaste.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/generation_parameters_copypaste.py b/modules/generation_parameters_copypaste.py
index 2b80737a..224a17ea 100644
--- a/modules/generation_parameters_copypaste.py
+++ b/modules/generation_parameters_copypaste.py
@@ -1,3 +1,5 @@
+import base64
+import io
import os
import re
import gradio as gr
@@ -14,6 +16,7 @@ type_of_gr_update = type(gr.update())
paste_fields = {}
bind_list = []
+
def quote(text):
if ',' not in str(text):
return text
@@ -23,6 +26,7 @@ def quote(text):
text = text.replace('"', '\\"')
return f'"{text}"'
+
def image_from_url_text(filedata):
if type(filedata) == dict and filedata["is_file"]:
filename = filedata["name"]
@@ -45,19 +49,23 @@ def image_from_url_text(filedata):
image = Image.open(io.BytesIO(filedata))
return image
+
def add_paste_fields(tabname, init_img, fields):
paste_fields[tabname] = {"init_img":init_img, "fields": fields}
+
def create_buttons(tabs_list):
buttons = {}
for tab in tabs_list:
buttons[tab] = gr.Button(f"Send to {tab}")
return buttons
+
#if send_generate_info is a tab name, mean generate_info comes from the params fields of the tab
def bind_buttons(buttons, send_image, send_generate_info):
bind_list.append([buttons, send_image, send_generate_info])
+
def run_bind():
for buttons, send_image, send_generate_info in bind_list:
for tab in buttons:
@@ -98,6 +106,7 @@ def run_bind():
outputs=None,
)
+
def parse_generation_parameters(x: str):
"""parses generation parameters string, the one you see in text field under the picture in UI:
```