Commit Graph

13560 Commits

Author SHA1 Message Date
Ryan Meador 11096bc0aa feat(video): add thumbnail save toggle 2026-06-02 23:43:58 -04:00
Vladimir Mandic 2af67b76d0 lint
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-06-02 17:13:08 +02:00
Vladimir Mandic 35aa8c6422 fix openpose and add test-compile
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-06-02 17:06:18 +02:00
Vladimir Mandic 3c2a742f40 cleanup logging
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-06-02 08:03:27 +02:00
Vladimir Mandic bd47b693d2 update transformers and cleanup ui labels
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-06-02 07:45:37 +02:00
Vladimir Mandic 2ad2796ea9 update diffusers
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-06-02 07:19:04 +02:00
Vladimir Mandic 6afde7e631 Merge pull request #4886 from vladmandic/feat/detailer-postprocess
feat(api): add detailer postprocess script and /sdapi/v1/detail endpoint
2026-06-02 07:15:11 +02:00
Vladimir Mandic a96a828191 Merge pull request #4888 from liutyi/dev
Microsoft Lens preview images v2 (office)
2026-06-01 19:58:33 +02:00
Oleksandr Liutyi 3108a00be8 Microsoft Lens preview images v2 (office) 2026-06-01 17:49:11 +00:00
Vladimir Mandic 6a1c994cf3 cleanup
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-06-01 11:54:26 +02:00
Vladimir Mandic c319f8f92d refactor shared text encoder
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-06-01 10:03:10 +02:00
Vladimir Mandic 24aced130d Merge pull request #4876 from vladmandic/feat/native-transformer-loader
Feat/native transformer loader
2026-06-01 06:59:47 +02:00
Vladimir Mandic 76763da29d Merge pull request #4887 from ryanmeador/fix/ltx-prompt-embed-device
fix(ltx): align cached prompt tensors with device
2026-06-01 06:51:40 +02:00
CalamitousFelicitousness f9ab0bf04d feat(api): add detailer postprocess script and /sdapi/v1/detail endpoint
Surface YoloRestorer.restore() as a standalone operation: a Detailer
postprocessing script in the Process tab and a thin /sdapi/v1/detail
endpoint, neither requiring a base generation pass.

- modules/postprocess/yolo.py: YoloRestorer.make_processing() builds the
  synthetic Img2Img processing object both entry points feed to restore(),
  resolving the seed so the inpaint passes are reproducible
- modules/api/process.py: post_detail handler exposes the full detailer
  parameter set and returns the detailed image plus optional annotations
  as base64
- scripts/postprocessing_detailer.py: reuses shared.yolo.ui('extras') and
  runs through make_processing()
- modules/postprocessing.py: run_extras takes a per-script script_args
  dict, also letting the extras API drive other scripts such as Remove
  background; omitting it leaves existing callers unchanged
- modules/api/models.py: ReqDetail / ResDetail
- modules/processing_info.py: guard create_infotext's Image/Hires CFG
  reporting against an unset (None) cfg_image, matching the is-not-None
  checks the other cfg_image readers use; the detailer inpaint pass runs
  with it unset
- test/test-detailer-api.py: covers both paths; effect tests measure the
  diff inside the detected region with extreme isolated parameter values,
  and the suite disables model quantization for the run and restores the
  original settings afterward
2026-06-01 00:25:59 +01:00
Ryan Meador b63e5ceeae fix(ltx): align cached prompt tensors with device 2026-05-31 17:52:44 -04:00
Vladimir Mandic c3eec8e60b Merge pull request #4884 from vladmandic/fix/output-paths-base-relative
fix(paths): don't create per-type output dirs at root when base set
2026-05-31 06:47:53 +02:00
Vladimir Mandic dce4c2cd94 Merge pull request #4883 from vladmandic/fix/taesd-preview-size
fix(preview): keep taesd preview size constant across decode layers
2026-05-31 06:47:07 +02:00
CalamitousFelicitousness 0acfc70c42 fix(paths): don't create per-type output dirs at root when base set
create_paths() pre-created every per-type output folder via fix_path(), which resolves relative values against data_path (the repo root). With a base images/grids folder configured, those bare dirs are never written to (generation uses the base-joined path), so they accumulate as empty stray folders at the repo root on every launch. Guard the bare creations behind an unset base; the resolved base+specific block already creates the real targets.
2026-05-31 04:49:05 +01:00
CalamitousFelicitousness f8bd53a96b fix(preview): keep taesd preview size constant across decode layers
taesd_layers < 3 drops spatial upsample blocks in the TAESD/TAEHV
decoders, shrinking preview output 2x/4x. Both UIs size the live preview
from the image's intrinsic pixel dimensions (modern via object-fit:
scale-down, standard via max(naturalWidth, 512px)), so lower layer counts
rendered the preview physically small.

Rescale the decoded preview spatially by 2^(3-layers) in
sd_vae_taesd.decode. Gated to TAESD and TAEHV, the only decoders that
honor taesd_layers; TAEM1 and Hybrid VAEs decode at full size and are left
untouched. Rank-agnostic so it covers both image (CHW) and video (TCHW)
previews, including single-frame video models used for txt2img.
2026-05-31 04:43:10 +01:00
CalamitousFelicitousness 77913c7c0a docs: cleanup
- generic.load_transformer: shorter dispatch description, no internal taxonomy
- native_transformer.load: trim kwargs forwarding wording
- sd_unet revert: one-line comment
- test: shorten kwargs-forwarding docstrings
2026-05-31 02:04:56 +01:00
CalamitousFelicitousness 23c06c39d6 refactor(sd_unet): route transformer override through reload_model_weights
The custom-transformer apply (DiT branch) and the revert-to-default path now call reload_model_weights(force=True) instead of load_diffuser, so both go through the same managed reload: unload-before-rebuild for a lower VRAM peak and consistent job/checkpoint bookkeeping.

Gate the cross-arch unet reset on an actual checkpoint change so a same-checkpoint reload skips the pipeline-class comparison, which could false-positive and clear the override when the model was left in an img2img/inpaint variant after an interrupted generation.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 25fa8e0f15 refactor(ui): shorten unet-sync handlers, align load logs
- ui_settings: rename to sync_checkpoint_unet / sync_checkpoint_unet_forced
- sd_models: cross-arch unet reset log uses key=value house style
- generic: native transformer dispatch logs loader=native
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 18656d1d79 fix(native_transformer): forward load kwargs to from_config
load_transformer threads **kwargs into its from_pretrained and from_single_file branches. The native dispatch branch bypasses both loaders and builds via cls.from_config, so those kwargs were dropped there. Thread them through load, build_component, and build_component_quantized into from_config so callers passing extra args alongside native_spec are honored instead of silently dropped. Siblings do not receive them.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness c29168a766 feat(native_transformer): implement per-tensor pre-mode SDNQ quantization
The transformer load path now mirrors diffusers' load_model_dict_into_meta: build the component inside init_empty_weights(include_buffers=False) so parameter slots stay meta while computed buffers keep their __init__ values, then iterate the converted state_dict tensor by tensor. Each tensor is dispatched through SDNQQuantizer.check_if_quantized_param and create_quantized_param so Linear/Conv/Embed weights are packed to uint4 in flight, while non-quantizable parameters go through accelerate.set_module_tensor_to_device.

Peak memory during transformer load drops from the full bf16 model size to one layer's worth of bf16 plus the running uint4 result. The prior load_state_dict + .to(dtype) + post-walk sdnq_quantize_model sequence remains as the fallback path for siblings and non-SDNQ quant types.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 7ae45c59d4 refactor(native_transformer): accept precomputed quant_args from caller
generic.load_transformer already computes quant_args and quant_type at the top of the function, but native_transformer.load was redoing the same work and emitting a duplicate 'Quantization: module=Model ...' log line milliseconds later. Pass them through instead; fall back to computing them when called directly (model_anima still does so).
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 7b9c5d5d8c fix(sd_models): hide misleading state_dict progress bar for safetensors
safetensors.torch.load_file opens the file by path internally, so the progress.open wrapper around it never advanced from 0/N - it just left a stuck '0.0/18.2 GB' bar on screen for the duration of the load. Skip the wrapper on that path; .ckpt and stream_load paths still get the working bar.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 09c6229b1c fix(ui): refresh UNET dropdown after cross-arch model swap
When reload_model_weights resets shared.opts.sd_unet to Default on a cross-arch swap, the backend value changed but the dropdown component kept showing the previous selection because sd_unet was not in the change_checkpoint button's outputs.

Add the sd_unet component to the outputs and return its post-reload value via gr.update.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 75933bfaee feat(native_transformer): log per-phase progress to reduce load silence
The native loader was emitting one line at dispatch, a single line after prefix detection, and the total time at the end. For an 18 GB transformer that meant ~60s of silence with no indication anything was happening.

Add DEBUG lines before each long phase: read_state_dict, optional converter, load_state_dict into the model, and dtype cast. Total-time log at the end is unchanged.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness bab6c253f4 feat(sd_unet): reset UNET override on cross-arch base model swap
A custom UNET selected via the UNET dropdown carried over silently when the user swapped to a base model of a different arch, then crashed inside the per-arch loader because shared.opts.sd_unet was still pointing at the previous arch's file.

reload_model_weights now runs sd_detect.detect_pipeline on the new checkpoint before unloading the old model, compares the detected pipeline class against the loaded model's class, and resets shared.opts.sd_unet to Default when they differ.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness cda4822ca0 fix(chroma): route through native_transformer to avoid SDNQ pre-mode crash
Loading a Chroma transformer override via UNET dropdown crashed at
inference with a shape mismatch in unpack_uint4: from_single_file does
not integrate quantization_config the way from_pretrained does, so the
dequantizer state was set up but the .weight tensor was never packed.

CHROMA_SPEC routes through native_transformer with the diffusers
Chroma converter, which loads bare and quantizes explicitly via
sdnq_quantize_model.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness b29178743c fix(native_transformer): forward modules_to_not_convert to sdnq_quantize_model
apply_quant called sdnq_quantize_model(transformer, op="transformer")
without the per-call skip lists, dropping modules_to_not_convert and
modules_dtype_dict that the caller passed into generic.load_transformer.
The from_pretrained path receives them via quantization_config; the
native path now threads them directly into the explicit quantizer call.

Plumbed load -> build_component -> apply_quant as keyword args. No
behavior change for callers that did not set the skip lists.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness d55af33d36 refactor(pipelines): split kandinsky into kandinsky3 and kandinsky5
K3 and K5 share only the marketing name: different diffusers pipeline
classes (Kandinsky3Pipeline vs Kandinsky5T2I/I2IPipeline), different
denoiser classes (Kandinsky3UNet vs Kandinsky5Transformer3DModel), no
shared scaffolding. Separate packages so each spec lives next to the
arch it serves.

K2.1 and K2.2 stay outside both packages since they go through
KandinskyCombinedPipeline.from_pretrained directly with no spec.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness bd60372cc5 refactor(pipelines): move per-arch transformer specs into packages
Specs for chrono, cogview, flux2_klein, glm, hunyuandit, hyimage, joy,
kandinsky, longcat, nucleus, ovis, pixart and prx lived module-level in
model_<arch>.py. Move each into pipelines/<arch>/__init__.py to match
the layout used by anima, bria, ernie, f_lite, lens, qwen, step1x and
vibe.

Each model_<arch>.py now imports its spec lazily inside the load
function, so the package only gets pulled in when that arch is actually
loaded (kandinsky 2.x never goes through native dispatch and stays
untouched).

Also drop the "without this spec..." crash paragraph from the new
package docstrings plus ernie/__init__.py and bria/__init__.py.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 9326804d69 fix(sd_unet): reload model when reverting UNET dropdown to Default
load_unet returned early when sd_unet was set to 'Default'/'None',
leaving any previously-loaded custom UNET in memory. The model stayed
on the override and the dropdown looked stuck.

Now detects the transition from a custom selection to Default and
triggers sd_models.load_diffuser() to reload via the canonical
from_pretrained path.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 55db15c213 docs: cleanup 2026-05-31 00:24:33 +01:00
CalamitousFelicitousness a68ae8991d fix(flux2_klein): route through native_transformer with explicit converter
Klein shares Flux2Transformer2DModel with full Flux 2 but uses a
smaller config. from_single_file instantiates with the class default
(= Flux 2 full size); loading a Klein-shaped file crashed at
load_model_dict_into_meta with:

  Cannot load because double_stream_modulation_img.linear.weight
  expected shape (36864, 6144), but got (24576, 4096)

FLUX2_KLEIN_SPEC fetches Klein's transformer/config.json from the base
repo and uses convert_flux2_transformer_checkpoint_to_diffusers
explicitly. Probed against snofsSexNudesAndOtherFunStuff_v14Base:
233/233 keys overlap.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 3368ce95f7 feat(pipelines): wire native_spec for Qwen-Image and custom-class arches
Qwen-Image: diffusers registers a no-op identity lambda for
QwenImageTransformer2DModel; from_single_file silently accepted any
key naming and loaded with mismatches. QWEN_SPEC sets converter=None
to short-circuit the no-op.

Custom transformer classes (Lens, Step1X-Edit, VIBE Sana, f-lite):
runtime-registered onto diffusers, never in SINGLE_FILE_LOADABLE_CLASSES.
Specs land in each arch's existing pipelines/<arch>/__init__.py.

NextStep skipped: loader returns None up front.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness e302518d73 feat(pipelines): wire native_spec for arches without from_single_file
CogView3+, CogView4, GLM-Image, HunyuanDiT, Joy, Kandinsky3 UNet,
PixArt, PRX. These classes lack from_single_file entirely; the UNET
dropdown fell through to cls.from_pretrained(local_file), which
decodes the .safetensors header as UTF-8 and crashes "is not a valid
JSON file".

TransformerSpec(cls=...) module-level in each model_<arch>.py.
Kandinsky3 also needs subfolder='unet' since it loads a UNet not a
transformer.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness e7d2e28d3d feat(pipelines): wire native_spec for arches missing single_file_model entry
ChronoEdit, HunyuanImage, Kandinsky5, LongCat, Ovis, NucleusMoE, Bria,
BriaFibo. Each inherits from_single_file via FromOriginalModelMixin
but has no SINGLE_FILE_LOADABLE_CLASSES entry; calling it crashed with
"FromOriginalModelMixin is currently only compatible with [...]".

TransformerSpec(cls=...) for each. Bria specs in
pipelines/bria/__init__.py; the rest are module-level in
model_<arch>.py since they have no package directory.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness d01d637d94 refactor(wanai): retire bespoke load_transformer, route through generic
The 40-line hand-rolled loader was generic.load_transformer plus a
VACE/standard class switch and a hardcoded GGUF rejection. Switch moves
to load_wan; GGUF rejection removed (generic handles it via
GGUFQuantizationConfig).

No native_spec passed: WanTransformer3DModel has a working diffusers
converter, so from_single_file via generic stays correct.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness b681cccccb feat(ernie): register ERNIE_SPEC for native dispatch
ErnieImageTransformer2DModel has no from_single_file; selecting an
Ernie finetune in the UNET dropdown previously crashed with
"is not a valid JSON file" from from_pretrained.

Probe of jibMixErnie_v20.safetensors: 409/409 keys overlap with the
model state dict after stripping model.diffusion_model., zero missing
or unexpected. Spec is the minimum TransformerSpec(cls=...).
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 98fba8ddc3 feat(pipelines): wire native_spec dispatch in generic.load_transformer
New native_spec=None kwarg. When set and the UNET dropdown points at a
.safetensors, dispatches to native_transformer.load (threading
allow_quant/dtype/modules_to_not_convert/modules_dtype_dict). Pipelines
without a spec stay on cls.from_single_file unchanged.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness cec6d0dce5 refactor(anima): port anima_transformer to native_transformer
217-line bespoke loader collapses to a 40-line ANIMA_SPEC in
pipelines/anima/__init__.py (Cosmos converter + llm_adapter sibling +
Cosmos 1.0 forbidden marker).

Drop the class-keyed REGISTRY: Anima and raw Cosmos share
CosmosTransformer3DModel but need different specs. Specs pass via
explicit native_spec= kwarg; make_default_spec(cls) covers the
auto-converter case.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 08ad6196d0 feat(pipelines): add native_transformer for single-file DiT loading
Read .safetensors, strip prefix, partition siblings, run optional
converter, from_config + load_state_dict + validate, dtype/quant/offload.
Per-arch knobs via TransformerSpec(cls, subfolder, prefixes, converter,
siblings, acceptable_missing, forbidden_markers). SiblingSpec covers
bundled components like Anima's llm_adapter. 36 offline tests.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 5b321d2071 refactor(lora): update importers for native_adapter rename
5 pipeline files + 2 test files. Mechanical substitution. 141/141
adapter tests pass.
2026-05-31 00:24:33 +01:00
CalamitousFelicitousness 7cd6b6be79 refactor(lora): rename native_loader to native_adapter
Frees the name for pipelines/native_transformer. Module covers the full
LyCORIS adapter family (LoRA/LoKR/LoHA/OFT/IA3/GLoRA/Norm/Full), not
just LoRA.
2026-05-31 00:24:33 +01:00
Vladimir Mandic a0531c70fd add new attention dispatcher
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-29 21:10:56 +02:00
Vladimir Mandic d2d9f7caea captioning improvements and cleanup
Signed-off-by: Vladimir Mandic <mandic00@live.com>
2026-05-29 21:10:56 +02:00
Vladimir Mandic e9be7e929f Merge pull request #4881 from liutyi/dev
fix clean ipex install error and community ZIT models covers
2026-05-29 18:03:42 +02:00
Oleksandr Liutyi 964ae59078 fix resonantsky models paths, regenerate preview with metadata 2026-05-29 12:42:02 +00:00