@@ -561,8 +561,8 @@ def __call__(
561561 # single image for edit, list for edit plus(QwenImageEdit2509)
562562 input_image : List [Image .Image ] | Image .Image | None = None ,
563563 cfg_scale : float = 4.0 , # true cfg
564- height : int = 1328 ,
565- width : int = 1328 ,
564+ height : Optional [ int ] = None ,
565+ width : Optional [ int ] = None ,
566566 num_inference_steps : int = 50 ,
567567 seed : int | None = None ,
568568 controlnet_params : List [QwenImageControlNetParams ] | QwenImageControlNetParams = [],
@@ -571,7 +571,9 @@ def __call__(
571571 entity_prompts : Optional [List [str ]] = None ,
572572 entity_masks : Optional [List [Image .Image ]] = None ,
573573 ):
574+ assert (height is None ) == (width is None ), "height and width should be set together"
574575 is_edit_plus = isinstance (input_image , list )
576+
575577 if input_image is not None :
576578 if not isinstance (input_image , list ):
577579 input_image = [input_image ]
@@ -583,9 +585,11 @@ def __call__(
583585 vae_width , vae_height = self .calculate_dimensions (1024 * 1024 , img_width / img_height )
584586 condition_images .append (img .resize ((condition_width , condition_height ), Image .LANCZOS ))
585587 vae_images .append (img .resize ((vae_width , vae_height ), Image .LANCZOS ))
588+ if width is None and height is None :
589+ width , height = vae_images [- 1 ].size
586590
587- width , height = vae_images [ - 1 ]. size
588-
591+ if width is None and height is None :
592+ width , height = 1328 , 1328
589593 self .validate_image_size (height , width , minimum = 64 , multiple_of = 16 )
590594
591595 if not isinstance (controlnet_params , list ):
0 commit comments