diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

Bugfix for dreambooth flux2 img2img2

Open leisuzz opened this issue 1 month ago • 2 comments

What does this PR do?

I'm training the flux2 img2img with 8 GPUs, the running scripts is using the script from examples/dreambooth/README_flux2.md:

bash
accelerate launch train_dreambooth_lora_flux2_img2img.py \
  --pretrained_model_name_or_path=black-forest-labs/FLUX.2-dev  \
  --output_dir="flux2-i2i" \
  --dataset_name="kontext-community/relighting" \
  --image_column="output" --cond_image_column="file_name" --caption_column="instruction" \
  --do_fp8_training \
  --gradient_checkpointing \
  --remote_text_encoder \
  --cache_latents \
  --resolution=1024 \
  --train_batch_size=1 \
  --guidance_scale=1 \
  --gradient_accumulation_steps=4 \
  --gradient_checkpointing \
  --optimizer="adamw" \
  --use_8bit_adam \
  --cache_latents \
  --learning_rate=1e-4 \
  --lr_scheduler="constant_with_warmup" \
  --lr_warmup_steps=200 \
  --max_train_steps=1000 \
  --rank=16\
  --seed="0" 

There are three different errors occured, and this PR is doing these fix:

  1. Fix the issue that --instance_prompt is required as True, but the script does not need it.

  2. Fix the error: AttributeError: type object 'Flux2ImageProcessor' has no attribute 'image_processor'

  3. Fix the error: AttributeError: 'Tensor' object has no attribute 'load'

The dest_image has to be converted to PIL to keep the same logic after preprocess .

  1. Fix the issue that validation_image is required to be loaded, but the datasets relighting and the script does not provide it
validation_image = load_image(args.validation_image_path).convert("RGB")
validation_kwargs = {"image": validation_image}

Before submitting

  • [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • [x] Did you read the contributor guideline?
  • [x] Did you read our philosophy doc (important for complex PRs)?
  • [x] Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case.
  • [ ] Did you make sure to update the documentation with your changes? Here are the documentation guidelines, and here are tips on formatting docstrings.
  • [x] Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.

leisuzz avatar Dec 11 '25 06:12 leisuzz

@sayakpaul Please take a look at this PR, thank you!

leisuzz avatar Dec 13 '25 01:12 leisuzz

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.