π IMPORTANT: This is now an API-only version!
- β Gradio UI has been removed
- β REST API only - All functionality via HTTP endpoints
- β FLUX.2 models: Klein + base + dev (Flux1 removed)
- π See API.md for complete API documentation
A REST API server for FLUX.2 image generation on Apple Silicon using MLX.
pip install -r requirements.txt# Default (0.0.0.0:7861)
python api_main.py
# Custom host/port
python api_main.py --host 127.0.0.1 --port 8080
# Using environment variables
MFLUX_API_PORT=9000 python api_main.pycurl -X POST http://localhost:7861/sdapi/v1/txt2img \
-H "Content-Type: application/json" \
-d '{
"prompt": "a beautiful sunset over mountains",
"model": "flux2-klein-4b",
"steps": 4
}'- Complete API Docs: API.md
- Base URL:
http://localhost:7861 - Supported Models: FLUX.2 Klein (4B/9B), base, and experimental dev (Flux1 removed)
If you were using the UI version:
- UI is removed - Use API endpoints instead
- Flux1 models removed - Use
flux2-klein-4borflux2-klein-9b - See API.md for endpoint mapping (e.g., UI "Generate" button β
POST /sdapi/v1/txt2img) - Old UI code archived in
legacy/directory
flux2-klein-4b(default) - Distilled 4B model (guidance fixed at 1.0)flux2-klein-4b-mlx-4bit- Pre-quantized 4-bitflux2-klein-4b-mlx-8bit- Pre-quantized 8-bitflux2-klein-9b- Distilled 9B model (highest quality; guidance fixed at 1.0)flux2-klein-9b-mlx-4bit- Pre-quantized 4-bitflux2-klein-9b-mlx-8bit- Pre-quantized 8-bitflux2-klein-base-4b- Base 4B model (guidance > 1.0 supported)flux2-klein-base-4b-mlx-4bit- Pre-quantized 4-bitflux2-klein-base-4b-mlx-8bit- Pre-quantized 8-bitflux2-klein-base-9b- Base 9B model (guidance > 1.0 supported)flux2-dev- Experimental FLUX.2-dev (very large; high-RAM machines only)- All models support runtime quantization (3/4/6/8-bit).
Note: Distilled FLUX.2 Klein models use fixed guidance=1.0. Base models (and flux2-dev) allow guidance > 1.0.
Note: The information below describes the legacy UI version. This functionality is now available via REST API endpoints. See API.md for current usage.
MFLUX WebUI was a comprehensive interface for the MFLUX 0.16.x image generation library. It provided an intuitive way to interact with MFLUX models, from one-click "easy" generation to specialized tools with advanced workflow management and intelligent prompt processing.
- πΌοΈ Simple and advanced text-to-image generation
- π¨ Image-to-Image transformation
- ποΈ Fill Tool (Inpaint/Outpaint)
- π Depth Tool with depth-guided generation
- β‘ Flux2 Klein text-to-image + multi-image edit
- Qwen Image & Qwen Edit for multilingual generation + edits
- FIBO structured prompt generation
- Z-Image Turbo fast text-to-image
- π Redux image variation generator
- β¬οΈ Upscale high-resolution upscaling (ControlNet-aware)
- π CatVTON virtual try-on
- βοΈ IC-Edit in-context editing
- π§© Concept Attention fine-grained prompt control
- ποΈ ControlNet support
- π― Dreambooth Fine-Tuning
- Flux2 Klein (4B/9B) support with dedicated generate + edit tabs (guidance fixed at 1.0)
- SeedVR2 Upscale tab integration with softness control for faithful 1-step upscaling
- FIBO tab with JSON prompts + optional VLM expansion
- Z-Image Turbo tab with LoRA + img2img support
- π² Dynamic Prompts - Wildcard support and prompt variations (applied across all generation workflows)
- π― Auto Seeds - Intelligent seed management and selection (shared workflow for Easy, Advanced, Canvas, ControlNet, Image-to-Image, In-Context LoRA)
- βοΈ Configuration Manager - Advanced config handling with presets
- π Generation Workflow - Comprehensive progress tracking and statistics
- π§ Enhanced Multi-LoRA support with library path management
- β‘ Advanced Quantization (3-,4-,6-,8-bit) & Low RAM mode
- π€ Enhanced Metadata export with workflow information
- π Stepwise output for generation progress visualization
- π€ Third-party HuggingFace model support
- π Modern tabbed UI for beginners and experts
- π€ Ollama integration for prompt enhancement
- macOS on Apple Silicon (MLX). Windows and Linux are not supported by MLX yet.
- Pinokio support targets macOS for this project.
- Enough disk space for models (tens of GB for multiple checkpoints).
- Sufficient RAM for the selected model/quantization level.
Get started in seconds! Install and run MFLUX WebUI with just one click using Pinokio.
If you prefer to install manually, follow these steps:
-
Clone this repository:
git clone https://github.com/yourusername/mflux-webui.git cd mflux-webui -
Create and activate a conda environment:
conda create -n mflux python=3.12 conda activate mflux -
Install the required packages:
pip install -r requirements.txt
To run the WebUI:
python webui.py # starts UI + built-in API server
Access the interface in your web browser at http://localhost:7860.
MFLUX_SERVER_NAME(default127.0.0.1), set to0.0.0.0to expose on your LANMFLUX_SERVER_PORTorPORTto force a specific port (otherwise Gradio picks an open one)MFLUX_OPEN_BROWSERset tofalseto disable auto-opening the browser
If your browser shows a folder listing instead of the UI, the WebUI is not running or you are on the wrong port.
Run python webui.py in a terminal and open the exact URL that Gradio prints.
Model downloads start on the first Generate click (or via the Model & LoRA Management tab).
The UI runs with Gradio queueing enabled by default. To control how many jobs run in parallel:
export MFLUX_QUEUE_CONCURRENCY=4
export MFLUX_QUEUE_STATUS=true
The built-in API server also queues requests and defaults to sequential processing:
export MFLUX_API_QUEUE_CONCURRENCY=1
- Auto-starts with the UI.
- Defaults:
http://<MFLUX_API_HOST>:<MFLUX_API_PORT>with endpoint/sdapi/v1/txt2img(Stable Diffusion WebUI-style). - Environment overrides:
MFLUX_API_HOST(default0.0.0.0)MFLUX_API_PORT(default7861)
- Example request:
curl -X POST http://localhost:7861/sdapi/v1/txt2img \
-H "Content-Type: application/json" \
-d '{
"prompt": "A cat playing guitar",
"width": 768,
"height": 1024,
"num_images": 1
}'The built-in API mirrors SD WebUI-style endpoints for automation.
- Base URL:
http://<MFLUX_API_HOST>:<MFLUX_API_PORT>(defaults:0.0.0.0:7861) - Endpoints:
POST /sdapi/v1/txt2img- Fields:
prompt(required),seed,width,height,steps,guidance,num_images,model,auto_seeds,lora_files,low_ram
- Fields:
POST /sdapi/v1/img2img- Fields:
prompt(required),init_images(array base64, required),seed,width,height,steps,guidance,image_strength,num_images,model,auto_seeds,lora_files,low_ram
- Fields:
POST /sdapi/v1/controlnet- Fields:
prompt(required),controlnet_image/controlnet_images/init_images(array base64, required),seed,width,height,steps,guidance,controlnet_strength,model,lora_files,low_ram
- Fields:
POST /api/upscale- Fields:
image(base64, required),upscale_factor(default 2),output_format(PNG/JPEG/WebP),metadata(bool)
- Fields:
- Model selection: pass
modelorsd_model_checkpointwith an alias fromGET /sdapi/v1/sd-models. - Response JSON (generation endpoints):
images: array of base64-encoded PNGsparameters: echo of the request payloadinfo: text summary from the generation callprompt: the prompt actually used (where applicable)
Run only the API (skip UI) by importing and calling backend.api_server.run_server(host, port) in your own launcher if needed.
After installation, you may want to configure the new v0.13.3 features:
Set up optional environment variables for enhanced functionality:
export LORA_LIBRARY_PATH="/path/to/your/lora/models" # Custom LoRA library location
export MFLUX_CONFIG_PATH="/path/to/config/files" # Custom config directory- First Run: Launch the WebUI and navigate to the Configuration tab
- Dynamic Prompts: Set up your prompt categories in the Dynamic Prompts tab
- Auto Seeds: Configure seed management in the Auto Seeds tab
- Presets: Create and save your preferred configuration presets
For full functionality, you may want to install optional dependencies:
# For advanced image processing
pip install opencv-python scipy matplotlib
# For development
pip install black flake8 pytestThe MFLUX WebUI v0.13.3 contains the following tabs:
- MFLUX Easy β quick text-to-image generation
- Qwen Image β text-to-image generation with the Qwen Image model (multilingual prompts, negative prompts, LoRA, quantization and optional init image)
- Qwen Image Edit β image editing based on one or more reference images using Qwen-Image-Edit (semantic + appearance editing)
- FIBO β structured prompt-based generation
- Z-Image Turbo β fast text-to-image generation
- π¨ Canvas β node-like workflow canvas for chaining tools
- Advanced Generate β full control over generation parameters
- ControlNet β guided generation with control images
- Image-to-Image β transform existing images
- Fill Tool (Inpaint/Outpaint) β remove or extend content
- Depth Tool β depth-guided generation
- Redux β create image variations
- Upscale β intelligent upscaling
- CatVTON β virtual try-on
- IC-Edit β in-context editing
- Concept Attention β weighted prompt control
- In-Context LoRA β apply reference styles
- Dreambooth Fine-Tuning β train custom models
- Kontext β context-aware generation
- Model & LoRA Management β download, quantize & manage models
- Auto Seeds β intelligent seed management and auto-generation (global workflow for all generation tabs)
- Dynamic Prompts β wildcard prompts, categories, and variations (applied in Easy, Advanced, Canvas, ControlNet, Image-to-Image and In-Context LoRA)
- Configuration β advanced config management with presets
frontend/
βββ components/ # UI components for each tab
βββ gradioui.py # Main Gradio UI implementation
βββ __init__.py
The MFLUX Easy tab provides a simplified interface for quick image generation:
- Prompt: Enter your text prompt describing the image you want to generate.
- Enhance prompt with Ollama: Option to improve the prompt using Ollama.
- Model: Choose between "schnell" (fast, lower quality) and "dev" (slow, higher quality).
- Image Format: Select common image dimensions.
- LoRA Files: Select LoRA files to use in generation (if available).
The Advanced Generate tab offers more control over the image generation process:
- All features from MFLUX Easy, plus:
- Seed: Set a specific seed for reproducible results.
- Width/Height: Set custom dimensions for the generated image.
- Inference Steps: Control the number of denoising steps.
- Guidance Scale: Adjust how closely the image follows the text prompt.
- Export Metadata: Option to export generation parameters as JSON.
The ControlNet tab allows for guided image generation:
- All features from Advanced Generate, plus:
- Control Image: Upload an image to guide the generation process.
- ControlNet Strength: Adjust the influence of the control image.
- Save Canny Edge Detection Image: Option to save the edge detection result.
Note: ControlNet requires InstantX/FLUX.1-dev-Controlnet-Canny, which was trained for the dev model. It can work well with schnell, but performance is not guaranteed.
The Image-to-Image tab allows you to transform existing images using new prompts:
- Prompt: Enter your text prompt describing how you want to transform the image.
- Enhance prompt with Ollama: Option to improve the prompt using Ollama.
- Initial Image: Upload the image you want to transform.
- Init Image Strength: Control how much the initial image influences the final result (0.0 - 1.0).
- Model: Choose the model to use for image transformation.
- Seed: Set a specific seed for reproducible results.
- Width/Height: Set dimensions for the generated image.
- Inference Steps: Control the number of denoising steps.
- Guidance Scale: Adjust how closely the image follows the text prompt.
- LoRA Files: Select LoRA files to use in transformation (if available).
- LoRA Scale: Adjust the influence of the LoRA files.
- Export Metadata: Option to export generation parameters as JSON.
- FIBO: JSON-native prompting with optional VLM expansion for structured prompts.
- Z-Image Turbo: fast generation in ~9 steps with LoRA and img2img support.
The Auto Seeds tab provides intelligent seed management:
- Enable Auto Seeds: Toggle automatic seed generation
- Current Pool: View and manage the current seed collection
- Pool Size: Configure how many seeds to maintain
- Generation Strategy: Choose between random, sequential, or weighted selection
- Seed History: Track previously used seeds and their results
- Export/Import: Save and load seed collections
- Statistics: View seed usage analytics and performance metrics
The Dynamic Prompts tab enables advanced prompt processing:
- Enable Dynamic Prompts: Toggle dynamic prompt processing
- Wildcard Support: Use
{category}syntax for random selections - Prompt Variations: Generate multiple variations from templates
- Categories Management: Create and manage prompt categories
- Template Library: Save and reuse prompt templates
- File Import/Export: Load prompts from txt/json files
- Random Selection: Configure randomization settings
- Prompt Testing: Preview variations before generation
Example wildcards:
A {adjective} {animal} in a {environment}, {style}
Where categories contain:
adjective: [beautiful, majestic, mysterious, elegant]animal: [cat, wolf, eagle, dragon]environment: [forest, mountain, ocean, city]style: [digital art, oil painting, photograph]
The Configuration Manager tab offers comprehensive settings control:
- Current Config: View all active configuration settings
- Quick Settings: Apply common configuration presets
- Config Sections: Manage settings by category:
- Generation parameters
- System settings
- LoRA configuration
- Auto seeds settings
- Battery management
- Quantization options
- Presets: Save and load custom configuration presets
- Import/Export: Share configurations via JSON/YAML files
- Template Export: Create configuration templates
- Validation: Automatic config validation and error checking
- Reset Options: Restore default settings
v0.13.3 introduces a comprehensive generation workflow system:
- Pre-generation Checks: Validate settings before starting
- Progress Monitoring: Real-time generation progress tracking
- Smart Pause/Resume: Intelligent generation control
- Enhanced Metadata: Comprehensive generation information
- Statistics Tracking: Monitor generation performance
- Error Recovery: Robust error handling and recovery
- Resource Management: Optimized memory and GPU usage
The Dreambooth Fine-Tuning tab allows you to train and customize models:
- Train new models using your own images
- Fine-tune existing models for specific styles or subjects
- Customize training parameters and configurations
- Monitor training progress
The Models tab enables you to manage models:
- Download LoRA: Download LoRA models directly from within the interface.
- Download and Add Model: Download models from Hugging Face and add them to available models.
- Quantize Model: Create optimized versions of the models:
- Choose which model to quantize ("dev" or "schnell").
- Select the quantization level (4-bit or 8-bit).
- View the quantization output in a dedicated textbox.
The Fill Tool lets you remove objects or extend the canvas of an existing image.
- Input Image with optional Mask Image indicating the region to fill/outpaint
- Prompt describing what should appear in the masked / empty area
- Width / Height, Steps, Guidance Scale sliders for fine-tuning
- Supports Low-RAM mode, 3/4/6/8-bit quantization, and metadata export
Generate images guided by the depth map extracted from a reference photo.
- Reference Image and text Prompt
- ControlNet Strength slider controls depth influence
- Option to save the extracted depth map alongside the result
Create multiple stylistic variations of a reference image in a single click.
- Redux Strength slider determines how different the variations are
- Specify number of variations, seed, steps, and guidance
Increase resolution up to 4Γ while preserving detail.
- Accepts any Input Image (optionally with a descriptive Prompt)
- Intelligent patch-based upscaling, ControlNet-aware for advanced guidance
- Adjustable Upscale Factor, Steps, Sharpen Strength, and more
Virtually dress a person in a garment image.
- Person Image + Mask identifying clothing region
- Garment Image to apply
- Auto-generated prompt if none provided
- Outputs both a diptych preview and the final try-on image
Edit an image using a natural-language instruction.
- Reference Image and an Instruction Prompt (e.g. "make it snowy")
- Generate one or multiple edited variants
- Full control over seed, steps, guidance, and quantization
Apply weighted concepts directly in your prompt using the {concept:weight} syntax.
- Supports multiple weighted tags per prompt
- Displays parsed concepts and weights before generation
- Works with any model or LoRA combo
Apply the style of a reference image on-the-fly without external LoRA files.
- Reference Image is encoded into a temporary LoRA
- Adjustable strength slider; combine with standard LoRAs for unique results
LoRA (Low-Rank Adaptation) allows for fine-tuned models to be used in image generation:
- Place your LoRA files (
.safetensors) in theloradirectory. - Select the desired LoRA file(s) from the dropdown menu in the WebUI.
- Use the LoRA download functionality in the Models tab to easily add new LoRA models.
MFLUX WebUI integrates Ollama for prompt enhancement:
- Enable the "Enhance prompt with Ollama" option to automatically improve your prompts.
- Adjust Ollama settings, including the model and system prompt, in the Ollama Settings section.
This tag introduces a richer Qwen workflow on top of the existing MFLUX WebUI:
-
Qwen Image tab
- Text-to-image generation with the Qwen Image model
- Supports multilingual prompts (Chinese and English), negative prompts, LoRA, quantization, seeds and multiple images per batch
- Optional init image input for Qwen-based image-to-image generation
-
Qwen Image Edit tab
- Uses
Qwen-Image-Editfor semantic and appearance editing:- Semantic edits: IP creation, viewpoint changes (90Β°/180Β° rotations), style transfer, background/clothing changes
- Appearance edits: add/remove elements while preserving the rest of the image
- Precise text editing in English and Chinese (posters, signs, etc.)
- Supports:
- Multiple reference images
- LoRA integration and quantization
- Seed control and metadata export
- Uses
-
Chained editing workflow
- After running Qwen Image Edit, the Use last output as input button reuses the latest edited images as new reference images
- Enables step-by-step refinement workflows (e.g. progressively correcting calligraphy or fine-grained local changes)
-
Region-based editing (crop helper)
- A dedicated Preview / Crop (optional) image area in the Qwen Edit tab allows selecting a region with the selection tool
- The selected crop is saved and used as the sole reference image for the next Qwen-Image-Edit call
- This makes it easy to target specific regions (e.g. a single character, logo, or object) for precise edits
These enhancements sit on top of the standard MFLUX Qwen integration and do not change the underlying Qwen models; they add a more powerful and user-friendly workflow layer around Qwen-Image and Qwen-Image-Edit.
Highlights:
- Updated to MFLUX v0.13.3 (FIBO + Z-Image Turbo support)
- Added FIBO and Z-Image Turbo tabs
- Refreshed ControlNet/Depth/Upscale integrations for the latest MFLUX APIs
- Improved API model selection for Open WebUI clients
- Updated Dreambooth trainer to the new DreamBooth modules
π οΈ Dependency Fixes
- Restricted MLX dependency upper bound to 0.26.1 (mlx>=0.22.0,<=0.26.1) to prevent incompatibility issues
π¨ Inpaint Mask Tool Improvements
- Enhanced interactive inpaint masking tool with additional shape options (ellipse, rectangle, and free-hand drawing)
- Added eraser mode for precise mask corrections
- Implemented undo/redo history for non-destructive editing when crafting masks
π©βπ» Developer Experience
- Introduced initial mypy static-type checking configuration
- Upgraded pre-commit hooks and addressed lint warnings
- π² Dynamic Prompts: Wildcard support with categories and templates
- π― Auto Seeds: Intelligent seed management and selection
- βοΈ Configuration Manager: Advanced config handling with presets
- π Generation Workflow: Comprehensive progress tracking
- π Stepwise Output: Real-time generation progress visualization
- π€ Third-party HuggingFace Model Support: Expanded model compatibility
- π€ Enhanced Metadata: Workflow information in exports
- Enhanced Multi-LoRA support with library path management
- Advanced quantization options (3-,4-,6-,8-bit)
- Improved error handling and recovery
- Better resource management and memory optimization
- Modern tabbed UI with better organization
- Comprehensive statistics and analytics
- Updated to MFLUX v0.9.1
- New modular backend architecture
- Enhanced workflow management system
- Improved configuration validation
- Better integration with external dependencies
- Fixed memory leaks in generation workflow
- Improved stability with multiple simultaneous generations
- Better error messages and user feedback
- Enhanced cleanup and resource management
- Base MFLUX WebUI functionality
- Core generation features
- LoRA and ControlNet support
- Basic model management
We welcome contributions to MFLUX WebUI! If you have suggestions for improvements or encounter any issues, please feel free to:
- Open an issue
- Submit a pull request
Please ensure that your code adheres to the project's coding standards and includes appropriate tests.
This project is licensed under the Apache License, Version 2.0.
The FLUX models (black-forest-labs/FLUX.1) used in this project are subject to their own license terms. Please refer to the black-forest-labs/FLUX.1 license for more information on the usage and distribution of these models.
Get started with MFLUX WebUI in seconds using Pinokio - the easiest way to install and run AI applications!
