From ee3cea54ebbba930e5f9807053ea31d5b330a785 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 19 Apr 2023 07:52:26 -0400 Subject: [PATCH] fix live preview --- extensions-builtin/a1111-sd-webui-lycoris | 2 +- extensions-builtin/sd-extension-system-info | 2 +- extensions-builtin/sd-webui-controlnet | 2 +- javascript/extensions.js | 3 +- javascript/textualInversion.js | 9 +---- javascript/ui.js | 42 +++++++++++---------- 6 files changed, 28 insertions(+), 32 deletions(-) diff --git a/extensions-builtin/a1111-sd-webui-lycoris b/extensions-builtin/a1111-sd-webui-lycoris index a2d2ac40a..bb7d428ac 160000 --- a/extensions-builtin/a1111-sd-webui-lycoris +++ b/extensions-builtin/a1111-sd-webui-lycoris @@ -1 +1 @@ -Subproject commit a2d2ac40a31a9a8913c6838e7f863a72958e3bd3 +Subproject commit bb7d428ac7703d6703ebabbc1fcc9233ac958801 diff --git a/extensions-builtin/sd-extension-system-info b/extensions-builtin/sd-extension-system-info index 52cd26c76..3d4e823e5 160000 --- a/extensions-builtin/sd-extension-system-info +++ b/extensions-builtin/sd-extension-system-info @@ -1 +1 @@ -Subproject commit 52cd26c766ef52060675b46ffbc7c004d5542c78 +Subproject commit 3d4e823e5e627ff85597e6e89c371fbd0c096130 diff --git a/extensions-builtin/sd-webui-controlnet b/extensions-builtin/sd-webui-controlnet index 7d28d00e2..937e8f074 160000 --- a/extensions-builtin/sd-webui-controlnet +++ b/extensions-builtin/sd-webui-controlnet @@ -1 +1 @@ -Subproject commit 7d28d00e299078454d20ca1a8b09a8aa4ea76ee7 +Subproject commit 937e8f07414d5de9f4a8570844731d643aeff576 diff --git a/javascript/extensions.js b/javascript/extensions.js index 1c2483b86..e64a0c795 100644 --- a/javascript/extensions.js +++ b/javascript/extensions.js @@ -19,8 +19,7 @@ function extensions_check(_, _){ x.innerHTML = "Loading..." }) var id = randomId() - requestProgress(id, gradioApp().getElementById('extensions_installed_top'), null, function(){ - }) + requestProgress(id, gradioApp().getElementById('extensions_installed_top'), null, null, null, false) return [id, JSON.stringify(disable)] } diff --git a/javascript/textualInversion.js b/javascript/textualInversion.js index 0354b860c..883092547 100644 --- a/javascript/textualInversion.js +++ b/javascript/textualInversion.js @@ -3,15 +3,10 @@ function start_training_textual_inversion(){ gradioApp().querySelector('#ti_error').innerHTML='' - var id = randomId() - requestProgress(id, gradioApp().getElementById('ti_output'), gradioApp().getElementById('ti_gallery'), function(){}, function(progress){ - gradioApp().getElementById('ti_progress').innerHTML = progress.textinfo - }) - + const onProgress = (progress) => gradioApp().getElementById('ti_progress').innerHTML = progress.textinfo; + requestProgress(id, gradioApp().getElementById('ti_output'), gradioApp().getElementById('ti_gallery'), null, onProgress, false) var res = args_to_array(arguments) - res[0] = id - return res } diff --git a/javascript/ui.js b/javascript/ui.js index c849ea585..e52f2d6e1 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -2,9 +2,7 @@ function set_theme(theme){ gradioURL = window.location.href - if (!gradioURL.includes('?__theme=')) { - window.location.replace(gradioURL + '?__theme=' + theme); - } + if (!gradioURL.includes('?__theme=')) window.location.replace(gradioURL + '?__theme=' + theme); } function all_gallery_buttons() { @@ -128,33 +126,32 @@ function showSubmitButtons(tabname, show){ // gradioApp().getElementById(tabname+'_skip').style.display = "block" } -function submit(id, once = false){ +function submit(){ rememberGallerySelection('txt2img_gallery') showSubmitButtons('txt2img', false) - if (!id) id = randomId() + const id = randomId() const atEnd = () => showSubmitButtons('txt2img', true) - requestProgress(id, gradioApp().getElementById('txt2img_gallery_container'), gradioApp().getElementById('txt2img_gallery'), atEnd, null, once) + requestProgress(id, gradioApp().getElementById('txt2img_gallery_container'), gradioApp().getElementById('txt2img_gallery'), atEnd) var res = create_submit_args(arguments) res[0] = id return res } -function submit_img2img(id){ +function submit_img2img(){ rememberGallerySelection('img2img_gallery') showSubmitButtons('img2img', false) - if (!id) id = randomId() - requestProgress(id, gradioApp().getElementById('img2img_gallery_container'), gradioApp().getElementById('img2img_gallery'), function(){ - showSubmitButtons('img2img', true) - }) + const id = randomId() + const atEnd = () => showSubmitButtons('img2img', true) + requestProgress(id, gradioApp().getElementById('img2img_gallery_container'), gradioApp().getElementById('img2img_gallery'), atEnd) var res = create_submit_args(arguments) res[0] = id res[1] = get_tab_index('mode_img2img') return res } -function modelmerger(id){ - if (!id) id = randomId() - requestProgress(id, gradioApp().getElementById('modelmerger_results_panel'), null, function(){}) +function modelmerger(){ + const id = randomId() + requestProgress(id, gradioApp().getElementById('modelmerger_results_panel'), null) var res = create_submit_args(arguments) res[0] = id return res @@ -173,7 +170,6 @@ function confirm_clear_prompt(prompt, negative_prompt) { return [prompt, negative_prompt] } - promptTokecountUpdateFuncs = {} function recalculatePromptTokens(name){ @@ -194,7 +190,6 @@ function recalculate_prompts_img2img(){ return args_to_array(arguments); } - opts = {} onUiUpdate(function(){ if(Object.keys(opts).length != 0) return; @@ -331,11 +326,18 @@ function preview_theme() { } function reconnect_ui() { - const el = gradioApp().getElementById('txt2img_generate') - if (!el) return - else clearInterval(start_check) + const el1 = gradioApp().getElementById('txt2img_gallery_container') + const el2 = gradioApp().getElementById('txt2img_gallery') const task_id = localStorage.getItem('task') - if (task_id) submit(task_id, true) + if (!el1 || !el2) return + else clearInterval(start_check) + if (task_id) { + console.debug('task check:', task_id) + rememberGallerySelection('txt2img_gallery') + showSubmitButtons('txt2img', false) + const atEnd = () => showSubmitButtons('txt2img', true) + requestProgress(task_id, el1, el2, atEnd, null, true) + } } var start_check = setInterval(reconnect_ui, 50)