* WIP: Add FLUX.2 Klein LoRA support (BFL PEFT format)
Initial implementation for loading and applying LoRA models trained
with BFL's PEFT format for FLUX.2 Klein transformers.
Changes:
- Add LoRA_Diffusers_Flux2_Config and LoRA_LyCORIS_Flux2_Config
- Add BflPeft format to FluxLoRAFormat taxonomy
- Add flux_bfl_peft_lora_conversion_utils for weight conversion
- Add Flux2KleinLoraLoaderInvocation node
Status: Work in progress - not yet fully tested
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
* feat(flux2): add LoRA support for FLUX.2 Klein models
Add BFL PEFT LoRA support for FLUX.2 Klein, including runtime conversion
of BFL-format keys to diffusers format with fused QKV splitting, improved
detection of Klein 4B LoRAs via MLP ratio check, and frontend graph wiring.
* feat(flux2): detect Klein LoRA variant (4B/9B) and filter by compatibility
Auto-detect FLUX.2 Klein LoRA variant from tensor dimensions during model
probe, warn on variant mismatch at load time, and filter the LoRA picker
to only show variant-compatible LoRAs.
* Chore Ruff
* Chore pnpm
* Fix detection and loading of 3 unrecognized Flux.2 Klein LoRA formats
Three Flux.2 Klein LoRAs were either unrecognized or misclassified due to
format detection gaps:
1. PEFT-wrapped BFL format (base_model.model.* prefix) was not recognized
because the detector only accepted the diffusion_model.* prefix.
2. Klein 4B LoRAs with hidden_size=3072 were misidentified as Flux.1 due to
a break statement exiting the detection loop before txt_in/vector_in
dimensions could be checked.
3. Flux2 native diffusers format (to_qkv_mlp_proj, ff.linear_in) was not
detected because the detector only checked for Flux.1 diffusers keys.
Also handles mixed PEFT/standard LoRA suffix formats within the same file.
---------
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
* Fix bare except clauses and mutable default arguments
Replace bare `except:` with `except Exception:` in sqlite_database.py
and mlsd/utils.py to avoid catching KeyboardInterrupt and SystemExit,
which can prevent graceful shutdowns and mask critical errors (PEP 8
E722).
Replace mutable default arguments (lists) with None in
imwatermark/vendor.py to prevent shared state between calls, which
is a known Python gotcha that can cause subtle bugs when default
mutable objects are modified in place.
* add tests for mutable defaults and bare except fixes
* Simplify exception propagation tests
* Remove unused db initialization in error propagation tests
Removed unused database initialization in tests for KeyboardInterrupt and SystemExit.
---------
Co-authored-by: Jonathan <34005131+JPPhoto@users.noreply.github.com>
Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
* Initial mashup of mentioned feature. Still need to resolve some quirks and kinks.
* Clean text tool integration
* Fixed text tool opions bar jumping and added more fonts
* Touch up for cursor styling
* Minor addition to doc file
* Appeasing frontend checks
* Prettier fix
* knip fixes
* Added safe zones to font selection and color picker to be clickable without commiting text.
* Removed color probing on cursor and added dynamic font display for fallback, minor tweaks
* Finally fixed the text shifting on commit
* Cursor now represent actual input field size. Tidy up options UI
* Some strikethrough and underline line tweaks
* Replaced the focus retry loop with a callback‑ref based approach in in CanvasTextOverlay.tsx
Renamed containerMetrics to textContainerData in CanvasTextOverlay.tsx
Fixed mouse cursor disapearing during typing.
* Added missing localistaion string
* Moved canvas-text-tool.md to docs/contributing/frontend
* ui: Improve functionality of the text toolbar
Few things done with this commit.
- The varying size of the font selector box has been fixed. The UI no longer shifts and moves with font change.
- We no longer format the font size input to add px each time. Instead now just have a permanent px indicator.
- The bug with the random text inputs on the slider value has also been fixed.
- The font size value is only committed on blur keeping it consistent with other editing apps.
- Fixed the spacing of the toolbar to make it look cleaner.
- Font size now permits increments of 1.
* Added autoselect text in font size on click allowing immediate imput
* Improvement: Added uncommited layer state with CTRL-move and options to select line spacing.
* Added rotation handle to rotate uncommiitted text layer.
* Fix: Redirect user facing labels to use localization file + Add tool discription to docs
* Fixed box padding. Disable tool swich when text input is active, added message on canvas for better UX.
* Updated Text tool description
* Updated Text tool description
* Typo
* Add draggable text-box border with improved cursor feedback and larger hit targets. Supress hotkeys on uncommitted text.
* Lint
* Fix(bug): text commit to link uploaded image assets instead of embedding full base64
---------
Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
Co-authored-by: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com>
* feat(z-image): add Z-Image Base (undistilled) model variant support
- Add ZImageVariantType enum with 'turbo' and 'zbase' variants
- Auto-detect variant on import via scheduler_config.json shift value (3.0=turbo, 6.0=zbase)
- Add database migration to populate variant field for existing Z-Image models
- Re-add LCM scheduler with variant-aware filtering (LCM hidden for zbase)
- Auto-reset scheduler to Euler when switching to zbase model if LCM selected
- Update frontend to show/hide LCM option based on model variant
- Add toast notification when scheduler is auto-reset
Z-Image Base models are undistilled and require more steps (28-50) with higher
guidance (3.0-5.0), while Z-Image Turbo is distilled for ~8 steps with CFG 1.0.
LCM scheduler only works with distilled (Turbo) models.
* Chore ruff format
* Chore fix windows path
* feat(z-image): filter LoRAs by variant compatibility and warn on mismatch
LoRA picker now hides Z-Image LoRAs with incompatible variants (e.g. ZBase
LoRAs when using Turbo model). LoRAs without a variant are always shown.
Backend loaders warn at runtime if a LoRA variant doesn't match the
transformer variant.
* Chore typegen
---------
Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
The FLUX.2 Klein transformer operates in BN-normalized latent space,
but init_latents from VAE encode were not being normalized before
being passed to the InpaintExtension. This caused a scale mismatch
when merging intermediate_latents (normalized) with noised_init_latents
(unnormalized), resulting in visible artifacts at mask blur boundaries.
Now normalize:
- init_latents_packed before passing to InpaintExtension
- noise_packed for correct interpolation in normalized space
- x (starting latents) for img2img/inpainting workflows
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
Co-authored-by: Jonathan <34005131+JPPhoto@users.noreply.github.com>
* feat(canvas): add raster layer blend modes and boolean operations submenu; support per-layer globalCompositeOperation in compositor; UI to toggle and select color blend modes (multiply, screen, darken, lighten, color-dodge, color-burn, hard-light, soft-light, difference, hue, saturation, color, luminosity).
* feat(canvas): boolean ops submenu and UI polish
* (chore): prettier lint
* add icons to boolean submenu items
* add delete button for color blend operations
* move composite operation type and imports
* chore: pnpm eslint
* update blend modes order
* update default blend mode to 'color'
* add i18n for blend modes
* actually use translations for blend modes now
* move composite options into types.ts
* cleanup and comments
* update names
* move constant mapping out of function
* feat(ui): Refactor Blend Mode Implementation
- Blend Modes are not right click menu options anymore. Instead they rest above the layer panel as they do in other art programs readily available for each layer.
- Blend Modes have been resorted to match the listings of other art programs so users can avail their muscle memory.
- Blend Mode now defaults to `Normal` for each layer as it should.
- The extra layer operations have now been moved down to the `Operations Bar` at the bottom of the layer stack. This is to increase familiarity again with other art programs and also to make space for us in the top action bar.
- The Operations Bars operations have been resorted in order of usage that makes sense.
* fix: use source-over instead of normal
* fix: pixel fix for slightly offset action bar labels.
* feat(canvas): boolean raster merge creates new layer and disables sources
* (fix) lint errors
* remove extra typecast
---------
Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
Co-authored-by: blessedcoolant <54517381+blessedcoolant@users.noreply.github.com>
* Add script and UI to remove orphaned model files
- This commit adds command-line and Web GUI functionality for
identifying and optionally removing models in the models directory
that are not referenced in the database.
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
* Add backend service and API routes for orphaned models sync
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
Add expandable file list to orphaned models dialog
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
* Fix cache invalidation after deleting orphaned models
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
* (bugfix) improve status messages
* docs(backend): add info on the orphaned model detection/removal feature
* Update docs/features/orphaned_model_removal.md
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: lstein <111189+lstein@users.noreply.github.com>
Co-authored-by: dunkeroni <dunkeroni@gmail.com>
* fix(flux2): Fix image quality degradation at resolutions > 1024x1024
This commit addresses severe quality degradation and artifacts when
generating images larger than 1024x1024 with FLUX.2 Klein models.
Root causes fixed:
1. Dynamic max_image_seq_len in scheduler (flux2_denoise.py)
- Previously hardcoded to 4096 (1024x1024 only)
- Now dynamically calculated based on actual resolution
- Allows proper schedule shifting at all resolutions
2. Smoothed mu calculation discontinuity (sampling_utils.py)
- Eliminated 40-50% mu value drop at seq_len 4300 threshold
- Implemented smooth cosine interpolation (4096-4500 transition zone)
- Gradual blend between low-res and high-res formulas
Impact:
- FLUX.2 Klein 9B: Major quality improvement at high resolutions
- FLUX.2 Klein 4B: Improved quality at high resolutions
- Baseline 1024x1024: Unchanged (no regression)
- All generation modes: T2I and Kontext (reference images)
Fixes: Community-reported quality degradation issue
See: Discord discussions in #garbage-bin and #devchat
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
* fix(flux2): Fix high-resolution quality degradation for FLUX.2 Klein
Fixes grid/diamond artifacts and color loss at resolutions > 1024x1024.
Root causes identified and fixed:
- BN normalization was incorrectly applied to random noise input
(diffusers only normalizes image latents from VAE.encode)
- BN denormalization must be applied to output before VAE decode
- mu parameter was resolution-dependent causing over-shifted schedules
at high resolutions (now fixed to 2.02, matching ComfyUI)
Changes:
- Remove BN normalization on noise input (not needed for N(0,1) noise)
- Preserve BN denormalization on denoised output (required for VAE)
- Fix mu to constant 2.02 for all resolutions (matches ComfyUI)
Tested at 2048x2048 with FLUX.2 Klein 4B
* Chore Ruff
---------
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: Jonathan <34005131+JPPhoto@users.noreply.github.com>
The ParamFluxDypePreset component was rendered twice in the FLUX
generation settings accordion, causing the DyPE dropdown to appear
both after the scheduler and after the guidance slider.
Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
setting with hardcoded full denoising (start=0, end=1) in addOutpaint.
This caused denoising strength to be completely ignored whenever the
canvas bbox extended beyond the raster layer content, triggering outpaint
mode. The issue affected all model types (SDXL, SD1.5, FLUX, etc.).
Restore the original behavior by reading denoising_start/end from the
user's img2imgStrength setting via getDenoisingStartAndEnd().
Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
When recalling an image that lacks `z_image_seed_variance_enabled` metadata
(e.g. older images), the toggle now defaults to off instead of retaining the
previous state.
* Switched to use v5.x gallery pagination design.
* Improved pagination UX and gallery grid calculation
* Minor bug fix
* Formatting...
* Fixed Jump to page input behavior and "Locate in gallery" logic.
* Changed Jump input field to select text on click for better UX.
Use useFlux1VAEModels() instead of useFluxVAEModels() in the FLUX VAE
selector, which was incorrectly returning both FLUX.1 and FLUX.2 VAEs.
Remove the now-unused useFluxVAEModels hook.
Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
* fix(flux2): support Heun scheduler for FLUX.2 Klein models
FlowMatchHeunDiscreteScheduler does not support dynamic shifting parameters
(use_dynamic_shifting, base_shift, max_shift, etc.) or sigmas/mu in set_timesteps.
This caused FLUX.2 Klein to fail when using Heun scheduler.
- Create Heun scheduler with only num_train_timesteps and shift parameters
- Use num_inference_steps instead of sigmas for Heun's set_timesteps call
- Euler and LCM schedulers continue to use full dynamic shifting support
* fix(flux2): fix Heun scheduler detection using inspect.signature
The previous hasattr check for state_in_first_order failed because
the attribute doesn't exist before set_timesteps() is called. Now
using inspect.signature to check for sigmas parameter support,
matching the FLUX1 implementation.
---------
Co-authored-by: Jonathan <34005131+JPPhoto@users.noreply.github.com>
* Implemented ordering for expanded iterators
* Update test_graph_execution_state.py
Added a test for nested iterator execution ordering. (Failing at commit time!)
* Filter invalid nested-iterator parent mappings in _prepare()
When a graph has nested iterators, some "ready to run" node combinations do not actually belong together. Previously, the scheduler would still try to build nodes for those mismatched combinations, which could cause the same work to run more than once. This change skips any combination that is missing a valid iterator parent, so nested iterator expansions run once per intended item.
* Fixed Collect node ordering
* ruff
* Removed ordering guarantees from test_node_graph.py
* Fix iterator prep and type compatibility in graph execution
Include iterator nodes in nx_graph_flat so iterators are prepared/expanded correctly. Fix connection type checks to allow subclass-to-base via issubclass. Harden iterator/collector validation to fail cleanly instead of crashing on missing edges. Remove unused nx_graph_with_data(). Added tests to verify proper functionality.
* feat(model_manager): add missing models filter to Model Manager
Adds the ability to view and manage orphaned model database entries
where the underlying files have been deleted externally.
Changes:
- Add GET /v2/models/missing API endpoint to list models with missing files
- Add "Missing Files" filter option to Model Manager type filter dropdown
- Display "Missing Files" badge on models with missing files in the list
- Automatically exclude missing models from model selection dropdowns
to prevent users from selecting unavailable models for generation
* fix(ui): enable Select All checkbox for missing models filter
The Select All checkbox was disabled when the missing models filter was
active because the bulk actions component didn't use the missing models
query data. Now it correctly uses useGetMissingModelsQuery when the
filter is set to 'missing'.
* test(model_manager): add tests for missing model detection and bulk delete
Tests _scan_for_missing_models and the unregister/delete workflow for
models whose files have been removed externally.
* Chore Ruff check
When switching between FLUX.2 (model-less reference images) and other
models that require IP adapter/Redux models, the reference image configs
were not being converted, leaving stale config types that hid or showed
the wrong UI controls.
Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
The scheduler dropdown is no longer shown for FLUX.2 Klein models.
The backend default (Euler) is used instead.
Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
* fix(ui): improve DyPE field ordering and add 'On' preset option
- Add ui_order to DyPE fields (100, 101, 102) to group them at bottom of node
- Change DyPEPreset from Enum to Literal type for proper frontend dropdown support
- Add ui_choice_labels for human-readable dropdown options
- Add new 'On' preset to enable DyPE regardless of resolution
- Fix frontend input field sorting to respect ui_order (unordered first, then ordered)
- Bump flux_denoise node version to 4.4.0
* Chore Ruff check fix
* fix(flux): remove .value from dype_preset logging
DyPEPreset is now a Literal type (string) instead of an Enum,
so .value is no longer needed.
* fix(tests): update DyPE tests for Literal type change
Update test imports and assertions to use string constants
instead of Enum attributes since DyPEPreset is now a Literal type.
* feat(flux): add DyPE scale and exponent controls to Linear UI
- Add dype_scale (λs) and dype_exponent (λt) sliders to generation settings
- Add Zod schemas and parameter types for DyPE scale/exponent
- Pass custom values from Linear UI to flux_denoise node
- Fix bug where DyPE was enabled even when preset was "off"
- Add enhanced logging showing all DyPE parameters when enabled
* fix(flux): apply DyPE scale/exponent and add metadata recall
- Fix DyPE scale and exponent parameters not being applied in frequency
computation (compute_vision_yarn_freqs, compute_yarn_freqs now call
get_timestep_mscale)
- Add metadata handlers for dype_scale and dype_exponent to enable
recall from generated images
- Add i18n translations referencing existing parameter labels
* fix(flux): apply DyPE scale/exponent and add metadata recall
- Fix DyPE scale and exponent parameters not being applied in frequency
computation (compute_vision_yarn_freqs, compute_yarn_freqs now call
get_timestep_mscale)
- Add metadata handlers for dype_scale and dype_exponent to enable
recall from generated images
- Add i18n translations referencing existing parameter labels
* feat(ui): show DyPE scale/exponent only when preset is "on"
- Hide scale/exponent controls in UI when preset is not "on"
- Only parse/recall scale/exponent from metadata when preset is "on"
- Prevents confusion where custom values override preset behavior
* fix(dype): only allow custom scale/exponent with 'on' preset
Presets (auto, 4k) now use their predefined values and ignore
any custom_scale/custom_exponent parameters. Only the 'on' preset
allows manual override of these values.
This matches the frontend UI behavior where the scale/exponent
fields are only shown when 'On' is selected.
* refactor(dype): rename 'on' preset to 'manual'
Rename the 'on' DyPE preset to 'manual' to better reflect its purpose:
allowing users to manually configure scale and exponent values.
Updated in:
- Backend presets (DYPE_PRESET_ON -> DYPE_PRESET_MANUAL)
- Frontend UI labels and options
- Redux slice type definitions
- Zod schema validation
- Tests
* refactor(dype): rename 'on' preset to 'manual'
Rename the 'on' DyPE preset to 'manual' to better reflect its purpose:
allowing users to manually configure scale and exponent values.
Updated in:
- Backend presets (DYPE_PRESET_ON -> DYPE_PRESET_MANUAL)
- Frontend UI labels and options
- Redux slice type definitions
- Zod schema validation
- Tests
* fix(dype): update remaining 'on' references to 'manual'
- Update docstrings, comments, and error messages to use 'manual' preset name
- Simplify FLUX graph builder to always send dype_scale/dype_exponent
- Fix UI condition to show DyPE controls for 'manual' preset
---------
Co-authored-by: Jonathan <34005131+JPPhoto@users.noreply.github.com>
Co-authored-by: Lincoln Stein <lincoln.stein@gmail.com>
* release(docker): fix workflow edge case that prevented CUDA build from completing
* bugfix(release): fix yaml syntax error
* bugfix(CI/CD): fix similar problem in typegen check