Skip to content

Fix AttributeError in train_dreambooth_lora_flux2_img2img validation#13520

Open
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix-flux2-img2img-validation-image-typo
Open

Fix AttributeError in train_dreambooth_lora_flux2_img2img validation#13520
Ricardo-M-L wants to merge 1 commit intohuggingface:mainfrom
Ricardo-M-L:fix-flux2-img2img-validation-image-typo

Conversation

@Ricardo-M-L
Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes an AttributeError in examples/dreambooth/train_dreambooth_lora_flux2_img2img.py that makes the validation flow unusable.

The validation block references args.validation_image_path:

if args.validation_prompt is not None:
    validation_image = load_image(args.validation_image_path).convert(\"RGB\")

But the CLI argument is defined as --validation_image:

parser.add_argument(
    \"--validation_image\",
    type=str,
    default=None,
    help=\"path to an image that is used during validation as the condition image ...\",
)

Argparse stores it as args.validation_image, so accessing args.validation_image_path raises AttributeError: 'Namespace' object has no attribute 'validation_image_path' the moment a user passes --validation_prompt, before any training actually starts.

Sibling scripts like train_dreambooth_lora_flux2_klein_img2img.py (L1437) and train_dreambooth_lora_flux_kontext.py already use the correct args.validation_image; this aligns this script with them.

Fixes

-        validation_image = load_image(args.validation_image_path).convert(\"RGB\")
+        validation_image = load_image(args.validation_image).convert(\"RGB\")

Before submitting

Who can review?

@sayakpaul @linoytsaban

The validation block referenced `args.validation_image_path`, but the CLI
argument is defined as `--validation_image`, so argparse stores it as
`args.validation_image`. When a user passes `--validation_prompt`, the
script crashes immediately with `AttributeError: 'Namespace' object has
no attribute 'validation_image_path'` before any training starts.

Other Flux2 img2img-style dreambooth scripts (e.g.
`train_dreambooth_lora_flux2_klein_img2img.py` and
`train_dreambooth_lora_flux_kontext.py`) already use the correct
`args.validation_image`; this just aligns this script with them.
@github-actions github-actions Bot added examples size/S PR with diff < 50 LOC labels Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

examples size/S PR with diff < 50 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant