In the realm of large language models (LLMs) and diffusion models, techniques for optimizing performance while minimizing computational resources are crucial. One such technique, LoRA (Low-Rank Adaptation), has gained significant traction for its ability to fine-tune models efficiently. In this comprehensive guide, we’ll explore the process of LoRA training specifically for the FLUX diffusion model using the Flux Gym tool.
What is Flux Gym?
Developed by the creator of Pinokio AI, Flux Gym is a user-friendly web interface designed to simplify the process of LoRA training for the FLUX diffusion model. It leverages the Gradio UI from the AI toolkit and the Kohya script, making it accessible to users with varying technical backgrounds.
Video Tutorial Here : Flux 1 Dev LoRA Training Simple WebUI With Low VRAM Enable – Fluxgym Tutorial Guide
Step 1: Setting up the Environment
Before we dive into LoRA training, we need to set up our environment. Follow these steps:
- Clone the Flux Gym repository using the
git clone
command. - Navigate to the Flux Gym folder using
cd fluxgym
. - Clone the SD script from Kohya SS, which handles the backend training logic.
- Create a virtual environment using
python -m venv env
(or use Conda if preferred). - Activate the virtual environment with
env\Scripts\activate
(Windows) orsource env/bin/activate
(Unix-based systems). - Install the required dependencies by running
pip install -r requirements.txt
in both theSD script
andFlux Gym
folders. - Install PyTorch and its dependencies using the appropriate command for your system.
Step 2: Preparing the Models and Checkpoints
Flux Gym requires specific models and checkpoints to function correctly. If you’ve previously worked with FLUX models, you can reuse them. Otherwise, you’ll need to download them separately:
- Place the CLIP models (e.g., CLIP L safe tensor, T5 CLIP) in the
models/CLIP
folder. - Add the U-Net model (e.g., Flux 1 Dev SFT) to the
models/UNet
folder. - Include the VAE model (e.g., VAE SFT) in the
models/VAE
folder.
Step 3: Running Flux Gym
With the environment set up and models in place, you can now run Flux Gym:
- Ensure your virtual environment is active.
- Navigate to the Flux Gym folder.
- Run the command
python app.py
to start the Flux Gym web interface.
Step 4: LoRA Training with Flux Gym
The Flux Gym web interface provides a user-friendly interface for LoRA training:
- Enter a name for your LoRA model.
- Specify the trigger word or phrase for the LoRA.
- Select the desired VRAM allocation (12GB, 16GB, or 20GB).
- Set the number of repeat training iterations per image (default is 1).
- Upload your dataset images (e.g., 20 images for the desired subject or character).
- Click the “Start Training” button to initiate the LoRA training process.
Step 5: Monitoring and Retrieving Results
During the training process, you can monitor the progress through the web UI. Upon completion, the LoRA model and associated checkpoints will be saved in the output
folder within the Flux Gym directory.
You can then load the trained LoRA model into compatible applications, such as ComfyUI, to generate images using the fine-tuned model.
By following this step-by-step guide, you’ll be able to leverage the power of LoRA training for the FLUX diffusion model using the user-friendly Flux Gym interface. Whether you’re a seasoned AI practitioner or a newcomer to the field, this tutorial aims to streamline the process and empower you to create custom, fine-tuned models tailored to your specific needs.
Fluxgym Github : https://github.com/cocktailpeanut/fluxgym