Skip to content

Conversation

@nicolaus-huang
Copy link

@nicolaus-huang nicolaus-huang commented Oct 15, 2025

fixes #441: Standardize control image handling for training pipeline

This commit refactors the way control images are processed and passed to the model to ensure consistency and robustness.

  • In extensions_built_in/diffusion_models/qwen_image/qwen_image_edit_plus.py:

    • A new method, _prepare_control_images_for_prompt, has been added at line 158.
    • This function unifies control images from the data loader—whether a single tensor or a nested list—into a standard list format ([tensor_ctrl0, ...]).
    • It is called within get_prompt_embeds, where each image is then interpolated, has its extra batch dimension squeezed, and is passed to the Qwen pipeline as a CPU float32 tensor.
  • In extensions_built_in/sd_trainer/SDTrainer.py:

    • The prompt encoding arguments at lines 1091 and 1484 have been adjusted.
    • The training process will now prioritize using batch.control_tensor_list.
    • If it is unavailable, the code will fall back to splitting batch.control_tensor into a list. This ensures control images are always passed to the model during training.

@nicolaus-huang nicolaus-huang changed the title Solve KeyError: 'pixel_values' in Qwen-Image-Edit-2509 when number of control images is less than 3 Solve KeyError: 'pixel_values' in Qwen-Image-Edit-2509 when number of control images is less than 3 #441 Oct 15, 2025
@nicolaus-huang nicolaus-huang changed the title Solve KeyError: 'pixel_values' in Qwen-Image-Edit-2509 when number of control images is less than 3 #441 Solve KeyError: 'pixel_values' in Qwen-Image-Edit-2509 when number of control images is less than 3 Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KeyError: 'pixel_values' in Qwen-Image-Edit-2509

1 participant