ComfyUI-QwenImageLoraLoader

A ComfyUI custom node for loading and applying LoRA (Low-Rank Adaptation) to Nunchaku Qwen Image models.

This project is based on the fork version of ComfyUI-nunchaku-qwen-lora-suport-standalone.

Source

This LoRA loader was extracted and modified from the fork version:

  • Original Fork: ComfyUI-nunchaku-qwen-lora-suport-standalone
  • Extraction: LoRA functionality was extracted from the full fork to create an independent custom node
  • Integration: Modified to work with the official ComfyUI-nunchaku plugin

Features

  • NunchakuQwenImageLoraLoader: Load and apply single LoRA to Qwen Image models
  • NunchakuQwenImageLoraStack: Apply multiple LoRAs with dynamic UI control
  • Dynamic VRAM Management: Automatic CPU offloading based on available VRAM
  • LoRA Composition: Efficient LoRA stacking and composition
  • ComfyUI Integration: Seamless integration with ComfyUI workflows

Installation

  1. Clone this repository to your ComfyUI custom_nodes directory:
git clone https://github.com/ussoewwin/ComfyUI-QwenImageLoraLoader.git
  1. Ensure you have the official ComfyUI-nunchaku plugin installed (which includes nunchaku as a dependency).

  2. Run the installation script:

    • Double-click install_qwen_lora.bat to automatically configure the integration
    • This script will automatically modify the ComfyUI-nunchaku __init__.py file
    • Restart ComfyUI

Manual Installation

If you prefer manual installation, see INSTALLATION.md for detailed instructions.

Integration with ComfyUI-nunchaku

IMPORTANT: This node requires modification of the official ComfyUI-nunchaku plugin to function properly.

Required Modification

You must modify the __init__.py file in your ComfyUI-nunchaku plugin to import this LoRA loader:

try:
    # Import from the independent ComfyUI-QwenImageLoraLoader
    import sys
    import os
    qwen_lora_path = os.path.join(os.path.dirname(__file__), "..", "ComfyUI-QwenImageLoraLoader")
    if qwen_lora_path not in sys.path:
        sys.path.insert(0, qwen_lora_path)
    
    # Import directly from the file path
    import importlib.util
    spec = importlib.util.spec_from_file_location("qwenimage", os.path.join(qwen_lora_path, "nodes", "lora", "qwenimage.py"))
    qwenimage_module = importlib.util.module_from_spec(spec)
    spec.loader.exec_module(qwenimage_module)
    
    NunchakuQwenImageLoraLoader = qwenimage_module.NunchakuQwenImageLoraLoader
    NunchakuQwenImageLoraStack = qwenimage_module.NunchakuQwenImageLoraStack

    NODE_CLASS_MAPPINGS["NunchakuQwenImageLoraLoader"] = NunchakuQwenImageLoraLoader
    NODE_CLASS_MAPPINGS["NunchakuQwenImageLoraStack"] = NunchakuQwenImageLoraStack
    logger.info("Successfully imported Qwen Image LoRA loaders from ComfyUI-QwenImageLoraLoader")
except ImportError:
    logger.exception("Nodes `NunchakuQwenImageLoraLoader` and `NunchakuQwenImageLoraStack` import failed:")

Why This Modification is Required

  • The independent LoRA loader exists as a separate custom node
  • The official ComfyUI-nunchaku plugin needs to reference the independent LoRA loader
  • Standard from ... import ... fails due to different package structures
  • importlib.util allows direct module loading from file paths

The batch file install_qwen_lora.bat automatically adds the above code to your ComfyUI-nunchaku __init__.py file:

  1. What the batch file does:

    • Automatically detects your ComfyUI installation path
    • Backs up the original __init__.py file (creates __init__.py.backup)
    • Adds the exact import code shown above to the end of ComfyUI-nunchaku's __init__.py
    • Performs error checking to ensure all required files exist
    • Provides user feedback throughout the process
  2. Run the installation script:

    • Double-click install_qwen_lora.bat to automatically configure the integration
    • No manual code editing required - the script handles everything
    • Restart ComfyUI after installation
  3. Uninstall if needed:

    • Double-click uninstall_qwen_lora.bat to restore the original configuration
    • This will restore the backup and remove the integration code

Usage

Available Nodes

  • NunchakuQwenImageLoraLoader: Single LoRA loader
  • NunchakuQwenImageLoraStack: Multi LoRA stacker with dynamic UI

Basic Usage

  1. Load your Nunchaku Qwen Image model using Nunchaku Qwen Image DiT Loader
  2. Add either NunchakuQwenImageLoraLoader or NunchakuQwenImageLoraStack node
  3. Select your LoRA file and set the strength
  4. Connect to your workflow

Dynamic UI Control

The NunchakuQwenImageLoraStack node automatically adjusts the number of visible LoRA slots based on the lora_count parameter (1-10).

Features

  • Easy Installation: Automated installation script included
  • Automatic Integration: No manual code editing required
  • Backup & Restore: Automatic backup of original files
  • Cross-Platform: Works on Windows with batch files
  • Error Handling: Comprehensive error checking and user feedback

Requirements

  • ComfyUI
  • ComfyUI-nunchaku plugin (with required modification)
  • PyTorch
  • Python 3.10+

Compatibility

This node is designed to work with:

  • ComfyUI-nunchaku plugin (modified)
  • Nunchaku Qwen Image models
  • Standard ComfyUI workflows

License

This project is licensed under the MIT License.

S
Description
No description provided
Readme Apache-2.0
5.4 MiB
Languages
Python 85.2%
JavaScript 14.1%
Batchfile 0.7%