A comprehensive web-based interface for FLUX.1 and Qwen-Image generation with advanced queue system, dynamic tool system, LoRA support, prompt enhancement, and background removal capabilities.
- FLUX.1 Models: Support for schnell, dev, and krea-dev variants with diffusers library
- Qwen-Image Model: Advanced text-to-image model with negative prompt and True CFG Scale support
- Memory Optimization: 8-bit quantization with ~70% memory reduction using optimum.quanto
- Dynamic Tool System: Modular selection of LoRA, ControlNet, and FLUX Tools
- LoRA Integration: Multiple LoRA models with individual intensity control (0-1) for both FLUX.1 and Qwen-Image
- Adaptive UI: Content Creation interface automatically adapts based on selected model
- FLUX Canny: Specialized Canny edge ControlNet with configurable thresholds
- FLUX Tools: Kontext for image editing and transformation
- Background Removal: AI-powered background removal with rembg
- ControlNet Upscaler: High-quality image upscaling using JasperAI's FLUX ControlNet
- Modular Design: Select and combine different AI tools
- Individual Tool Control: Each tool has its own parameters and settings
- Real-time Configuration: Adjust parameters for each selected tool
- Visual Tool Management: Clear interface showing selected tools and their settings
- Ollama Integration: Local LLM integration for prompt optimization
- Vision Model Support: Analyze images to generate detailed prompts
- Streaming Responses: Real-time prompt generation with progressive updates
- Batch Processing: Sequential task execution with intelligent resource management
- Memory Monitoring: Real-time RAM and VRAM/MPS usage tracking during processing
- Task Management: Interactive queue interface with individual task control
- Auto-Queuing: All generation operations automatically added to processing queue
- Progress Tracking: Live status updates with detailed memory statistics
- Error Recovery: Graceful handling of memory issues and processing errors
- SQLite Database: Persistent storage of all image operations and LoRA models
- Complete Metadata: Tracks generation parameters, tools used, and settings with automatic metadata saving
- Performance Metrics: Built-in timing measurements tracking both total generation time (end-to-end) and pure model execution time
- Gallery View: Visual browsing of generated images with detailed information and timing data
- LoRA Management: Dedicated interface for uploading, editing, and managing LoRA models
- HuggingFace Cache Management: Integrated cache viewer and cleanup with selective deletion
- Comprehensive Logging: Detailed console output for debugging and monitoring
- Python 3.8+
- CUDA-compatible GPU or Apple Silicon Mac (MPS support)
- Ollama (optional, for prompt enhancement)
- Clone the repository:
git clone https://github.com/VincentGourbin/FluxForge-Studio.git
cd FluxForge-Studio- Install dependencies:
pip install -r requirements.txtNote: The requirements include diffusers from the main development branch to support FLUX Kontext functionality. This ensures compatibility with the latest FLUX model features.
- (Optional) Install and configure Ollama:
# Install Ollama from https://ollama.ai/
ollama pull llama3.2-vision
ollama pull llama3.2python main.pyAccess the web interface at http://localhost:7860
python main.py --share
# or
python main.py -sWhen using --share, the application will:
- Generate a public shareable link (valid for 1 week)
- Create random authentication credentials for security
- Display the username/password in the terminal
Security Note: Save the generated credentials immediately as they won't be shown again!
- Click "Sélectionner des outils" to open the tool selection modal
- Choose a tool type: LoRA, ControlNet, or FLUX Tools
- Select the specific tool from the dropdown
- Click "Ajouter l'outil" to add it to your selection
LoRA Models
- Intensity control (0-1 range)
- Automatic activation keyword integration
- Multiple LoRA support (up to 3 simultaneously)
- Parameter Isolation: Queue tasks capture independent LoRA snapshots, preventing UI state interference
FLUX Postprocessing Tools
- FLUX Canny: Canny edge detection with configurable thresholds
- FLUX Depth: Depth-based image generation and control
- FLUX Fill: Inpainting and outpainting capabilities
- FLUX Redux: Image-to-image with Redux model
- Kontext: Text-guided image editing
FLUX Tools
- Kontext for image editing
- Guidance scale control
- Input image processing
- Individual Removal: Use 🗑️ buttons to remove specific tools
- Clear All: Remove all selected tools at once
- Parameter Adjustment: Modify settings for each tool independently
- Enter your prompt in the Content Creation tab
- Select model (schnell/dev/krea-dev/qwen-image) and configure basic parameters
- For Qwen-Image: Use negative prompt and True CFG Scale controls as needed
- Add desired tools using the dynamic tool system (LoRA, ControlNet, FLUX Tools)
- Adjust tool-specific parameters
- Click "Generate Image" to automatically queue your generation
- Monitor progress in the Processing Queue tab
- View completed images in the History tab
- Queue Tasks: All generation operations are automatically queued
- Start Processing: Use the "🚀 Process Queue" button to begin batch processing
- Monitor Progress: Real-time updates showing current task and memory usage
- Step Display: Live progress tracking with detailed step counts, elapsed time, and remaining time estimates
- Manage Tasks: Select and remove individual tasks from the pending queue
- View Statistics: Live counters for pending, processing, completed, and error tasks
- Access Interface: Open the "LoRA Management" tab
- Upload LoRA:
- Click "Upload .safetensors file" to select your LoRA model
- Add description and activation keywords
- Click "Add LoRA" to save to database and copy to lora directory
- Edit LoRA: Modify descriptions and keywords directly in the dataframe
- Delete LoRA:
- Select LoRA(s) using checkboxes
- Click "Delete Selected" to see confirmation interface
- Choose whether to delete files from disk
- Confirm deletion
- Real-time Sync: Changes immediately appear in all generation interfaces
mflux-gradio/
├── main.py # Main application entry point
├── lora_info.json # LoRA model metadata
├── requirements.txt # Python dependencies
├── src/ # Source code modules
│ ├── core/ # Core functionality
│ │ ├── config.py # Configuration and device setup
│ │ ├── database.py # SQLite database operations
│ │ └── processing_queue.py # Advanced queue system with memory monitoring
│ ├── generator/ # Image generation
│ │ ├── image_generator.py # FLUX.1 generation with diffusers
│ │ └── qwen_generator.py # Qwen-Image generation with LoRA and quantization
│ ├── enhancement/ # AI enhancement tools
│ │ └── prompt_enhancer.py # Ollama prompt enhancement
│ ├── postprocessing/ # FLUX postprocessing tools
│ │ ├── background_remover.py # Background removal
│ │ ├── flux_canny.py # Canny edge ControlNet
│ │ ├── flux_depth.py # Depth ControlNet
│ │ ├── flux_fill.py # Inpainting/outpainting
│ │ ├── flux_redux.py # Image-to-image with Redux
│ │ ├── kontext.py # Text-guided image editing
│ │ └── upscaler.py # ControlNet upscaling
│ ├── ui/ # User interface components
│ │ ├── components.py # Gradio UI components
│ │ ├── lora_manager.py # LoRA selection interface
│ │ ├── lora_management.py # LoRA management interface
│ │ └── processing_tab.py # Processing queue interface
│ └── utils/ # Utility functions
│ ├── canny_processing.py # Canny edge detection
│ ├── hf_cache_manager.py # HuggingFace cache management
│ ├── image_processing.py # Image utilities
│ ├── mask_utils.py # Masking utilities
│ ├── model_cache.py # Model caching system
│ ├── quantization.py # Memory quantization
│ └── queue_helpers.py # Queue integration functions
├── docs/ # Documentation
│ ├── API.md # API documentation
│ ├── FEATURES.md # Detailed features guide
│ ├── QUANTIZATION.md # Quantization guide
│ └── SETUP.md # Setup instructions
├── lora/ # LoRA model files (.safetensors)
├── outputimage/ # Generated images and metadata
└── temp_images/ # Temporary file storage
LoRA models are now managed through the dedicated LoRA Management tab in the web interface:
- Upload New LoRA: Upload .safetensors files with descriptions and activation keywords
- Edit Existing LoRA: Modify descriptions and keywords directly in the interface
- Delete LoRA: Remove LoRA models from database and optionally from disk
- Automatic Sync: Changes immediately reflected in all generation interfaces
Legacy Configuration: The old lora_info.json file is automatically migrated to the database on first run.
The application automatically detects and uses:
- MPS (Apple Silicon)
- CUDA (NVIDIA GPUs)
- CPU (fallback)
- FLUX.1 models loaded via diffusers library (schnell, dev, krea-dev)
- Qwen-Image model loaded via diffusers library with custom pipeline
- ControlNet models loaded on-demand
- Intelligent model caching for performance across all models
- Configurable Thresholds: Adjust low/high thresholds for edge detection
- Real-time Preview: See Canny edges before generation
- Strength Control: Fine-tune ControlNet influence (0-1)
- Specialized Pipeline: Dedicated FLUX Canny implementation
- JasperAI Model: Uses FLUX.1-dev-Controlnet-Upscaler
- High Quality: Better than simple image resizing
- Automatic Parameters: Optimized settings for best results
- Visual Cache Browser: View all cached models with detailed information
- Selective Deletion: Choose specific models to remove with checkboxes
- Space Calculation: See freed space before deletion
- Real-time Updates: Automatic refresh after cleanup operations
- 8-bit Quantization: Reduce GPU memory usage by ~70% using optimum.quanto
- Cross-Platform Support: Works on MPS (Apple Silicon), CUDA, and CPU
- Automatic Cleanup: GPU/MPS memory cleaned after operations
- Model Caching: Prevents unnecessary model reloads
- Device Optimization: Adapts to available hardware
- Supported Models: FLUX Schnell, Dev, Krea-dev, Qwen-Image, and all postprocessing tools (Fill, Kontext, Depth, Canny, Redux)
- Memory Reduction: Up to 70% GPU memory savings with 8-bit quantization
- Performance: Tested on MPS devices with minimal quality loss
- LoRA Compatibility: Quantization applied AFTER LoRA loading for full compatibility
- Stability: Conservative implementation using only tested qint8 quantization
- Fallback: Graceful degradation if quantization fails
- Dual Timing System: Comprehensive timing measurements for all generation types
- Total Generation Time: End-to-end timing from function start to image save
- Model Execution Time: Pure pipeline execution time for performance analysis
- Console Output: Real-time timing display (e.g.,
⏱️ Generation completed in 15.2s (model: 14.8s)) - Metadata Integration: All timing data automatically saved to database for historical analysis
- Cross-Model Support: Timing measurements available for both FLUX.1 and Qwen-Image generations
- Queue Integration: Timing data preserved through queue processing system
- Always-On Saving: Metadata automatically saved for all generations (no user toggle required)
- Comprehensive Data: Includes generation parameters, timing metrics, LoRA configurations, and tool settings
- Database Integration: All metadata stored in SQLite for persistent access
- Backward Compatibility: Existing generations maintain full metadata support
- Detailed Parameters: All generation settings logged
- Tool Information: Complete tool configuration tracking
- Clean Output: Essential information without debug clutter
- Performance Metrics: Timing information displayed for every generation
Memory Issues
- Reduce image dimensions
- Use CPU for ControlNet operations if MPS fails
- Close other GPU-intensive applications
Tool Selection Issues
- Ensure LoRA files are in
lora/directory - Check
lora_info.jsonformat - Verify input images are valid for postprocessing tools
- Check that required models are downloaded for specific tools
Generation Failures
- Check console logs for detailed error information
- Verify model files are accessible
- Ensure sufficient disk space
- Model Caching: Avoid changing models frequently
- Tool Selection: Only select tools you need
- Image Dimensions: Balance quality vs. speed
- Batch Operations: Process multiple images efficiently
- Performance Timing System: Comprehensive timing measurements for all generations
- Dual Timing Metrics: Total generation time (end-to-end) and pure model execution time
- Automatic Integration: Timing data automatically saved to metadata and database
- Console Display: Real-time timing information during generation
- Cross-Model Support: Available for both FLUX.1 and Qwen-Image generations
- Automatic Metadata Saving: Removed user toggle, metadata now always saved for all generations
- Qwen-Image LoRA Fix: Resolved critical bug preventing LoRA models from loading with Qwen-Image generations
- Enhanced Database Schema: Extended metadata structure to include timing information
- Qwen-Image Integration: Full integration of Qwen-Image model with adaptive UI, LoRA support, and quantization
- Unified Content Creation: Single interface supporting both FLUX.1 and Qwen-Image with model-specific controls
- Adaptive UI System: Interface automatically adapts based on selected model (negative prompt for Qwen-Image, True CFG Scale)
- LoRA Parameter Isolation: Fixed critical bug where LoRA selections persisted between queued tasks
- Advanced Queue System: Complete batch processing implementation with memory monitoring
- Sequential Task Processing: Intelligent resource management preventing memory conflicts
- Real-time Progress Tracking: Live updates with memory statistics and task status
- Diffusers Migration: Full migration from mflux to diffusers library
- Dynamic Tool System: Modular tool selection and management
- Fixed LoRA Mapping: Corrected tool-to-parameter mapping issues
- Enhanced Logging: Comprehensive parameter tracking
- Memory Optimization: Better GPU/MPS memory management with automatic cleanup
- UI Improvements: Cleaner interface with better contrast and queue management
- ControlNet Upscaler: Proper implementation with JasperAI model
- LoRA Management System: Complete interface for LoRA upload, editing, and database management
- Support quantisation - Add 4-bit/8-bit model quantization for memory efficiency (8-bit implemented, to be tested on CUDA)
- Remove Ollama dependencies - Make prompt enhancement optional with fallback options
- Add interface to manage LoRA - GUI for installing, organizing, and managing LoRA models (Complete LoRA Management tab implemented)
- Add custom model support - Support for user-provided custom models and fine-tunes
- Add memory optimisation of diffusers - Implement advanced memory management techniques
- Add batch image generation - Complete queue system for generating multiple images with different prompts/parameters
- High: Custom model support
- Medium: Advanced memory optimization for diffusers
- Low: Optional Ollama dependencies
- Performance Timing System: Comprehensive dual timing measurements with automatic metadata integration
- Automatic Metadata Saving: Streamlined metadata management with always-on saving
- Qwen-Image LoRA Support: Full LoRA compatibility for Qwen-Image generations
- Qwen-Image Integration: Complete integration with adaptive UI, LoRA support, quantization, and queue processing
- Batch Processing System: Complete queue implementation with memory monitoring
- 8-bit Quantization: Memory optimization with optimum.quanto for all models
- LoRA Management System: Complete GUI interface for LoRA upload, editing, deletion, and database management
- Adaptive UI System: Dynamic interface that adapts to selected model capabilities
Contributions welcome! Feel free to open issues for feature requests or bug reports.
This project is licensed under the MIT License - see the LICENSE file for details.
- FLUX.1 by Black Forest Labs
- Qwen-Image by Alibaba Cloud
- Diffusers by Hugging Face
- Gradio - Web interface framework
- Ollama - Local LLM integration
- JasperAI - ControlNet Upscaler model
Performance Note: This application requires significant computational resources. GPU acceleration (CUDA/MPS) is highly recommended for optimal performance.