Skip to main content

mflux-CV

A drop-in community build of mflux by Filip Strand (MIT). It stays current with upstream main and adds a curated set of fixes, training features, and useful community PRs, with prebuilt wheels on GitHub Releases so improvements are easy to pick up between upstream releases. The Python package is still mflux and every CLI keeps its name, so this is a direct replacement in ComfyUI, image-studio, or any existing setup.

Install

pip install mflux-cv

To track a specific tag instead, or to pick up work that has not been released yet:

pip install git+https://github.com/HowDidTheCatGetSoFat/mflux-cv.git@v.0.18.25-CV

Wheels are also attached to every Release.

Install this or upstream mflux, never both. The distribution is named mflux-cv so it can live on PyPI alongside upstream, though both provide the same mflux import package. With both installed, pip raises no error while the two overwrite each other's files, and uninstalling either one leaves the other broken. Run pip uninstall mflux before installing this, and pip uninstall mflux-cv before going back.

Relationship to upstream: kept rebased on filipstrand/mflux so changes merge back cleanly. Every upstream commit is included and nothing is removed. Credit for the base project and every pulled PR goes to their authors.

Changelog (on top of upstream 0.18.0)

0.18.26-CV

  • Z-Image Turbo Union ControlNet, native in MLX. The first Z-Image ControlNet running in MLX, with all five modalities computed locally (no pre-made control image needed):

    mflux-generate-z-image-controlnet \
        --control canny:room.png:1.0 --controlnet-strength 0.6 \
        --prompt "a cozy bedroom, photorealistic" --steps 8 --output out.png
    

    --control type:path[:strength] is repeatable to stack controls. Types: canny, mlsd, depth, hed, pose.

  • Preprocessors: canny and mlsd via OpenCV, depth via the native DepthPro mflux already ships, and native mlx.nn ports of hed (ControlNetHED) and pose (OpenPose body). Only weight loading touches torch; every forward pass is MLX.

  • The controlnet inference is numerically matched to the diffusers ZImageControlNetModel (block-by-block residual cosine 1.00000). A correctness fix carries the refined control tokens into the main control layers, which the original port dropped.

0.18.25-CV

  • Multi-ControlNet for FLUX.1. Several controlnets can now be stacked, each with its own checkpoint, control image and strength (for example depth + canny). Repeat --controlnet-path and --controlnet-image-path (and optionally --controlnet-strength, or give one value for all):

    mflux-generate-controlnet -m dev --prompt "a modern living room" \
        --controlnet-path org/depth --controlnet-image-path depth.png --controlnet-strength 0.7 \
        --controlnet-path org/canny --controlnet-image-path canny.png --controlnet-strength 0.4
    

    The residual path is additive, so each net's residuals are spread over the transformer's blocks with the rule the transformer already applies and then summed. Controlnets with different block counts stack correctly, and a single controlnet renders exactly as before (the expansion reproduces the transformer's own selection index for index, which is pinned by a test).

  • --controlnet-path is new: it selects a controlnet checkpoint (local path or HF repo) instead of the one named by the model config, which also makes Flux1Controlnet(controlnet_path=...) work. It was previously accepted by the constructor and silently ignored.

  • A single --controlnet-image-path / --controlnet-strength keeps its scalar shape, so existing commands and the metadata round-trip are unchanged.

  • Canny preprocessing is decided per controlnet, from that net's own checkpoint name (the same match is_canny() makes). A depth + canny stack therefore preprocesses only the canny image, and a config-driven canny run behaves exactly as before.

  • Known limitation: the image metadata holds a single controlnet, so a stacked run records only its first net there. Metadata-driven re-runs of a stack are not supported; pass the flags explicitly. Single-controlnet metadata is unchanged.

0.18.24-CV

  • FLUX.2-klein now exposes flux2-klein-edit / flux2-edit / klein-edit aliases (it does txt2img and edit from the same weights), so the edit variant is selectable by name — used by the ComfyUI-mflux-AnyModel node.
  • Qwen-Image-Edit: skip the unconditional pass at guidance 1.0 (it reduces to the conditional noise there), halving per-step compute for CFG-distilled setups like the Lightning step-reduction LoRAs.

0.18.23-CV

  • Updated the default Qwen models to the latest releases (based on #475's sibling, #474, credited under Community PRs pulled in): qwen-image now loads Qwen-Image-2512 and qwen-image-edit loads Qwen-Image-Edit-2511. The architecture is identical to the prior releases, so they are drop-in; both were validated end-to-end on Apple Silicon. Unlike the upstream PR, the old qwen-edit-2509 alias still resolves to the actual 2509 weights (kept as its own entry) instead of silently pointing at the new default.

0.18.22-CV

  • Pulled in configurable VAE decode tiling (#475, credited under Community PRs pulled in): --vae-tiling / --vae-tile-size decouple tiled decoding from full low-RAM mode, so you can cut peak memory on large generations without the rest of the low-RAM penalty.

0.18.21-CV

  • Krea 2 depth ControlNet: fix the estimated-depth convention (Depth Pro already outputs near = white, like Depth-Anything-V2, so its map is now used un-inverted — an earlier inversion put the background in front). --save-depth-map now writes the estimated map (<output>_depth_map.png).

0.18.20-CV

  • Krea 2 depth ControlNet now supports quantization (-q 8 / -q 4): the control deltas are baked into the base weights before quantization, so the packed model keeps the depth control. Validated end-to-end at int8.

0.18.19-CV

  • New: Krea 2 depth ControlNet (mflux-generate-krea2-controlnet). Runs the community Krea-2-controlnet depth checkpoint natively in MLX: the input projection is widened to take a depth latent concatenated on the channel axis, and the attention/MLP deltas are merged into the base weights. Depth is taken from a supplied map (--depth-image-path) or estimated with the native Depth Pro. See the Krea 2 depth ControlNet section below.

0.18.18-CV

  • Pulled in two new upstream models (credited under Community PRs pulled in): Boogu-Image-0.1-Turbo (#446, mflux-generate-boogu) and Qwen-Image-Layered (#302, mflux-generate-qwen-layered) for decomposing an image into RGBA layers.

0.18.17-CV

  • Pulled in Ideogram 4 mlx-forge checkpoint loading (#445) and mixed-quant FLUX.2 inference (#436), both credited under Community PRs pulled in.

0.18.16-CV

  • Pulled in two upstream bug fixes (credited under Community PRs pulled in): fused-qkv LoRA loading (#459) and ERNIE / Krea 2 tiled img2img (#463).
  • Repo automation: CodeQL security scanning, structured issue forms, and PR / issue auto-labeling.

0.18.15-CV

First release under the mflux-CV name, in the community home at HowDidTheCatGetSoFat/mflux-cv. Same codebase as the prior +fxd0h builds (0.18.1 through 0.18.5); this is the rebrand plus everything listed below.

0.18.5

  • Krea 2 --krea2-uncensor <k>: scales the text-fusion projector's refusal layers (tapped Qwen3-VL 9/10/11) so explicit prompts render instead of being dodged. k=1 is off, ~6 neutralises the filter.

0.18.4

  • LoRA on quantized bases: keep the adapter live at inference instead of baking it into the quantized weights (baking re-quantized and badly diverged the output on the --quantize default).
  • LoKr: load LyCORIS LoKr adapters for Krea 2, Qwen, and Ideogram 4.
  • Ideogram 4: fix the stepwise-preview VAE decode crash on already-unpacked latents; guard the injected-LoRA scan against transformers without named_modules.
  • Krea 2 Raw: download the diffusers transformer from HuggingFace.
  • z-image: shared --saveinfo filename builder; fix numeric-tag collisions.
  • qwen-edit: clearer error on empty image_paths; regenerated golden references.

0.18.3

  • Review fixes: fp8-aware fused DoRA, training guards (LR, grad-accum reset on skip, qwen VAE flag), route the CFG negative through an injected LoRA in training previews, surface LoRA bake failures on save, EMA resume from live weights.

0.18.2

  • Krea 2 sigma schedule: use the official dynamic exponential shift instead of a linear 1.15.

0.18.1

  • Training suite: DoRA (weight-decomposed LoRA) for Krea 2, Ideogram 4, z-image, flux, flux2; gradient accumulation; EMA of trained weights; caption dropout; masked loss; regularization / prior-preservation images; continue training from an existing LoRA; non-finite-step guard; utf-8-safe captions; free training-loss plot.
  • Krea 2: LoRA training, Raw variant, and diffusers-format loading.

Community PRs pulled in

  • filipstrand/mflux#459 by Sahil Tanveer — fix LoRA loading for fused qkv layers: keep the shared rank/down projection whole and slice only the up projection, so kohya/BFL FLUX LoRAs with a rank divisible by 3/4 load correctly.
  • filipstrand/mflux#463 by Mike Wallio — fix ERNIE and Krea 2 img2img with tiled VAE latents: the 5D tiled-VAE pack path took the wrong slice; keep the singleton temporal axis so tiled-decode img2img reconstructs correctly.
  • filipstrand/mflux#445 by plz12345 — load Ideogram 4 from mlx-forge converted checkpoints (bf16 / int8) by HF repo id, skipping the fp8-only validation; plus a once-built boolean attention keep-mask. Merged with our gradient-checkpointing.
  • filipstrand/mflux#436 by Ian Scrivener — mixed-quant inference for FLUX.2: quantize the transformer and text encoder to different levels, or load each from its own path (--model-transformer / --model-text-encoder); the VAE stays bf16. Merged alongside our LoKr flux2 changes.
  • filipstrand/mflux#446 by plz12345 — new model: Boogu-Image-0.1-Turbo (mflux-generate-boogu). Applied cleanly.
  • filipstrand/mflux#302 by ZimengXiong — new model: Qwen-Image-Layered (mflux-generate-qwen-layered) for decomposing an image into RGBA layers, with a low-memory chunked save path. We kept our README; the PR's stale old-structure README changes were dropped.
  • filipstrand/mflux#475 by azrahello — configurable VAE decode tiling: --vae-tiling and --vae-tile-size (min 128, multiple of 16) enable tiled decoding on its own, decoupled from --low-ram, to lower peak memory during the VAE decode phase. Applied cleanly.
  • filipstrand/mflux#474 by imbible — bump the default Qwen models to Qwen-Image-2512 and Qwen-Image-Edit-2511. Both validated generating end-to-end on Apple Silicon (identical architecture, drop-in). We diverged in one place: kept a separate qwen-image-edit-2509 entry so qwen-edit-2509 still resolves to the real 2509 weights instead of the new default.

Krea 2 depth ControlNet

Steer a Krea 2 generation with the depth of a reference image, running natively in MLX. Uses the community Krea-2-controlnet depth checkpoint by Tanmay Patil (base weights: krea/Krea-2-Raw / krea/Krea-2-Turbo).

mflux-generate-krea2-controlnet \
  --model krea2 \
  --controlnet-path /path/to/depth-control-lora.safetensors \
  --image-path reference.png \
  --prompt "a glowing crystal orb on a wooden table, studio photo" \
  --steps 8 --seed 42 --height 1024 --width 1024 \
  --output out.png
  • --image-path estimates depth with the native Depth Pro (near = white, used as-is, the same convention the checkpoint was trained on). Add --save-depth-map to also write the estimated map. For the closest match to the training data, pass a Depth-Anything-V2 map directly with --depth-image-path.
  • --controlnet-strength scales how strongly the control deltas are merged (default 1.0).
  • --krea2-uncensor is supported here too.
  • -q 8 / -q 4 quantize the variant: the control deltas are baked into the base weights before quantization, so the packed model keeps the depth control.

The rest of this file is the upstream mflux documentation.

image

MFLUX MLX CI

About

Run the latest state-of-the-art generative image models locally on your Mac in native MLX!

Table of contents


💡 Philosophy

MFLUX is a line-by-line MLX port of several state-of-the-art generative image models from the Huggingface Diffusers and Huggingface Transformers libraries. All models are implemented from scratch in MLX, using only tokenizers from the Huggingface Transformers library. MFLUX is purposefully kept minimal and explicit, @karpathy style.


💿 Installation

If you haven't already, install uv, then run:

uv tool install --upgrade mflux

After installation, the following command shows all available MFLUX CLI commands:

uv tool list 

To generate your first image using, for example, the z-image-turbo model, run

mflux-generate-z-image-turbo \
  --prompt "A puffin standing on a cliff" \
  --width 1280 \
  --height 500 \
  --seed 42 \
  --steps 9 \
  -q 8

Puffin

The first time you run this, the model will automatically download which can take some time. See the model section for the different options and features, and the common README for shared CLI patterns and examples.

Python API

Create a standalone generate.py script with inline uv dependencies:

#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10"
# dependencies = [
#   "mflux",
# ]
# ///
from mflux.models.z_image import ZImageTurbo

model = ZImageTurbo(quantize=8)
image = model.generate_image(
    prompt="A puffin standing on a cliff",
    seed=42,
    num_inference_steps=9,
    width=1280,
    height=500,
)
image.save("puffin.png")

Run it with:

uv run generate.py

For more Python API inspiration, look at the CLI entry points for the respective models.

⚠️ Troubleshooting: hf_transfer error

If you encounter a ValueError: Fast download using 'hf_transfer' is enabled (HF_HUB_ENABLE_HF_TRANSFER=1) but 'hf_transfer' package is not available, you can install MFLUX with the hf_transfer package included:

uv tool install --upgrade mflux --with hf_transfer

This will enable faster model downloads from Hugging Face.

DGX / NVIDIA (uv tool install)
uv tool install --python 3.13 mflux

🎨 Models

MFLUX supports the following model families. They have different strengths and weaknesses; see each model’s README for full usage details.

Model Release date Size Type Training Description
Mage Flow Jul 2026 8.7B Base, RL & Turbo No Native-resolution generation with natural-language, multi-image editing.
Z-Image Nov 2025 6B Distilled & Base Yes Fast, small, very good quality and realism.
Krea 2 Jun 2026 12B Turbo (distilled) No Very good quality with a wide range of styles; good for creative exploration.
FLUX.2 Jan 2026 4B & 9B Distilled & Base Yes Fastest + smallest with very good qaility and edit capabilities.
Ideogram 4 Jun 2026 9B Base No JSON-caption-native, typography-focused text-to-image generation.
ERNIE-Image Apr 2026 8B Distilled & Base No Single-stream DiT from Baidu. Vivid, high-contrast output.
FIBO Oct 2025+ 8B Distilled & Base No Very good JSON-based prompt understanding. Has edit capabilities.
SeedVR2 Jun 2025 3B & 7B — No Best upscaling model.
Qwen Image Aug 2025+ 20B Base No Large model (slower); strong prompt understanding and world knowledge. Has edit capabilities
Depth Pro Oct 2024 — — No Very fast and accurate depth estimation model from Apple.
FLUX.1 Aug 2024 12B Distilled & Base No (legacy) Legacy option with decent quality. Has edit capabilities with 'Kontext' model and upscaling support via ControlNet

✨ Features

General

  • Quantization and local model loading
  • LoRA support (multi-LoRA, scales, library lookup), including LyCORIS LoKr on FLUX.1 and FLUX.2
  • Metadata export + reuse, plus prompt file support

Model-specific highlights

  • Text-to-image and image-to-image generation.
  • LoRA finetuning
  • In-context editing, multi-image editing, and virtual try-on
  • ControlNet (Canny), depth conditioning, fill/inpainting, and Redux
  • Upscaling (SeedVR2 and Flux ControlNet)
  • Depth map extraction and FIBO prompt tooling (VLM inspire/refine)

See the common README for detailed usage and examples, and use the model section above to browse specific models and capabilities.



🙏 Acknowledgements

MFLUX would not be possible without the great work of:


⚖️ License

This project is licensed under the MIT License.

Metadata

Release files for mflux-cv 0.18.28

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mflux-cv 0.18.28
File Size Uploaded Provenance Actions
mflux_cv-0.18.28.tar.gz 986.7 kB Without provenance Details for mflux_cv-0.18.28.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mflux-cv 0.18.28
File Interpreter ABI Platform Actions
mflux_cv-0.18.28-py3-none-any.whl Python 3 none any Details for mflux_cv-0.18.28-py3-none-any.whl

Total release size: 2.3 MB

Release files / mflux_cv-0.18.28.tar.gz

Download URL mflux_cv-0.18.28.tar.gz
Size 986.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0b1ecd86e23a17331e3e2a07f65e1fb746e124af5bbfda7740f96e31b8c4ea6d
BLAKE2b-256 checksum
How to use checksums
655cd88016bd7a81d20dfe8cde305c8e37b93327b32e9fcbadf3f1b0993211ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Release files / mflux_cv-0.18.28-py3-none-any.whl

Download URL mflux_cv-0.18.28-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
eb9a193b2483e9e0170c68ea1a0e770911ebec36ab1451a47dce2718e7f61d74
BLAKE2b-256 checksum
How to use checksums
e9a2a0935eab49ec0d757db7f96c21e52c00cd303e5c909a025564e119f55505
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.13

Security for mflux-cv 0.18.28

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page