keyword, sort, send to img2img , administrator, esp

pull/3/head
yfszzx 2022-10-25 18:06:59 +08:00
parent b4f9566976
commit 1ace87f212
3 changed files with 176 additions and 254 deletions

View File

@ -17,12 +17,6 @@ var images_history_click_image = function(){
images_history_set_image_info(this);
}
function images_history_disabled_del(){
gradioApp().querySelectorAll(".images_history_del_button").forEach(function(btn){
btn.setAttribute('disabled','disabled');
});
}
function images_history_get_parent_by_class(item, class_name){
var parent = item.parentElement;
while(!parent.classList.contains(class_name)){
@ -73,17 +67,16 @@ function images_history_set_image_info(button){
var curr_idx = set_btn.getAttribute("img_index", index);
if (curr_idx != index) {
set_btn.setAttribute("img_index", index);
images_history_disabled_del();
}
set_btn.click();
}
function images_history_get_current_img(tabname, img_index, files){
function images_history_get_current_img(tabname, img_index, page_index){
return [
tabname,
gradioApp().getElementById(tabname + '_images_history_set_index').getAttribute("img_index"),
files
gradioApp().getElementById(tabname + '_images_history_set_index').getAttribute("img_index"),
page_index
];
}
@ -118,23 +111,16 @@ function images_history_delete(del_num, tabname, image_index){
}
setTimeout(function(btn){btn.click()}, 30, btn);
}
images_history_disabled_del();
}
function images_history_turnpage(tabname){
gradioApp().getElementById(tabname + '_images_history_del_button').setAttribute('disabled','disabled');
var buttons = gradioApp().getElementById(tabname + '_images_history').querySelectorAll(".gallery-item");
buttons.forEach(function(elem) {
elem.style.display = 'block';
})
});
}
function images_history_enable_del_buttons(){
gradioApp().querySelectorAll(".images_history_del_button").forEach(function(btn){
btn.removeAttribute('disabled');
})
}
function images_history_init(){
var tabnames = gradioApp().getElementById("images_history_tabnames_list")
@ -146,27 +132,21 @@ function images_history_init(){
gradioApp().getElementById(tab + '_images_history_set_index').classList.add("images_history_set_index");
gradioApp().getElementById(tab + '_images_history_del_button').classList.add("images_history_del_button");
gradioApp().getElementById(tab + '_images_history_gallery').classList.add("images_history_gallery");
gradioApp().getElementById(tab + "_images_history_start").setAttribute("style","padding:20px;font-size:25px");
}
}
//preload
var tab_btns = gradioApp().getElementById("images_history_tab").querySelector("div").querySelectorAll("button");
for (var i in images_history_tab_list){
var tabname = images_history_tab_list[i]
tab_btns[i].setAttribute("tabname", tabname);
tab_btns[i].addEventListener('click', function(){
gradioApp().getElementById(this.getAttribute("tabname") + "_images_history_renew_page").click();
});
}
if (gradioApp().getElementById("images_history_preload").querySelector("input").checked ){
var tabs_box = gradioApp().getElementById("tab_images_history").querySelector("div").querySelector("div").querySelector("div");
tabs_box.setAttribute("id", "images_history_tab");
var tab_btns = tabs_box.querySelectorAll("button");
for (var i in images_history_tab_list){
var tabname = images_history_tab_list[i]
tab_btns[i].setAttribute("tabname", tabname);
tab_btns[i].addEventListener('click', function(){
var tabs_box = gradioApp().getElementById("images_history_tab");
if (!tabs_box.classList.contains(this.getAttribute("tabname"))) {
gradioApp().getElementById(this.getAttribute("tabname") + "_images_history_start").click();
tabs_box.classList.add(this.getAttribute("tabname"))
}
});
}
tab_btns[0].click()
}
setTimeout(function(){tab_btns[0].click()}, 100);
}
} else {
setTimeout(images_history_init, 500);
}

4
path_recorder.txt Normal file
View File

@ -0,0 +1,4 @@
f:\hentai
outputs
outputs\txt2img-images
log

View File

@ -5,22 +5,16 @@ import hashlib
import gradio as gr
import modules.extras
import modules.ui
from modules.shared import opts
from modules import shared
from modules.shared import opts, cmd_opts
from modules import shared, scripts
from modules import script_callbacks
system_bak_path = "webui_log_and_bak"
custom_tab_name = "custom fold"
faverate_tab_name = "favorites"
tabs_list = ["txt2img", "img2img", "extras", faverate_tab_name]
tabs_list = ["txt2img", "img2img", "extras", faverate_tab_name, "others"]
num_of_imgs_per_page = 0
loads_files_num = 0
def is_valid_date(date):
try:
time.strptime(date, "%Y%m%d")
return True
except:
return False
path_recorder_filename = os.path.join(scripts.basedir(), "path_recorder.txt")
image_ext_list = [".png", ".jpg", ".jpeg", ".bmp", ".gif", ".webp"]
def reduplicative_file_move(src, dst):
def same_name_file(basename, path):
@ -46,70 +40,10 @@ def reduplicative_file_move(src, dst):
name = same_name_file(name, dst)
shutil.move(src, os.path.join(dst, name))
def traverse_all_files(curr_path, image_list, all_type=False):
try:
f_list = os.listdir(curr_path)
except:
if all_type or (curr_path[-10:].rfind(".") > 0 and curr_path[-4:] != ".txt" and curr_path[-4:] != ".csv"):
image_list.append(curr_path)
return image_list
for file in f_list:
file = os.path.join(curr_path, file)
if (not all_type) and (file[-4:] == ".txt" or file[-4:] == ".csv"):
pass
elif os.path.isfile(file) and file[-10:].rfind(".") > 0:
image_list.append(file)
else:
image_list = traverse_all_files(file, image_list)
return image_list
def archive_images(dir_name, date_to):
filenames = []
batch_size = loads_files_num
today = time.strftime("%Y%m%d",time.localtime(time.time()))
date_to = today if date_to is None or date_to == "" else date_to
date_to_bak = date_to
filenames = traverse_all_files(dir_name, filenames)
total_num = len(filenames)
tmparray = [(os.path.getmtime(file), file) for file in filenames ]
date_stamp = time.mktime(time.strptime(date_to, "%Y%m%d")) + 86400
filenames = []
date_list = {date_to:None}
date = time.strftime("%Y%m%d",time.localtime(time.time()))
for t, f in tmparray:
date = time.strftime("%Y%m%d",time.localtime(t))
date_list[date] = None
if t <= date_stamp:
filenames.append((t, f ,date))
date_list = sorted(list(date_list.keys()), reverse=True)
sort_array = sorted(filenames, key=lambda x:-x[0])
if len(sort_array) > batch_size:
date = sort_array[batch_size][2]
filenames = [x[1] for x in sort_array]
else:
date = date_to if len(sort_array) == 0 else sort_array[-1][2]
filenames = [x[1] for x in sort_array]
filenames = [x[1] for x in sort_array if x[2]>= date]
num = len(filenames)
last_date_from = date_to_bak if num == 0 else time.strftime("%Y%m%d", time.localtime(time.mktime(time.strptime(date, "%Y%m%d")) - 1000))
date = date[:4] + "/" + date[4:6] + "/" + date[6:8]
date_to_bak = date_to_bak[:4] + "/" + date_to_bak[4:6] + "/" + date_to_bak[6:8]
load_info = "<div style='color:#999' align='center'>"
load_info += f"{total_num} images in this directory. Loaded {num} images during {date} - {date_to_bak}, divided into {int((num + 1) // num_of_imgs_per_page + 1)} pages"
load_info += "</div>"
_, image_list, _, _, visible_num = get_recent_images(1, 0, filenames)
return (
date_to,
load_info,
filenames,
1,
image_list,
"",
"",
visible_num,
last_date_from,
gr.update(visible=total_num > num)
)
def save_image(file_name):
if file_name is not None and os.path.exists(file_name):
reduplicative_file_move(file_name, opts.outdir_save)
return "<div style='color:#999'>Added to faverites</div>"
def delete_image(delete_num, name, filenames, image_index, visible_num):
if name == "":
@ -141,88 +75,95 @@ def delete_image(delete_num, name, filenames, image_index, visible_num):
i += 1
return new_file_list, 1, visible_num
def save_image(file_name):
if file_name is not None and os.path.exists(file_name):
shutil.copy(file_name, opts.outdir_save)
def traverse_all_files(curr_path, image_list):
try:
f_list = os.listdir(curr_path)
except:
if os.path.splitext(curr_path)[1] in image_ext_list:
image_list.append(curr_path)
return image_list
for file in f_list:
file = os.path.join(curr_path, file)
if os.path.isfile(file) and os.path.splitext(file)[1] in image_ext_list:
image_list.append(file)
else:
image_list = traverse_all_files(file, image_list)
return image_list
def get_recent_images(page_index, step, filenames):
def get_all_images(dir_name, sort_by, keyword):
filenames = []
filenames = traverse_all_files(dir_name, filenames)
keyword = keyword.strip(" ")
if len(keyword) != 0:
filenames = [x for x in filenames if keyword in x]
total_num = len(filenames)
if sort_by == "date":
filenames = [(os.path.getmtime(file), file) for file in filenames ]
sort_array = sorted(filenames, key=lambda x:-x[0])
filenames = [x[1] for x in sort_array]
elif sort_by == "path name":
sort_array = sorted(filenames)
return filenames
def get_image_page(img_path, page_index, filenames, keyword, sort_by):
if page_index == 1 or page_index == 0 or len(filenames) == 0:
filenames = get_all_images(img_path, sort_by, keyword)
page_index = int(page_index)
max_page_index = len(filenames) // num_of_imgs_per_page + 1
page_index = max_page_index if page_index == -1 else page_index + step
length = len(filenames)
max_page_index = length // num_of_imgs_per_page + 1
page_index = max_page_index if page_index == -1 else page_index
page_index = 1 if page_index < 1 else page_index
page_index = max_page_index if page_index > max_page_index else page_index
idx_frm = (page_index - 1) * num_of_imgs_per_page
image_list = filenames[idx_frm:idx_frm + num_of_imgs_per_page]
length = len(filenames)
visible_num = num_of_imgs_per_page if idx_frm + num_of_imgs_per_page <= length else length % num_of_imgs_per_page
visible_num = num_of_imgs_per_page if idx_frm + num_of_imgs_per_page < length else length % num_of_imgs_per_page
visible_num = num_of_imgs_per_page if visible_num == 0 else visible_num
return page_index, image_list, "", "", visible_num
def loac_batch_click(date_to):
if date_to is None:
return time.strftime("%Y%m%d",time.localtime(time.time())), []
else:
return None, []
def forward_click(last_date_from, date_to_recorder):
if len(date_to_recorder) == 0:
return None, []
if last_date_from == date_to_recorder[-1]:
date_to_recorder = date_to_recorder[:-1]
if len(date_to_recorder) == 0:
return None, []
return date_to_recorder[-1], date_to_recorder[:-1]
def backward_click(last_date_from, date_to_recorder):
if last_date_from is None or last_date_from == "":
return time.strftime("%Y%m%d",time.localtime(time.time())), []
if len(date_to_recorder) == 0 or last_date_from != date_to_recorder[-1]:
date_to_recorder.append(last_date_from)
return last_date_from, date_to_recorder
def first_page_click(page_index, filenames):
return get_recent_images(1, 0, filenames)
def end_page_click(page_index, filenames):
return get_recent_images(-1, 0, filenames)
def prev_page_click(page_index, filenames):
return get_recent_images(page_index, -1, filenames)
def next_page_click(page_index, filenames):
return get_recent_images(page_index, 1, filenames)
def page_index_change(page_index, filenames):
return get_recent_images(page_index, 0, filenames)
load_info = "<div style='color:#999' align='center'>"
load_info += f"{length} images in this directory, divided into {int((length + 1) // num_of_imgs_per_page + 1)} pages"
load_info += "</div>"
return filenames, page_index, image_list, "", "", "", visible_num, load_info
def show_image_info(tabname_box, num, page_index, filenames):
file = filenames[int(num) + int((page_index - 1) * num_of_imgs_per_page)]
tm = "<div style='color:#999' align='right'>" + time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(os.path.getmtime(file))) + "</div>"
return file, tm, num, file
return file, tm, num, file, ""
def enable_page_buttons():
return gr.update(visible=True)
def change_dir(img_dir, date_to):
def change_dir(img_dir, path_recorder, load_switch, img_path_history):
warning = None
try:
if os.path.exists(img_dir):
try:
f = os.listdir(img_dir)
except:
warning = f"'{img_dir} is not a directory"
else:
warning = "The directory is not exist"
except:
warning = "The format of the directory is incorrect"
if warning is None:
today = time.strftime("%Y%m%d",time.localtime(time.time()))
return gr.update(visible=False), gr.update(visible=True), None, None if date_to != today else today, gr.update(visible=True), gr.update(visible=True)
else:
return gr.update(visible=True), gr.update(visible=False), warning, date_to, gr.update(visible=False), gr.update(visible=False)
if not cmd_opts.administrator:
head = os.path.realpath(".")
real_path = os.path.realpath(img_dir)
if len(real_path) < len(head) or real_path[:len(head)] != head:
warning = f"You have not permission to visit {img_dir}"
if warning is None:
try:
if os.path.exists(img_dir):
try:
f = os.listdir(img_dir)
except:
warning = f"'{img_dir} is not a directory"
else:
warning = "The directory is not exist"
except:
warning = "The format of the directory is incorrect"
def show_images_history(tabname):
if warning is None:
if img_dir not in path_recorder:
path_recorder.append(img_dir)
if os.path.exists(path_recorder_filename):
os.remove(path_recorder_filename)
with open(path_recorder_filename, "a") as f:
for x in path_recorder:
f.write(x + "\n")
return "", gr.update(visible=True), gr.Dropdown.update(choices=path_recorder, value=img_dir), path_recorder, img_dir
else:
return warning, gr.update(visible=False), img_path_history, path_recorder, load_switch
def create_tab(tabname):
custom_dir = False
path_recorder = []
if tabname == "txt2img":
dir_name = opts.outdir_txt2img_samples
elif tabname == "img2img":
@ -233,7 +174,13 @@ def show_images_history(tabname):
dir_name = opts.outdir_save
else:
custom_dir = True
dir_name = None
dir_name = None
if os.path.exists(path_recorder_filename):
with open(path_recorder_filename) as f:
path = f.readline().rstrip("\n")
while len(path) > 0:
path_recorder.append(path)
path = f.readline().rstrip("\n")
if not custom_dir:
d = dir_name.split("/")
@ -242,134 +189,125 @@ def show_images_history(tabname):
dir_name = os.path.join(dir_name, p)
if not os.path.exists(dir_name):
os.makedirs(dir_name)
with gr.Column() as page_panel:
with gr.Row():
with gr.Column(scale=1, visible=not custom_dir) as load_batch_box:
load_batch = gr.Button('Load', elem_id=tabname + "_images_history_start", full_width=True)
with gr.Column(scale=4):
with gr.Row():
img_path = gr.Textbox(dir_name, label="Images directory", placeholder="Input images directory", interactive=custom_dir)
with gr.Row():
with gr.Column(visible=False, scale=1) as batch_panel:
with gr.Row():
forward = gr.Button('Prev batch')
backward = gr.Button('Next batch')
with gr.Column(scale=3):
load_info = gr.HTML(visible=not custom_dir)
with gr.Row(visible=False) as warning:
warning_box = gr.Textbox("Message", interactive=False)
with gr.Row(visible=not custom_dir, elem_id=tabname + "_images_history") as main_panel:
with gr.Column(scale=2):
with gr.Row(visible=True) as turn_page_buttons:
#date_to = gr.Dropdown(label="Date to")
with gr.Row(visible= custom_dir):
img_path = gr.Textbox(dir_name, label="Images directory", placeholder="Input images directory", interactive=custom_dir)
img_path_history = gr.Dropdown(path_recorder)
path_recorder = gr.State(path_recorder)
with gr.Row(visible= not custom_dir, elem_id=tabname + "_images_history") as main_panel:
with gr.Column():
with gr.Row():
with gr.Column(scale=2):
with gr.Row():
first_page = gr.Button('First Page')
prev_page = gr.Button('Prev Page')
page_index = gr.Number(value=1, label="Page Index")
next_page = gr.Button('Next Page')
end_page = gr.Button('End Page')
end_page = gr.Button('End Page')
history_gallery = gr.Gallery(show_label=False, elem_id=tabname + "_images_history_gallery").style(grid=opts.images_history_page_columns)
with gr.Row():
with gr.Row() as delete_panel:
delete_num = gr.Number(value=1, interactive=True, label="number of images to delete consecutively next")
delete = gr.Button('Delete', elem_id=tabname + "_images_history_del_button")
with gr.Column():
with gr.Column():
with gr.Row():
sort_by = gr.Radio(value="date", choices=["path name", "date"], label="sort by")
keyword = gr.Textbox(value="", label="keyword")
with gr.Row():
with gr.Column():
img_file_info = gr.Textbox(label="Generate Info", interactive=False, lines=6)
gr.HTML("<hr>")
img_file_name = gr.Textbox(value="", label="File Name", interactive=False)
img_file_time= gr.HTML()
with gr.Row():
with gr.Row(elem_id=tabname + "_images_history_button_panel") as button_panel:
if tabname != faverate_tab_name:
save_btn = gr.Button('Collect')
pnginfo_send_to_txt2img = gr.Button('Send to txt2img')
pnginfo_send_to_img2img = gr.Button('Send to img2img')
send_to_txt2img = gr.Button('To txt2img')
send_to_img2img = gr.Button('To img2img')
send_to_inpaint = gr.Button('To inpaint')
send_to_extras = gr.Button('To extras')
with gr.Row():
collected_warning = gr.HTML()
# hiden items
with gr.Row(visible=False):
renew_page = gr.Button('Refresh page', elem_id=tabname + "_images_history_renew_page")
batch_date_to = gr.Textbox(label="Date to")
renew_page = gr.Button("Renew Page", elem_id=tabname + "_images_history_renew_page")
visible_img_num = gr.Number()
date_to_recorder = gr.State([])
last_date_from = gr.Textbox()
tabname_box = gr.Textbox(tabname)
image_index = gr.Textbox(value=-1)
set_index = gr.Button('set_index', elem_id=tabname + "_images_history_set_index")
filenames = gr.State()
filenames = gr.State([])
all_images_list = gr.State()
hidden = gr.Image(type="pil")
info1 = gr.Textbox()
info2 = gr.Textbox()
load_switch = gr.Textbox(value="load_switch", label="load_switch")
turn_page_switch = gr.Number(value=1, label="turn_page_switch")
with gr.Row():
warning_box = gr.HTML()
img_path.submit(change_dir, inputs=[img_path, batch_date_to], outputs=[warning, main_panel, warning_box, batch_date_to, load_batch_box, load_info])
#change batch
change_date_output = [batch_date_to, load_info, filenames, page_index, history_gallery, img_file_name, img_file_time, visible_img_num, last_date_from, batch_panel]
batch_date_to.change(archive_images, inputs=[img_path, batch_date_to], outputs=change_date_output)
batch_date_to.change(enable_page_buttons, inputs=None, outputs=[turn_page_buttons])
batch_date_to.change(fn=None, inputs=[tabname_box], outputs=None, _js="images_history_turnpage")
load_batch.click(loac_batch_click, inputs=[batch_date_to], outputs=[batch_date_to, date_to_recorder])
forward.click(forward_click, inputs=[last_date_from, date_to_recorder], outputs=[batch_date_to, date_to_recorder])
backward.click(backward_click, inputs=[last_date_from, date_to_recorder], outputs=[batch_date_to, date_to_recorder])
change_dir_outputs = [warning_box, main_panel, img_path_history, path_recorder, load_switch]
img_path.submit(change_dir, inputs=[img_path, path_recorder, load_switch, img_path_history], outputs=change_dir_outputs)
img_path_history.change(change_dir, inputs=[img_path_history, path_recorder, load_switch, img_path_history], outputs=change_dir_outputs)
img_path_history.change(lambda x:x, inputs=[img_path_history], outputs=[img_path])
#delete
delete.click(delete_image, inputs=[delete_num, img_file_name, filenames, image_index, visible_img_num], outputs=[filenames, delete_num, visible_img_num])
delete.click(fn=None, _js="images_history_delete", inputs=[delete_num, tabname_box, image_index], outputs=None)
if tabname != faverate_tab_name:
save_btn.click(save_image, inputs=[img_file_name], outputs=None)
save_btn.click(save_image, inputs=[img_file_name], outputs=[collected_warning])
#turn page
gallery_inputs = [page_index, filenames]
gallery_outputs = [page_index, history_gallery, img_file_name, img_file_time, visible_img_num]
first_page.click(first_page_click, inputs=gallery_inputs, outputs=gallery_outputs)
next_page.click(next_page_click, inputs=gallery_inputs, outputs=gallery_outputs)
prev_page.click(prev_page_click, inputs=gallery_inputs, outputs=gallery_outputs)
end_page.click(end_page_click, inputs=gallery_inputs, outputs=gallery_outputs)
page_index.submit(page_index_change, inputs=gallery_inputs, outputs=gallery_outputs)
renew_page.click(page_index_change, inputs=gallery_inputs, outputs=gallery_outputs)
first_page.click(lambda s:(1, -s) , inputs=[turn_page_switch], outputs=[page_index, turn_page_switch])
next_page.click(lambda p, s: (p + 1, -s), inputs=[page_index, turn_page_switch], outputs=[page_index, turn_page_switch])
prev_page.click(lambda p, s: (p - 1, -s), inputs=[page_index, turn_page_switch], outputs=[page_index, turn_page_switch])
end_page.click(lambda s: (-1, -s), inputs=[turn_page_switch], outputs=[page_index, turn_page_switch])
load_switch.change(lambda s:(1, -s), inputs=[turn_page_switch], outputs=[page_index, turn_page_switch])
keyword.submit(lambda s:(1, -s), inputs=[turn_page_switch], outputs=[page_index, turn_page_switch])
sort_by.change(lambda s:(1, -s), inputs=[turn_page_switch], outputs=[page_index, turn_page_switch])
page_index.submit(lambda s: -s, inputs=[turn_page_switch], outputs=[turn_page_switch])
renew_page.click(lambda s: -s, inputs=[turn_page_switch], outputs=[turn_page_switch])
first_page.click(fn=None, inputs=[tabname_box], outputs=None, _js="images_history_turnpage")
next_page.click(fn=None, inputs=[tabname_box], outputs=None, _js="images_history_turnpage")
prev_page.click(fn=None, inputs=[tabname_box], outputs=None, _js="images_history_turnpage")
end_page.click(fn=None, inputs=[tabname_box], outputs=None, _js="images_history_turnpage")
page_index.submit(fn=None, inputs=[tabname_box], outputs=None, _js="images_history_turnpage")
renew_page.click(fn=None, inputs=[tabname_box], outputs=None, _js="images_history_turnpage")
turn_page_switch.change(
fn=get_image_page,
inputs=[img_path, page_index, filenames, keyword, sort_by],
outputs=[filenames, page_index, history_gallery, img_file_name, img_file_time, img_file_info, visible_img_num, warning_box]
)
turn_page_switch.change(fn=None, inputs=[tabname_box], outputs=None, _js="images_history_turnpage")
turn_page_switch.change(fn=lambda:(gr.update(visible=False), gr.update(visible=False)), inputs=None, outputs=[delete_panel, button_panel])
# other funcitons
set_index.click(show_image_info, _js="images_history_get_current_img", inputs=[tabname_box, image_index, page_index, filenames], outputs=[img_file_name, img_file_time, image_index, hidden])
img_file_name.change(fn=None, _js="images_history_enable_del_buttons", inputs=None, outputs=None)
hidden.change(fn=modules.extras.run_pnginfo, inputs=[hidden], outputs=[info1, img_file_info, info2])
modules.generation_parameters_copypaste.connect_paste(pnginfo_send_to_txt2img, modules.ui.txt2img_paste_fields, img_file_info, 'switch_to_txt2img')
modules.generation_parameters_copypaste.connect_paste(pnginfo_send_to_img2img, modules.ui.img2img_paste_fields, img_file_info, 'switch_to_img2img_img2img')
set_index.click(fn=lambda:(gr.update(visible=True), gr.update(visible=True)), inputs=None, outputs=[delete_panel, button_panel])
img_file_name.change(fn=lambda : "", inputs=None, outputs=[collected_warning])
hidden.change(fn=modules.extras.run_pnginfo, inputs=[hidden], outputs=[info1, img_file_info, info2])
modules.generation_parameters_copypaste.connect_paste(send_to_txt2img, modules.ui.txt2img_paste_fields, img_file_info, 'switch_to_txt2img')
modules.generation_parameters_copypaste.connect_paste(send_to_img2img, modules.ui.img2img_paste_fields, img_file_info, 'switch_to_img2img_img2img')
modules.generation_parameters_copypaste.connect_paste(send_to_inpaint, modules.ui.img2img_paste_fields, img_file_info, 'switch_to_img2img_inpaint')
send_to_img2img.click(lambda x: x, inputs=[img_file_name], outputs=[modules.ui.init_img_components["img2img"]])
send_to_inpaint.click(lambda x: x, inputs=[img_file_name], outputs=[modules.ui.init_img_components["inpaint"]])
send_to_extras.click(lambda x: x, inputs=[img_file_name], outputs=[modules.ui.init_img_components["extras"]])
send_to_extras.click(fn=None, _js="switch_to_extras", inputs=None, outputs=None)
def on_ui_tabs():
global num_of_imgs_per_page
global loads_files_num
num_of_imgs_per_page = int(opts.images_history_page_columns * opts.images_history_page_rows)
loads_files_num = int(opts.images_history_pages_perload * num_of_imgs_per_page)
tabs_list.append(custom_tab_name)
with gr.Blocks(analytics_enabled=False) as images_history:
with gr.Tabs() as tabs:
with gr.Tabs(elem_id="images_history_tab") as tabs:
for tab in tabs_list:
with gr.Tab(tab):
with gr.Blocks(analytics_enabled=False) :
show_images_history(tab)
create_tab(tab)
gr.Checkbox(opts.images_history_preload, elem_id="images_history_preload", visible=False)
gr.Textbox(",".join(tabs_list), elem_id="images_history_tabnames_list", visible=False)
gr.Textbox(",".join(tabs_list), elem_id="images_history_tabnames_list", visible=False)
return (images_history , "Image Browser", "images_history"),
def on_ui_settings():
section = ('images-history', "Images Browser")
shared.opts.add_option("images_history_preload", shared.OptionInfo(False, "Preload images at startup", section=section))
shared.opts.add_option("images_history_page_columns", shared.OptionInfo(6, "Number of columns on the page", section=section))