add needed imports fr new code in copypaste.py
This commit is contained in:
parent
45ca67f35a
commit
3c207ca684
|
@ -1,3 +1,5 @@
|
||||||
|
import base64
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import gradio as gr
|
import gradio as gr
|
||||||
|
@ -14,6 +16,7 @@ type_of_gr_update = type(gr.update())
|
||||||
paste_fields = {}
|
paste_fields = {}
|
||||||
bind_list = []
|
bind_list = []
|
||||||
|
|
||||||
|
|
||||||
def quote(text):
|
def quote(text):
|
||||||
if ',' not in str(text):
|
if ',' not in str(text):
|
||||||
return text
|
return text
|
||||||
|
@ -23,6 +26,7 @@ def quote(text):
|
||||||
text = text.replace('"', '\\"')
|
text = text.replace('"', '\\"')
|
||||||
return f'"{text}"'
|
return f'"{text}"'
|
||||||
|
|
||||||
|
|
||||||
def image_from_url_text(filedata):
|
def image_from_url_text(filedata):
|
||||||
if type(filedata) == dict and filedata["is_file"]:
|
if type(filedata) == dict and filedata["is_file"]:
|
||||||
filename = filedata["name"]
|
filename = filedata["name"]
|
||||||
|
@ -45,19 +49,23 @@ def image_from_url_text(filedata):
|
||||||
image = Image.open(io.BytesIO(filedata))
|
image = Image.open(io.BytesIO(filedata))
|
||||||
return image
|
return image
|
||||||
|
|
||||||
|
|
||||||
def add_paste_fields(tabname, init_img, fields):
|
def add_paste_fields(tabname, init_img, fields):
|
||||||
paste_fields[tabname] = {"init_img":init_img, "fields": fields}
|
paste_fields[tabname] = {"init_img":init_img, "fields": fields}
|
||||||
|
|
||||||
|
|
||||||
def create_buttons(tabs_list):
|
def create_buttons(tabs_list):
|
||||||
buttons = {}
|
buttons = {}
|
||||||
for tab in tabs_list:
|
for tab in tabs_list:
|
||||||
buttons[tab] = gr.Button(f"Send to {tab}")
|
buttons[tab] = gr.Button(f"Send to {tab}")
|
||||||
return buttons
|
return buttons
|
||||||
|
|
||||||
|
|
||||||
#if send_generate_info is a tab name, mean generate_info comes from the params fields of the tab
|
#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):
|
def bind_buttons(buttons, send_image, send_generate_info):
|
||||||
bind_list.append([buttons, send_image, send_generate_info])
|
bind_list.append([buttons, send_image, send_generate_info])
|
||||||
|
|
||||||
|
|
||||||
def run_bind():
|
def run_bind():
|
||||||
for buttons, send_image, send_generate_info in bind_list:
|
for buttons, send_image, send_generate_info in bind_list:
|
||||||
for tab in buttons:
|
for tab in buttons:
|
||||||
|
@ -98,6 +106,7 @@ def run_bind():
|
||||||
outputs=None,
|
outputs=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def parse_generation_parameters(x: str):
|
def parse_generation_parameters(x: str):
|
||||||
"""parses generation parameters string, the one you see in text field under the picture in UI:
|
"""parses generation parameters string, the one you see in text field under the picture in UI:
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
import base64
|
|
||||||
import html
|
import html
|
||||||
import io
|
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
@ -18,13 +16,8 @@ import gradio as gr
|
||||||
import gradio.routes
|
import gradio.routes
|
||||||
import gradio.utils
|
import gradio.utils
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import piexif
|
|
||||||
import torch
|
|
||||||
from PIL import Image, PngImagePlugin
|
from PIL import Image, PngImagePlugin
|
||||||
|
|
||||||
import gradio as gr
|
|
||||||
import gradio.utils
|
|
||||||
import gradio.routes
|
|
||||||
|
|
||||||
from modules import sd_hijack, sd_models, localization, script_callbacks
|
from modules import sd_hijack, sd_models, localization, script_callbacks
|
||||||
from modules.paths import script_path
|
from modules.paths import script_path
|
||||||
|
|
Loading…
Reference in New Issue