diff --git a/.eslintrc.json b/.eslintrc.json index 4e5d16a65..0fa3cf216 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -75,6 +75,8 @@ //extraNetworks.js "requestGet": "readonly", "getENActiveTab": "readonly", + "quickApplyStyle": "readonly", + "quickSaveStyle": "readonly", // from python "localization": "readonly", // progressbar.js diff --git a/javascript/contextMenus.js b/javascript/contextMenus.js index fab220da4..40e93f4e4 100644 --- a/javascript/contextMenus.js +++ b/javascript/contextMenus.js @@ -86,25 +86,33 @@ const removeContextMenuOption = initResponse[1]; const addContextMenuEventListener = initResponse[2]; function initContextMenu() { - // Start example Context Menu Items - const generateOnRepeat = (genbuttonid, interruptbuttonid) => { - const genbutton = gradioApp().querySelector(genbuttonid); - const busy = document.getElementById('progressbar')?.style.display === 'block'; - if (!busy) genbutton.click(); - clearInterval(window.generateOnRepeatInterval); - window.generateOnRepeatInterval = setInterval(() => { - const pbBusy = document.getElementById('progressbar')?.style.display === 'block'; - if (!pbBusy) genbutton.click(); - }, 500); + const generateForever = (genbuttonid, interruptbuttonid) => { + if (window.generateOnRepeatInterval) { + log('generateForever: cancel'); + clearInterval(window.generateOnRepeatInterval); + window.generateOnRepeatInterval = null; + } else { + log('generateForever: start'); + const genbutton = gradioApp().querySelector(genbuttonid); + const busy = document.getElementById('progressbar')?.style.display === 'block'; + if (!busy) genbutton.click(); + window.generateOnRepeatInterval = setInterval(() => { + const pbBusy = document.getElementById('progressbar')?.style.display === 'block'; + if (!pbBusy) genbutton.click(); + }, 500); + } }; - const cancelGenerateForever = () => clearInterval(window.generateOnRepeatInterval); - appendContextMenuOption('#txt2img_generate', 'Generate forever', () => generateOnRepeat('#txt2img_generate', '#txt2img_interrupt')); - appendContextMenuOption('#img2img_generate', 'Generate forever', () => generateOnRepeat('#img2img_generate', '#img2img_interrupt')); - appendContextMenuOption('#txt2img_generate', 'Cancel generate forever', cancelGenerateForever); - appendContextMenuOption('#img2img_generate', 'Cancel generate forever', cancelGenerateForever); - appendContextMenuOption('#txt2img_generate', 'Show NVML overlay', initNVML); - appendContextMenuOption('#txt2img_generate', 'Hide NVML overlay', disableNVML); + for (const tab of ['txt2img', 'img2img']) { + for (const el of ['prompt > label > textarea', 'generate']) { + const id = `#${tab}_${el}`; + appendContextMenuOption(id, 'Copy to clipboard', () => navigator.clipboard.writeText(document.querySelector(`#${tab}_prompt > label > textarea`).value)); + appendContextMenuOption(id, 'Generate forever', () => generateForever(`#${tab}_generate`)); + appendContextMenuOption(id, 'Apply selected style', quickApplyStyle); + appendContextMenuOption(id, 'Quick save style', quickSaveStyle); + appendContextMenuOption(id, 'nVidia overlay', initNVML); + } + } } onUiLoaded(initContextMenu); diff --git a/javascript/extraNetworks.js b/javascript/extraNetworks.js index b2704ba42..432da7980 100644 --- a/javascript/extraNetworks.js +++ b/javascript/extraNetworks.js @@ -216,6 +216,18 @@ function applyStyles(styles) { return newStyles.join('|'); } +function quickApplyStyle() { + const tabname = getENActiveTab(); + const btnApply = gradioApp().getElementById(`${tabname}_extra_apply`); + if (btnApply) btnApply.click(); +} + +function quickSaveStyle() { + const tabname = getENActiveTab(); + const btnSave = gradioApp().getElementById(`${tabname}_extra_quicksave`); + if (btnSave) btnSave.click(); +} + // init function setupExtraNetworksForTab(tabname) { @@ -243,6 +255,14 @@ function setupExtraNetworksForTab(tabname) { btnModel.onclick = () => btnModel.classList.toggle('toolbutton-selected'); tabs.appendChild(buttons); + // details + const detailsImg = gradioApp().getElementById(`${tabname}_extra_details_img`); + const detailsClose = gradioApp().getElementById(`${tabname}_extra_details_close`); + if (detailsImg && detailsClose) { + detailsImg.title = 'Close details'; + detailsImg.onclick = () => detailsClose.click(); + } + // search and description const div = document.createElement('div'); div.classList.add('second-line'); diff --git a/javascript/nvml.js b/javascript/nvml.js index a557c43d5..cf0187367 100644 --- a/javascript/nvml.js +++ b/javascript/nvml.js @@ -1,4 +1,4 @@ -let nvmlInterval = true; // eslint-disable-line prefer-const +let nvmlInterval = null; // eslint-disable-line prefer-const let nvmlEl = null; let nvmlTable = null; @@ -60,7 +60,13 @@ async function initNVML() { gradioApp().appendChild(nvmlEl); log('initNVML'); } - nvmlInterval = setInterval(updateNVML, 1000); + if (nvmlInterval) { + clearInterval(nvmlInterval); + nvmlInterval = null; + nvmlEl.style.display = 'none'; + } else { + nvmlInterval = setInterval(updateNVML, 1000); + } } async function disableNVML() { diff --git a/javascript/sdnext.css b/javascript/sdnext.css index c0201dd78..4fef1203f 100644 --- a/javascript/sdnext.css +++ b/javascript/sdnext.css @@ -157,7 +157,7 @@ table.settings-value-table td { padding: 0.4em; border: 1px solid #ccc; max-widt /* context menu (ie for the generate button) */ #context-menu { z-index: 9999; position: absolute; display: block; padding: var(--spacing-md); border: 2px solid var(--highlight-color); background: var(--background-fill-primary); color: var(--body-text-color); } -.context-menu-items { list-style: none; margin: 0; padding: 0; } +.context-menu-items { list-style: none; margin: 0; padding: 0; font-size: 0.9em; } .context-menu-items a { display: block; padding: var(--spacing-md); cursor: pointer; font-weight: normal; } .context-menu-items a:hover { background: var(--highlight-color) } @@ -204,6 +204,7 @@ table.settings-value-table td { padding: 0.4em; border: 1px solid #ccc; max-widt .extra-network-cards .card:hover .actions { display: block; } .extra-network-cards .card:hover .overlay .tags { display: block; } .extra-network-cards .card .actions { font-size: 3em; display: none; text-align-last: right; cursor: pointer; font-variant: unicase; position: absolute; z-index: 100; right: 0; height: 0.7em; width: 100%; background: rgba(0, 0, 0, 0.40); } +.extra-details-close { position: fixed; top: 0.2em; right: 0.2em; z-index: 99; background: var(--button-secondary-background-fill) !important; } #txt2img_description, #img2img_description { max-height: 63px; overflow-y: auto !important; } #txt2img_description > label > textarea, #img2img_description > label > textarea { font-size: 0.9em } diff --git a/modules/sd_models.py b/modules/sd_models.py index 3dfd4ca01..f68d82f1e 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -879,7 +879,7 @@ def load_diffuser(checkpoint_info=None, already_loaded_state_dict=None, timer=No shared.log.error(f'Failed loading {op}: {checkpoint_info.path} auto={err1} diffusion={err2}') return elif os.path.isfile(checkpoint_info.path) and checkpoint_info.path.lower().endswith('.safetensors'): - diffusers_load_config["local_files_only"] = True + # diffusers_load_config["local_files_only"] = True diffusers_load_config["extract_ema"] = shared.opts.diffusers_extract_ema pipeline, model_type = detect_pipeline(checkpoint_info.path, op) if pipeline is None: diff --git a/modules/ui.py b/modules/ui.py index 633aa6f83..3ded98772 100644 --- a/modules/ui.py +++ b/modules/ui.py @@ -126,7 +126,7 @@ def process_interrogate(interrogation_function, mode, ii_input_files, ii_input_d images = [f.name for f in ii_input_files] else: if not os.path.isdir(ii_input_dir): - log.error(f"Input directory not found: {ii_input_dir}") + log.error(f"Interrogate: Input directory not found: {ii_input_dir}") return [gr.update(), None] images = modules.shared.listfiles(ii_input_dir) if ii_output_dir != "": @@ -142,6 +142,9 @@ def process_interrogate(interrogation_function, mode, ii_input_files, ii_input_d def interrogate(image): + if image is None: + log.error("Interrogate: no image selected") + return gr.update() prompt = modules.shared.interrogator.interrogate(image.convert("RGB")) return gr.update() if prompt is None else prompt diff --git a/modules/ui_extra_networks.py b/modules/ui_extra_networks.py index b849b1293..ea702d542 100644 --- a/modules/ui_extra_networks.py +++ b/modules/ui_extra_networks.py @@ -393,6 +393,7 @@ class ExtraNetworksUi: self.button_details: gr.Button = None self.button_refresh: gr.Button = None self.button_scan: gr.Button = None + self.button_quicksave: gr.Button = None self.button_save: gr.Button = None self.button_sort: gr.Button = None self.button_apply: gr.Button = None @@ -449,14 +450,14 @@ def create_ui(container, button_parent, tabname, skip_indexing = False): return is_visible, gr.update(visible=is_visible), gr.update(variant=("secondary-down" if is_visible else "secondary")) with ui.details: - details_close = ToolButton(symbols.close, elem_id=tabname+"_extra_details_close") + details_close = ToolButton(symbols.close, elem_id=tabname+"_extra_details_close", elem_classes=['extra-details-close']) details_close.click(fn=lambda: gr.update(visible=False), inputs=[], outputs=[ui.details]) with gr.Row(): with gr.Column(scale=1): text = gr.HTML('
| Type | {page.title} |
| Alias | {getattr(item, 'alias', 'N/A')} |