Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
F

flymyai-lora-trainer

> 编程语言
Open source

Qwen-Image text to image lora trainer

764 stars0 likes5 views
WebsiteGitHub

About

Qwen-Image text to image lora trainer

LoRA Training for Qwen-Image, Qwen-Image-Edit & FLUX.1-dev

An open-source implementation for training LoRA (Low-Rank Adaptation) layers for Qwen/Qwen-Image, Qwen/Qwen-Image-Edit, and FLUX.1-dev models by FlyMy.AI.

Star History

About FlyMy.AI

Agentic Infra for GenAI. FlyMy.AI is a B2B infrastructure for building and running GenAI Media agents.

** Useful Links:**

  • Official Website
  • Documentation
  • Discord Community
  • Pre-trained Qwen LoRA Model
  • Pre-trained FLUX LoRA Model
  • Train Your Own FLUX LoRA
  • X (Twitter)
  • LinkedIn
  • YouTube
  • Instagram

Features

  • LoRA-based fine-tuning for efficient training
  • Support for Qwen-Image, Qwen-Image-Edit, and FLUX.1-dev models
  • Compatible with Hugging Face diffusers
  • Easy configuration via YAML
  • Control-based image editing with LoRA
  • Open-source implementation for LoRA training
  • Full training support for Qwen-Image
  • High-quality portrait and character training for FLUX

Updates

16.10.2025

  • ✅ Added FLUX.1-dev LoRA training support
  • ✅ Added pre-trained FLUX LoRA model example

02.09.2025

  • ✅ Added full training for Qwen-Image and Qwen-Image-Edit

20.08.2025

  • ✅ Added Qwen-Image-Edit LoRA trainer support

09.08.2025

  • ✅ Add pipeline for train for < 24GiB GPU

08.08.2025

  • ✅ Added comprehensive dataset preparation instructions
  • ✅ Added dataset validation script (utils/validate_dataset.py)
  • ✅ Freeze model weights during training

⚠️ Project Status

** Under Development:** We are actively working on improving the code and adding test coverage. The project is in the refinement stage but ready for use.

** Development Plans:**

  • ✅ Basic code is working
  • ✅ Training functionality implemented
  • ✅ FLUX.1-dev support added
  • Performance optimization in progress
  • Test coverage coming soon

Installation

Requirements:

  • Python 3.10
  1. Clone the repository and navigate into it:

    bash
    git clone https://github.com/FlyMyAI/flymyai-lora-trainer
    cd flymyai-lora-trainer
  2. Install required packages:

    bash
    pip install -r requirements.txt
  3. Install the latest diffusers from GitHub:

    bash
    pip install git+https://github.com/huggingface/diffusers
  4. Download pre-trained LoRA weights (optional):

    bash
    # Qwen LoRA weights
    git clone https://huggingface.co/flymy-ai/qwen-image-realism-lora
    
    # FLUX LoRA weights
    git clone https://huggingface.co/flymy-ai/flux-dev-anne-hathaway-lora
    
    # Or download specific files
    wget https://huggingface.co/flymy-ai/qwen-image-realism-lora/resolve/main/flymy_realism.safetensors
    wget https://huggingface.co/flymy-ai/flux-dev-anne-hathaway-lora/resolve/main/pytorch_lora_weights.safetensors

Data Preparation

Dataset Structure for Training

The training data should follow the same format for both Qwen and FLUX models, where each image has a corresponding text file with the same name:

dataset/
├── img1.png
├── img1.txt
├── img2.jpg
├── img2.txt
├── img3.png
├── img3.txt
└── ...

Dataset Structure for Qwen-Image-Edit Training

For control-based image editing, the dataset should be organized with separate directories for target images/captions and control images:

dataset/
├── images/           # Target images and their captions
│   ├── image_001.jpg
│   ├── image_001.txt
│   ├── image_002.jpg
│   ├── image_002.txt
│   └── ...
└── control/          # Control images
    ├── image_001.jpg
    ├── image_002.jpg
    └── ...

Data Format Requirements

  1. Images: Support common formats (PNG, JPG, JPEG, WEBP)
  2. Text files: Plain text files containing image descriptions
  3. File naming: Each image must have a corresponding text file with the same base name

Example Data Structure

my_training_data/
├── portrait_001.png
├── portrait_001.txt
├── landscape_042.jpg
├── landscape_042.txt
├── abstract_design.png
├── abstract_design.txt
└── style_reference.jpg
└── style_reference.txt

Text File Content Examples

For FLUX character training (portrait_001.txt):

ohwx woman, professional headshot, studio lighting, elegant pose, looking at camera

For Qwen landscape training (landscape_042.txt):

Mountain landscape at sunset, dramatic clouds, golden hour lighting, wide angle view

For FLUX portrait training (abstract_design.txt):

ohwx woman, modern portrait style, soft lighting, artistic composition

Data Preparation Tips

  1. Image Quality: Use high-resolution images (recommended 1024x1024 or higher)
  2. Description Quality: Write detailed, accurate descriptions of your images
  3. Consistency: Maintain consistent style and quality across your dataset
  4. Dataset Size: For good results, use at least 10-50 image-text pairs
  5. Trigger Words:
    • For FLUX character training: Use "ohwx woman" or "ohwx man" as trigger words
    • For Qwen training: No specific trigger words required
  6. Auto-generate descriptions: You can generate image descriptions automatically using Florence-2

Quick Data Validation

You can verify your data structure using the included validation utility:

bash
python utils/validate_dataset.py --path path/to/your/dataset

This will check that:

  • Each image has a corresponding text file
  • All files follow the correct naming convention
  • Report any missing files or inconsistencies

Start Training on < 24gb vram

To begin training with your configuration file (e.g., train_lora_4090.yaml), run:

bash
accelerate launch train_4090.py --config ./train_configs/train_lora_4090.yaml

Training

Qwen Models Training

Qwen-Image LoRA Training

To begin training with your configuration file (e.g., train_lora.yaml), run:

bash
accelerate launch train.py --config ./train_configs/train_lora.yaml

Make sure train_lora.yaml is correctly set up with paths to your dataset, model, output directory, and other parameters.

Qwen-Image Full Training

To begin training with your configuration file (e.g., train_full_qwen_image.yaml), run:

bash
accelerate launch train_full_qwen_image.py --config ./train_configs/train_full_qwen_image.yaml

Make sure train_full_qwen_image.yaml is correctly set up with paths to your dataset, model, output directory, and other parameters. The proposed method was tested on an NVIDIA H200 GPU environment.

Loading Trained Full Model

After training, you can load your trained model from the checkpoint directory for inference.

Simple Example:

…

Complete Example Script:

bash
python inference_trained_model_gpu_optimized.py

Checkpoint Structure:

The trained model is saved in the following structure:

checkpoint/
├── config.yaml          # Training configuration
└── transformer/         # Trained transformer weights
    ├── config.json
    ├── diffusion_pytorch_model.safetensors.index.json
    └── diffusion_pytorch_model-00001-of-00005.safetensors
    └── ... (multiple shard files)

Qwen-Image-Edit LoRA Training

For control-based image editing training, use the specialized training script:

bash
accelerate launch train_qwen_edit_lora.py --config ./train_configs/train_lora_qwen_edit.yaml

Configuration for Qwen-Image-Edit

The configuration file train_lora_qwen_edit.yaml should include:

  • img_dir: Path to target images and captions directory (e.g., ./extracted_dataset/train/images)
  • control_dir: Path to control images directory (e.g., ./extracted_dataset/train/control)
  • Other standard LoRA training parameters

Usage

Qwen-Image-Edit Full Training

To begin training with your configuration file (e.g., train_full_qwen_edit.yaml), run:

bash
accelerate launch train_full_qwen_edit.py --config ./train_configs/train_full_qwen_edit.yaml

Qwen-Image Initialization

python
from diffusers import DiffusionPipeline
import torch

model_name = "Qwen/Qwen-Image"

# Load the pipeline
if torch.cuda.is_available():
    torch_dtype = torch.bfloat16
    device = "cuda"
else:
    torch_dtype = torch.float32
    device = "cpu"

pipe = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch_dtype)
pipe = pipe.to(device)

Qwen-Image-Edit Initialization

python
from diffusers import QwenImageEditPipeline
import torch
from PIL import Image

# Load the pipeline
pipeline = QwenImageEditPipeline.from_pretrained("Qwen/Qwen-Image-Edit")
pipeline.to(torch.bfloat16)
pipeline.to("cuda")

Load LoRA Weights

For Qwen-Image:

python
# Load LoRA weights
pipe.load_lora_weights('flymy-ai/qwen-image-realism-lora', adapter_name="lora")

For Qwen-Image-Edit:

python
# Load trained LoRA weights
pipeline.load_lora_weights("/path/to/your/trained/lora/pytorch_lora_weights.safetensors")

Generate Image with Qwen-Image LoRA

You can find LoRA weights here

No trigger word required

…

Edit Image with Qwen-Image-Edit LoRA

…

️ Sample Output - Qwen-Image

️ Sample Output - Qwen-Image-Edit

Input Image:

Prompt: "Make a shot in the same scene of the left hand securing the edge of the cutting board while the right hand tilts it, causing the chopped tomatoes to slide off into the pan, camera angle shifts slightly to the left to center more on the pan."

Output without LoRA:

Output with LoRA:


FLUX.1-dev Models Training

FLUX.1-dev LoRA Training

FLUX.1-dev is a powerful text-to-image model that excels at generating high-quality portraits and character images. Our LoRA training implementation allows you to fine-tune FLUX for specific characters or styles.

Start FLUX Training

To begin FLUX LoRA training with your configuration file, run:

bash
accelerate launch train_flux_lora.py --config ./train_configs/train_flux_config.yaml

Make sure train_flux_config.yaml is correctly set up with paths to your dataset, model, output directory, and other parameters.

FLUX.1-dev Initialization

python
from diffusers import DiffusionPipeline
import torch

model_name = "black-forest-labs/FLUX.1-dev"

# Load the pipeline
if torch.cuda.is_available():
    torch_dtype = torch.bfloat16
    device = "cuda"
else:
    torch_dtype = torch.float32
    device = "cpu"

pipe = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch_dtype)
pipe = pipe.to(device)

Load FLUX LoRA Weights

python
# Load LoRA weights
pipe.load_lora_weights('flymy-ai/flux-dev-anne-hathaway-lora', adapter_name="lora")

Generate Image with FLUX LoRA

You can find our pre-trained FLUX LoRA weights here

Trigger word required: "ohwx woman"

…

️ Sample FLUX Output

FLUX Generation Examples

Below are examples of images generated with our FLUX Anne Hathaway LoRA model:

Casual Portrait Selfie

Prompt: "ohwx woman portrait selfie"

Artistic Double Exposure

Prompt: "ohwx woman perfectly symmetrical young female face close-up, presented with double exposure overlay blending nature textures like leaves and water"

Golden Hour Macro Portrait

Prompt: "ohwx woman Macro photography style close-up of female face with light makeup, focused on eyes and lips, illuminated by golden hour sunlight for warm tones"

Cozy Portrait with Pa

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Python

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言