From f9aa2591e5eee70c6a5bcf9318e5020ececaa97c Mon Sep 17 00:00:00 2001 From: vladmandic Date: Tue, 20 Jan 2026 09:53:20 +0100 Subject: [PATCH] fix gallery save/delete Signed-off-by: vladmandic --- CHANGELOG.md | 51 ++++++++++--------- TODO.md | 1 + javascript/ui.js | 26 +++++++--- .../apg/pipeline_stable_diffision_xl_apg.py | 2 +- modules/apg/pipeline_stable_diffusion_apg.py | 2 +- modules/face/instantid_model.py | 2 +- modules/face/photomaker_pipeline.py | 2 +- modules/hidiffusion/hidiffusion_controlnet.py | 2 +- .../onnx_stable_diffusion_upscale_pipeline.py | 2 +- modules/pag/pipe_sd.py | 2 +- modules/pag/pipe_sdxl.py | 2 +- modules/ui_common.py | 4 +- scripts/consistory/consistory_pipeline.py | 2 +- scripts/differential_diffusion.py | 2 +- scripts/freescale/freescale_pipeline.py | 2 +- .../freescale/freescale_pipeline_img2img.py | 2 +- scripts/instantir/sdxl_instantir.py | 2 +- scripts/mod/__init__.py | 2 +- scripts/pixelsmith/pixelsmith_pipeline.py | 2 +- scripts/xadapter/pipeline_sd_xl_adapter.py | 2 +- .../pipeline_sd_xl_adapter_controlnet.py | 2 +- ...peline_sd_xl_adapter_controlnet_img2img.py | 2 +- 22 files changed, 65 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef27b3d7f..7127704c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Change Log for SD.Next -## Update for 2025-01-19 +## Update for 2025-01-20 -### Highlights for 2025-01-19 +### Highlights for 2025-01-20 First release of 2026 brings quite a few new models: **Flux.2-Klein, Qwen-Image-2512, LTX-2-Dev, GLM-Image** There are also improvements to SDNQ quantization engine, updated Prompt Enhance and many others. @@ -11,7 +11,7 @@ For full list of changes, see full changelog. [ReadMe](https://github.com/vladmandic/automatic/blob/master/README.md) | [ChangeLog](https://github.com/vladmandic/automatic/blob/master/CHANGELOG.md) | [Docs](https://vladmandic.github.io/sdnext-docs/) | [WiKi](https://github.com/vladmandic/automatic/wiki) | [Discord](https://discord.com/invite/sd-next-federal-batch-inspectors-1101998836328697867) | [Sponsor](https://github.com/sponsors/vladmandic) -### Details for 2025-01-19 +### Details for 2025-01-20 - **Models** - [Flux.2 Klein](https://bfl.ai/blog/flux2-klein-towards-interactive-visual-intelligence) @@ -80,31 +80,32 @@ For full list of changes, see full changelog. - refactor handling of seeds - allow unsafe ssl context for downloads - **Fixes** + - controlnet: controlnet with non-english ui locales + - core: add skip_keys to offloading logic, fixes wan frames mismatch, thanks @ryanmeador + - core: force model move on offload=none + - core: hidiffusion tracing + - core: hip device name detection + - core: reduce triton test verbosity + - core: switch processing class not restoring params - extension tab: update checker, date handling, formatting etc., thanks @awsr - - controlnet with non-english ui locales - - update civitai base models, thanks @trojaner - - wildards with folder specification - - z-image single-file loader - - hip device name detection - - force align width/height to vae scale factor - - meituan-longca-image-edit missing image param - - mobile auto-collapse when using side panel, thanks @awsr - - switch processing class not restoring params - - hidiffusion tracing - - add skip_keys to offloading logic, fixes wan frames mismatch, thanks @ryanmeador - - wan 2.2 i2v - - force model move on offload=none - - kandinsky-5 image and video on non-cuda platforms - - lora loading when using torch without distributed support - - generate slowdown when consequtive lora-diffusers enabled - - google-genai auth, thanks @CalamitousFelicitousness - - reduce triton test verbosity - - improve qwen i2i handling - - networks filter by model type - - netoworks icon/list view type switch, thanks @awsr - - lora skip with strength zero - lora force unapply on change - lora handle null description, thanks @CalamitousFelicitousness + - lora loading when using torch without distributed support + - lora skip with strength zero + - lora: generate slowdown when consequtive lora-diffusers enabled + - model: google-genai auth, thanks @CalamitousFelicitousness + - model: improve qwen i2i handling + - model: kandinsky-5 image and video on non-cuda platforms + - model: meituan-longca-image-edit missing image param + - model: wan 2.2 i2v + - model: z-image single-file loader + - other: update civitai base models, thanks @trojaner + - ui: gallery save/delete + - ui: mobile auto-collapse when using side panel, thanks @awsr + - ui: networks filter by model type + - ui: networks icon/list view type switch, thanks @awsr + - vae: force align width/height to vae scale factor + - wildards with folder specification ## Update for 2025-12-26 diff --git a/TODO.md b/TODO.md index ce8f4adcd..4c3f94f73 100644 --- a/TODO.md +++ b/TODO.md @@ -47,6 +47,7 @@ TODO: Investigate which models are diffusers-compatible and prioritize! +- [Bria FiboEdit](https://github.com/huggingface/diffusers/commit/d7a1c31f4f85bae5a9e01cdce49bd7346bd8ccd6) - [LTXVideo 0.98 LongMulti](https://github.com/huggingface/diffusers/pull/12614) - [Cosmos-Predict-2.5](https://huggingface.co/nvidia/Cosmos-Predict2.5-2B) - [NewBie Image Exp0.1](https://github.com/huggingface/diffusers/pull/12803) diff --git a/javascript/ui.js b/javascript/ui.js index 9c3fb4f8e..554ddd1a3 100644 --- a/javascript/ui.js +++ b/javascript/ui.js @@ -33,9 +33,10 @@ function clip_gallery_urls(gallery) { } function isVisible(el) { + if (!el) return false; const rect = el.getBoundingClientRect(); if (rect.width === 0 && rect.height === 0) return false; - return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth); + return (rect.top >= 0) && (rect.left >= 0) && (rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)) && (rect.right <= (window.innerWidth || document.documentElement.clientWidth)); } function all_gallery_buttons() { @@ -66,15 +67,24 @@ function selected_gallery_index() { return result; } -function selected_gallery_files() { +function selected_gallery_files(tabname) { let allImages = []; + let allThumbnails; + if (tabname && tabname !== 'gallery') allThumbnails = gradioApp().querySelectorAll('div[id$=_gallery].gradio-gallery .thumbnail-item.thumbnail-small'); + else allThumbnails = gradioApp().querySelectorAll('.gradio-gallery .thumbnails > .thumbnail-item.thumbnail-small'); try { - let allCurrentButtons = gradioApp().querySelectorAll('[style="display: block;"].tabitem div[id$=_gallery].gradio-gallery .thumbnail-item.thumbnail-small'); - if (allCurrentButtons.length === 0) allCurrentButtons = gradioApp().querySelectorAll('.gradio-gallery .thumbnails > .thumbnail-item.thumbnail-small'); - allImages = Array.from(allCurrentButtons).map((v) => v.querySelector('img')?.src); - allImages = allImages.filter((el) => isVisible(el)); - } catch { /**/ } - const selectedIndex = selected_gallery_index(); + allImages = Array.from(allThumbnails).map((v) => v.querySelector('img')); + if (tabname && tabname !== 'gallery') allImages = allImages.filter((img) => isVisible(img)); + allImages = allImages.map((img) => { + let fn = img.src; + if (fn.includes('file=')) fn = fn.split('file=')[1]; + return decodeURI(fn); + }); + } catch (err) { + error(`selected_gallery_files: ${err}`); + } + let selectedIndex = -1; + if (tabname && tabname !== 'gallery') selectedIndex = selected_gallery_index(); return [allImages, selectedIndex]; } diff --git a/modules/apg/pipeline_stable_diffision_xl_apg.py b/modules/apg/pipeline_stable_diffision_xl_apg.py index 70e1b17b8..3371877fd 100644 --- a/modules/apg/pipeline_stable_diffision_xl_apg.py +++ b/modules/apg/pipeline_stable_diffision_xl_apg.py @@ -1081,7 +1081,7 @@ class StableDiffusionXLPipelineAPG( latents, ) - # 6. Prepare extra step kwargs. + # 6. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 7. Prepare added time ids & embeddings diff --git a/modules/apg/pipeline_stable_diffusion_apg.py b/modules/apg/pipeline_stable_diffusion_apg.py index 29cc82b3a..6eb6bae90 100644 --- a/modules/apg/pipeline_stable_diffusion_apg.py +++ b/modules/apg/pipeline_stable_diffusion_apg.py @@ -965,7 +965,7 @@ class StableDiffusionPipelineAPG( latents, ) - # 6. Prepare extra step kwargs. + # 6. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 6.1 Add image embeds for IP-Adapter diff --git a/modules/face/instantid_model.py b/modules/face/instantid_model.py index 2f3002d99..8af9a2907 100644 --- a/modules/face/instantid_model.py +++ b/modules/face/instantid_model.py @@ -882,7 +882,7 @@ class StableDiffusionXLInstantIDPipeline(StableDiffusionXLControlNetPipeline): guidance_scale_tensor, embedding_dim=self.unet.config.time_cond_proj_dim ).to(device=device, dtype=latents.dtype) - # 7. Prepare extra step kwargs. + # 7. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 7.1 Create tensor stating which controlnets to keep diff --git a/modules/face/photomaker_pipeline.py b/modules/face/photomaker_pipeline.py index 577220447..45006a7e1 100644 --- a/modules/face/photomaker_pipeline.py +++ b/modules/face/photomaker_pipeline.py @@ -679,7 +679,7 @@ class PhotoMakerStableDiffusionXLPipeline(StableDiffusionXLPipeline): latents, ) - # 9. Prepare extra step kwargs. + # 9. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 10. Prepare added time ids & embeddings diff --git a/modules/hidiffusion/hidiffusion_controlnet.py b/modules/hidiffusion/hidiffusion_controlnet.py index 2e65d6df4..7a81ab066 100644 --- a/modules/hidiffusion/hidiffusion_controlnet.py +++ b/modules/hidiffusion/hidiffusion_controlnet.py @@ -550,7 +550,7 @@ def make_diffusers_sdxl_contrtolnet_ppl(block_class): # # scale the initial noise by the standard deviation required by the scheduler # latents = latents * self.scheduler.init_noise_sigma - # 7. Prepare extra step kwargs. + # 7. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 7.1 Create tensor stating which controlnets to keep diff --git a/modules/onnx_impl/pipelines/onnx_stable_diffusion_upscale_pipeline.py b/modules/onnx_impl/pipelines/onnx_stable_diffusion_upscale_pipeline.py index 4bf303666..5bdc09794 100644 --- a/modules/onnx_impl/pipelines/onnx_stable_diffusion_upscale_pipeline.py +++ b/modules/onnx_impl/pipelines/onnx_stable_diffusion_upscale_pipeline.py @@ -128,7 +128,7 @@ class OnnxStableDiffusionUpscalePipeline(diffusers.OnnxStableDiffusionUpscalePip " `pipeline.unet` or your `image` input." ) - # 8. Prepare extra step kwargs. + # 8. Prepare extra step kwargs. accepts_eta = "eta" in set(inspect.signature(self.scheduler.step).parameters.keys()) extra_step_kwargs = {} if accepts_eta: diff --git a/modules/pag/pipe_sd.py b/modules/pag/pipe_sd.py index 06a1aa195..4393a24d3 100644 --- a/modules/pag/pipe_sd.py +++ b/modules/pag/pipe_sd.py @@ -1268,7 +1268,7 @@ class StableDiffusionPAGPipeline( latents, ) - # 6. Prepare extra step kwargs. + # 6. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 6.1 Add image embeds for IP-Adapter diff --git a/modules/pag/pipe_sdxl.py b/modules/pag/pipe_sdxl.py index ce5a1dc8b..653fecf30 100644 --- a/modules/pag/pipe_sdxl.py +++ b/modules/pag/pipe_sdxl.py @@ -1366,7 +1366,7 @@ class StableDiffusionXLPAGPipeline( latents, ) - # 6. Prepare extra step kwargs. + # 6. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 7. Prepare added time ids & embeddings diff --git a/modules/ui_common.py b/modules/ui_common.py index aa7a1c8bb..4c0c6979e 100644 --- a/modules/ui_common.py +++ b/modules/ui_common.py @@ -88,7 +88,7 @@ def delete_files(js_data, files, all_files, index): continue if os.path.exists(fn) and os.path.isfile(fn): deleted.append(fn) - os.remove(fn) + # os.remove(fn) if fn in all_files: all_files.remove(fn) shared.log.info(f'Delete: image="{fn}"') @@ -312,7 +312,7 @@ def create_output_panel(tabname, preview=True, prompt=None, height=None, transfe outputs=[download_files, html_log], ) delete.click(fn=call_queue.wrap_gradio_call(delete_files), show_progress='hidden', - _js="(x, y, i, j) => [x, y, ...selected_gallery_files()]", + _js=f'(x, y, i, j) => [x, y, ...selected_gallery_files("{tabname}")]', inputs=[generation_info, result_gallery, html_info, html_info], outputs=[result_gallery, html_log], ) diff --git a/scripts/consistory/consistory_pipeline.py b/scripts/consistory/consistory_pipeline.py index facb486cf..9ad065db8 100644 --- a/scripts/consistory/consistory_pipeline.py +++ b/scripts/consistory/consistory_pipeline.py @@ -322,7 +322,7 @@ class ConsistoryExtendAttnSDXLPipeline( latents, ) - # 6. Prepare extra step kwargs. + # 6. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) if share_queries: diff --git a/scripts/differential_diffusion.py b/scripts/differential_diffusion.py index ed74819e0..f351571a6 100644 --- a/scripts/differential_diffusion.py +++ b/scripts/differential_diffusion.py @@ -1756,7 +1756,7 @@ class StableDiffusionDiffImg2ImgPipeline(DiffusionPipeline): timesteps, num_inference_steps = self.get_timesteps(num_inference_steps, strength, device) - # 7. Prepare extra step kwargs. + # 7. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) map = torchvision.transforms.Resize(tuple(s // self.vae_scale_factor for s in image.shape[2:]),antialias=None)(map) diff --git a/scripts/freescale/freescale_pipeline.py b/scripts/freescale/freescale_pipeline.py index 70e91a5c5..df91c014b 100644 --- a/scripts/freescale/freescale_pipeline.py +++ b/scripts/freescale/freescale_pipeline.py @@ -873,7 +873,7 @@ class StableDiffusionXLFreeScale(DiffusionPipeline, FromSingleFileMixin, LoraLoa latents, ) - # 6. Prepare extra step kwargs. + # 6. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 7. Prepare added time ids & embeddings diff --git a/scripts/freescale/freescale_pipeline_img2img.py b/scripts/freescale/freescale_pipeline_img2img.py index a34eae07b..7f2964cc2 100644 --- a/scripts/freescale/freescale_pipeline_img2img.py +++ b/scripts/freescale/freescale_pipeline_img2img.py @@ -902,7 +902,7 @@ class StableDiffusionXLFreeScaleImg2Img(DiffusionPipeline, FromSingleFileMixin, latents, ) - # 6. Prepare extra step kwargs. + # 6. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 7. Prepare added time ids & embeddings diff --git a/scripts/instantir/sdxl_instantir.py b/scripts/instantir/sdxl_instantir.py index 72f5bf831..bfb4f84e9 100644 --- a/scripts/instantir/sdxl_instantir.py +++ b/scripts/instantir/sdxl_instantir.py @@ -1405,7 +1405,7 @@ class InstantIRPipeline( guidance_scale_tensor, embedding_dim=self.unet.config.time_cond_proj_dim ).to(device=device, dtype=latents.dtype) - # 7. Prepare extra step kwargs. + # 7. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 7.1 Create tensor stating which controlnets to keep diff --git a/scripts/mod/__init__.py b/scripts/mod/__init__.py index a5490cb04..db9445b8c 100644 --- a/scripts/mod/__init__.py +++ b/scripts/mod/__init__.py @@ -1039,7 +1039,7 @@ class StableDiffusionXLTilingPipeline( if isinstance(self.scheduler, LMSDiscreteScheduler): latents = latents * self.scheduler.sigmas[0] - # 5. Prepare extra step kwargs. + # 5. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 6. Prepare added time ids & embeddings diff --git a/scripts/pixelsmith/pixelsmith_pipeline.py b/scripts/pixelsmith/pixelsmith_pipeline.py index 238df1a78..474fcd4e8 100644 --- a/scripts/pixelsmith/pixelsmith_pipeline.py +++ b/scripts/pixelsmith/pixelsmith_pipeline.py @@ -1384,7 +1384,7 @@ class PixelSmithXLPipeline( latents, ) - # 6. Prepare extra step kwargs. + # 6. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 7. Prepare added time ids & embeddings diff --git a/scripts/xadapter/pipeline_sd_xl_adapter.py b/scripts/xadapter/pipeline_sd_xl_adapter.py index 8cba72728..788235517 100644 --- a/scripts/xadapter/pipeline_sd_xl_adapter.py +++ b/scripts/xadapter/pipeline_sd_xl_adapter.py @@ -833,7 +833,7 @@ class StableDiffusionXLAdapterPipeline(DiffusionPipeline, FromSingleFileMixin, L latents_sd1_5, ) - # 6. Prepare extra step kwargs. + # 6. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 7. Prepare added time ids & embeddings diff --git a/scripts/xadapter/pipeline_sd_xl_adapter_controlnet.py b/scripts/xadapter/pipeline_sd_xl_adapter_controlnet.py index a1a71c3b8..853b49e26 100644 --- a/scripts/xadapter/pipeline_sd_xl_adapter_controlnet.py +++ b/scripts/xadapter/pipeline_sd_xl_adapter_controlnet.py @@ -934,7 +934,7 @@ class StableDiffusionXLAdapterControlnetPipeline(DiffusionPipeline, FromSingleFi latents_sd1_5, ) - # 6. Prepare extra step kwargs. + # 6. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 7. Prepare added time ids & embeddings diff --git a/scripts/xadapter/pipeline_sd_xl_adapter_controlnet_img2img.py b/scripts/xadapter/pipeline_sd_xl_adapter_controlnet_img2img.py index 515f24632..932ef5f1a 100644 --- a/scripts/xadapter/pipeline_sd_xl_adapter_controlnet_img2img.py +++ b/scripts/xadapter/pipeline_sd_xl_adapter_controlnet_img2img.py @@ -941,7 +941,7 @@ class StableDiffusionXLAdapterControlnetI2IPipeline(DiffusionPipeline, FromSingl generator, ) - # 6. Prepare extra step kwargs. + # 6. Prepare extra step kwargs. extra_step_kwargs = self.prepare_extra_step_kwargs(generator, eta) # 7. Prepare added time ids & embeddings