Commit 538bc89c authored by yfszzx's avatar yfszzx

Image browser improved

parent b7e78ef6
...@@ -17,14 +17,6 @@ var images_history_click_image = function(){ ...@@ -17,14 +17,6 @@ var images_history_click_image = function(){
images_history_set_image_info(this); images_history_set_image_info(this);
} }
var images_history_click_tab = 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"))
}
}
function images_history_disabled_del(){ function images_history_disabled_del(){
gradioApp().querySelectorAll(".images_history_del_button").forEach(function(btn){ gradioApp().querySelectorAll(".images_history_del_button").forEach(function(btn){
btn.setAttribute('disabled','disabled'); btn.setAttribute('disabled','disabled');
...@@ -145,57 +137,64 @@ function images_history_enable_del_buttons(){ ...@@ -145,57 +137,64 @@ function images_history_enable_del_buttons(){
} }
function images_history_init(){ function images_history_init(){
// var loaded = gradioApp().getElementById("images_history_reconstruct_directory") var tabnames = gradioApp().getElementById("images_history_tabnames_list")
// if (loaded){ if (tabnames){
// var init_status = loaded.querySelector("input").checked images_history_tab_list = tabnames.querySelector("textarea").value.split(",")
if (gradioApp().getElementById("images_history_finish_render")){
for (var i in images_history_tab_list ){ for (var i in images_history_tab_list ){
tab = images_history_tab_list[i]; var tab = images_history_tab_list[i];
gradioApp().getElementById(tab + '_images_history').classList.add("images_history_cantainor"); gradioApp().getElementById(tab + '_images_history').classList.add("images_history_cantainor");
gradioApp().getElementById(tab + '_images_history_set_index').classList.add("images_history_set_index"); 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_del_button').classList.add("images_history_del_button");
gradioApp().getElementById(tab + '_images_history_gallery').classList.add("images_history_gallery"); 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
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()
} }
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);
// if (!init_status){
// tab_btns[i].addEventListener('click', images_history_click_tab);
// }
tab_btns[i].addEventListener('click', images_history_click_tab);
}
} else { } else {
setTimeout(images_history_init, 500); setTimeout(images_history_init, 500);
} }
} }
var images_history_tab_list = ["custom", "txt2img", "img2img", "extras", "saved"]; var images_history_tab_list = "";
setTimeout(images_history_init, 500); setTimeout(images_history_init, 500);
document.addEventListener("DOMContentLoaded", function() { document.addEventListener("DOMContentLoaded", function() {
var mutationObserver = new MutationObserver(function(m){ var mutationObserver = new MutationObserver(function(m){
for (var i in images_history_tab_list ){ if (images_history_tab_list != ""){
let tabname = images_history_tab_list[i] for (var i in images_history_tab_list ){
var buttons = gradioApp().querySelectorAll('#' + tabname + '_images_history .gallery-item'); let tabname = images_history_tab_list[i]
buttons.forEach(function(bnt){ var buttons = gradioApp().querySelectorAll('#' + tabname + '_images_history .gallery-item');
bnt.addEventListener('click', images_history_click_image, true); buttons.forEach(function(bnt){
}); bnt.addEventListener('click', images_history_click_image, true);
});
var cls_btn = gradioApp().getElementById(tabname + '_images_history_gallery').querySelector("svg");
if (cls_btn){ var cls_btn = gradioApp().getElementById(tabname + '_images_history_gallery').querySelector("svg");
cls_btn.addEventListener('click', function(){ if (cls_btn){
gradioApp().getElementById(tabname + '_images_history_del_button').setAttribute('disabled','disabled'); cls_btn.addEventListener('click', function(){
}, false); gradioApp().getElementById(tabname + '_images_history_renew_page').click();
} }, false);
}
}
}
}
}); });
mutationObserver.observe(gradioApp(), { childList:true, subtree:true }); mutationObserver.observe(gradioApp(), { childList:true, subtree:true });
}); });
This diff is collapsed.
...@@ -74,6 +74,10 @@ parser.add_argument("--disable-console-progressbars", action='store_true', help= ...@@ -74,6 +74,10 @@ parser.add_argument("--disable-console-progressbars", action='store_true', help=
parser.add_argument("--enable-console-prompts", action='store_true', help="print prompts to console when generating with txt2img and img2img", default=False) parser.add_argument("--enable-console-prompts", action='store_true', help="print prompts to console when generating with txt2img and img2img", default=False)
parser.add_argument('--vae-path', type=str, help='Path to Variational Autoencoders model', default=None) parser.add_argument('--vae-path', type=str, help='Path to Variational Autoencoders model', default=None)
parser.add_argument("--disable-safe-unpickle", action='store_true', help="disable checking pytorch models for malicious code", default=False) parser.add_argument("--disable-safe-unpickle", action='store_true', help="disable checking pytorch models for malicious code", default=False)
parser.add_argument("--browse-all-images", action='store_true', help="Allow browsing all images by Image Browser", default=False)
cmd_opts = parser.parse_args()
cmd_opts = parser.parse_args() cmd_opts = parser.parse_args()
...@@ -311,6 +315,7 @@ options_templates.update(options_section(('sampler-params', "Sampler parameters" ...@@ -311,6 +315,7 @@ options_templates.update(options_section(('sampler-params', "Sampler parameters"
options_templates.update(options_section(('images-history', "Images Browser"), { options_templates.update(options_section(('images-history', "Images Browser"), {
#"images_history_reconstruct_directory": OptionInfo(False, "Reconstruct output directory structure.This can greatly improve the speed of loading , but will change the original output directory structure"), #"images_history_reconstruct_directory": OptionInfo(False, "Reconstruct output directory structure.This can greatly improve the speed of loading , but will change the original output directory structure"),
"images_history_preload": OptionInfo(False, "Preload images at startup"),
"images_history_num_per_page": OptionInfo(36, "Number of pictures displayed on each page"), "images_history_num_per_page": OptionInfo(36, "Number of pictures displayed on each page"),
"images_history_pages_num": OptionInfo(6, "Minimum number of pages per load "), "images_history_pages_num": OptionInfo(6, "Minimum number of pages per load "),
"images_history_grid_num": OptionInfo(6, "Number of grids in each row"), "images_history_grid_num": OptionInfo(6, "Number of grids in each row"),
......
...@@ -1150,7 +1150,7 @@ def create_ui(wrap_gradio_gpu_call): ...@@ -1150,7 +1150,7 @@ def create_ui(wrap_gradio_gpu_call):
"i2i":img2img_paste_fields "i2i":img2img_paste_fields
} }
images_history = img_his.create_history_tabs(gr, opts, wrap_gradio_call(modules.extras.run_pnginfo), images_history_switch_dict) images_history = img_his.create_history_tabs(gr, opts, cmd_opts, wrap_gradio_call(modules.extras.run_pnginfo), images_history_switch_dict)
with gr.Blocks() as modelmerger_interface: with gr.Blocks() as modelmerger_interface:
with gr.Row().style(equal_height=False): with gr.Row().style(equal_height=False):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment