Simple use of a/Mflux in ComfyUI, suitable for users who are not familiar with terminal usage. NOTE: A MLX port of FLUX based on the Huggingface Diffusers implementation.
Simple use of Mflux in ComfyUI, suitable for users who are not familiar with terminal usage. Only for MacOS.
Thanks to the developers of the mflux project, especially the initiator @filipstrand and active contributor @anthonywu, for making it easier and more efficient for Mac users to generate flux model images. These contributions are truly delightful—thank you!
mflux:
https://github.com/filipstrand/mflux
Thanks also to @CharafChnioune, the author of MFLUX-WEBUI, from whom I partially referenced some code. In compliance with the Apache 2.0 license used in his project, I have added license comments in the referenced sections of my code.
cd /path/to/your_ComfyUI
cd custom_nodes
git clone https://github.com/raysers/Mflux-ComfyUI.git
pip install mflux==0.4.1
Alternatively, you can search for "Mflux-ComfyUI" in ComfyUI-Manager for a quick installation.
This is the first time other contributors have participated in updating this plugin. Thanks @InformEthics.
The Quick MFlux Generation node has metadata enabled by default (set to True). This means that the generated images will be automatically saved under ComfyUI/output/Mflux, along with a JSON file that shares the same name as the image.
In the ComfyUI directory, you can also use the mflux-generate --config-from-metadata command to load a JSON file and use the original mflux to generate images.
Example:
The advantage of the original version is its clean memory management: it automatically releases memory after each generation, as can be observed in the Activity Monitor.
If you'd like to experience the original mflux, this provides an additional option.
mflux has been updated to version 0.4.1. To experience image-to-image generation, please upgrade in ComfyUI with:
pip install --upgrade mflux
Right-click to create nodes:
Under MFlux/Air:
Under MFlux/Pro:
Or double-click in the blank area of the canvas to bring up the node search box, and directly search for the node names by the keyword “Mflux.”
Quantized Models:
ComfyUI/models/Mflux
LoRA:
ComfyUI/models/loras
I usually create an Mflux folder under models/loras to manage the LoRAs compatible with Mflux, storing them uniformly. Therefore, in my example, the retrieved files should be Mflux/*******.safetensors.
Native Full Models & ControlNet:
Yourusername/.cache
Although the current node Mflux Models Downloader can automatically download, I would still like to share a few links to quantized models as a token of appreciation:
Of course, there are also the most important native full models from Black Forest:
Additionally, here is the FLUX.1-dev-Controlnet-Canny model from the InstantX team:
This basic workflow will download the full versions of dev or schnell to .cache
from Hugging Face, both of which are over 33GB and may put a strain on hard drive space.
Of course, using quantized models will greatly save hard drive space. If you want to use quantized models, you can directly connect to the Mflux Models Downloader node to download quantized models from Hugging Face, such as:
Alternatively, you can use the full version of the Black Forest model that is pre-existing in .cache
to create your custom model through Mflux Custom Models:
For instance, the default quantized version, which is the same as the basic quantized model downloaded from Hugging Face:
Or the LoRA stacked version, which allows for quantization after stacking LoRAs, thereby creating a unique model:
The drawback of this LoRA custom model is that it essentially remains a quantized model. If you try to stack LoRAs again in Quick MFlux Generation, it will result in an error.
Here, we can extract a mutual exclusion rule: LoRAs and quantized models cannot be used simultaneously; you can only choose one. To achieve the best of both worlds, you can only generate a LoRA custom model through this pre-quantization stacking.
However, if you want to quickly generate multiple images in the same LoRA style and your machine configuration is not very high (for example, mine has 16GB), using this method can serve as a compromise for achieving LoRA results. You can delete this unique model once the generation is complete.
Note that the custom_identifier
in the Mflux Custom Models node is not a mandatory field. If you do not need a specific identifier for distinction, you can leave it empty.
Whether you are downloading models from Hugging Face or creating custom models, they only need to be run once. As long as you save the model, you can use the Mflux Models Loader node to retrieve them, such as:
This update also adds the option to manually input paths. Alternatively, you can clear the models/Mflux folder, which will show "NONE" in the selection list, and then you can enter your own model path in free_path
.
I am still exploring the specific usage methods. If you have experiences worth sharing, please feel free to start a discussion in the issues.
In the image, two Mflux Loras Loader nodes are used just to illustrate that they can be chained together, meaning you can theoretically load countless LoRAs...
Please note that you cannot use the Mflux Models Loader node to load quantized models when using LoRAs; doing so will result in an error. This further verifies the mutual exclusion rule mentioned above.
Perhaps one day the official team will resolve this error; let's wait patiently.
Note:
Not all LoRAs are compatible with Mflux. Please check the official homepage for specific compatible types:
https://github.com/filipstrand/mflux
Therefore, I typically create an Mflux folder under models/loras to store all LoRAs compatible with Mflux in one place.
Mflux's ControlNet currently only supports Canny.
P.S. To quickly generate example images, I created a custom model using a 4-step LoRA from the dev model.
The advantage of this 4-step LoRA model is that it still belongs to the DEV model, so the Guidance parameter can be effective, and it can produce images in just four steps while retaining the advantages of schnell.
A must-have for English beginners.
Image reverse generation, using the MiaoshouAI/Florence-2-large-PromptGen-v1.5 visual model here.
All these processes can be dragged directly into ComfyUI from the workflows folder.
!!! If nodes are highlighted in red, use ComfyUI-Manager's "One-click Install Missing Nodes." !!! Please note that all processes at the end use preview nodes, which do not automatically save. You need to manually save the generated images you are satisfied with or simply replace the preview nodes with save nodes.
......
......
Here, I hope everyone shares their workflows more, fully promoting the spirit of sharing on the internet. Knowledge for payment? No, I advocate cooperation and sharing for mutual benefit.
Official Website Overview of Mflux 0.4.x Features:
Previous updates have already completed the Img2Img functionality. Additionally, MFlux 0.4.x introduced a keyboard interruption feature, which was implemented in the last update using ComfyUI's cancel button.
This update focuses on completing the functionality to generate images from metadata.
The next step is to complete the implementation of the remaining features as much as possible.
Please pay attention to the official website:
https://github.com/filipstrand/mflux
Interactive communication is all a contribution.
I would like to adopt the MIT License consistent with the Mflux project, contributing my part to the open-source community.