@@ -228,13 +228,13 @@ def __init__(
228228 controlnet = controlnet ,
229229 )
230230 self .vae_scale_factor = (
231- 2 ** (len (self .vae .config .block_out_channels )) if hasattr (self , "vae" ) and self .vae is not None else 16
231+ 2 ** (len (self .vae .config .block_out_channels ) - 1 ) if hasattr (self , "vae" ) and self .vae is not None else 8
232232 )
233233 self .image_processor = VaeImageProcessor (vae_scale_factor = self .vae_scale_factor )
234234 self .tokenizer_max_length = (
235235 self .tokenizer .model_max_length if hasattr (self , "tokenizer" ) and self .tokenizer is not None else 77
236236 )
237- self .default_sample_size = 64
237+ self .default_sample_size = 128
238238
239239 # Copied from diffusers.pipelines.flux.pipeline_flux.FluxPipeline._get_t5_prompt_embeds
240240 def _get_t5_prompt_embeds (
@@ -453,8 +453,10 @@ def check_inputs(
453453 if strength < 0 or strength > 1 :
454454 raise ValueError (f"The value of strength should in [0.0, 1.0] but is { strength } " )
455455
456- if height % 8 != 0 or width % 8 != 0 :
457- raise ValueError (f"`height` and `width` have to be divisible by 8 but are { height } and { width } ." )
456+ if height % self .vae_scale_factor != 0 or width % self .vae_scale_factor != 0 :
457+ raise ValueError (
458+ f"`height` and `width` have to be divisible by { self .vae_scale_factor } but are { height } and { width } ."
459+ )
458460
459461 if callback_on_step_end_tensor_inputs is not None and not all (
460462 k in self ._callback_tensor_inputs for k in callback_on_step_end_tensor_inputs
@@ -493,9 +495,9 @@ def check_inputs(
493495 @staticmethod
494496 # Copied from diffusers.pipelines.flux.pipeline_flux.FluxPipeline._prepare_latent_image_ids
495497 def _prepare_latent_image_ids (batch_size , height , width , device , dtype ):
496- latent_image_ids = torch .zeros (height // 2 , width // 2 , 3 )
497- latent_image_ids [..., 1 ] = latent_image_ids [..., 1 ] + torch .arange (height // 2 )[:, None ]
498- latent_image_ids [..., 2 ] = latent_image_ids [..., 2 ] + torch .arange (width // 2 )[None , :]
498+ latent_image_ids = torch .zeros (height , width , 3 )
499+ latent_image_ids [..., 1 ] = latent_image_ids [..., 1 ] + torch .arange (height )[:, None ]
500+ latent_image_ids [..., 2 ] = latent_image_ids [..., 2 ] + torch .arange (width )[None , :]
499501
500502 latent_image_id_height , latent_image_id_width , latent_image_id_channels = latent_image_ids .shape
501503
@@ -522,10 +524,10 @@ def _unpack_latents(latents, height, width, vae_scale_factor):
522524 height = height // vae_scale_factor
523525 width = width // vae_scale_factor
524526
525- latents = latents .view (batch_size , height , width , channels // 4 , 2 , 2 )
527+ latents = latents .view (batch_size , height // 2 , width // 2 , channels // 4 , 2 , 2 )
526528 latents = latents .permute (0 , 3 , 1 , 4 , 2 , 5 )
527529
528- latents = latents .reshape (batch_size , channels // (2 * 2 ), height * 2 , width * 2 )
530+ latents = latents .reshape (batch_size , channels // (2 * 2 ), height , width )
529531
530532 return latents
531533
@@ -549,11 +551,11 @@ def prepare_latents(
549551 f" size of { batch_size } . Make sure the batch size matches the length of the generators."
550552 )
551553
552- height = 2 * ( int (height ) // self .vae_scale_factor )
553- width = 2 * ( int (width ) // self .vae_scale_factor )
554+ height = int (height ) // self .vae_scale_factor
555+ width = int (width ) // self .vae_scale_factor
554556
555557 shape = (batch_size , num_channels_latents , height , width )
556- latent_image_ids = self ._prepare_latent_image_ids (batch_size , height , width , device , dtype )
558+ latent_image_ids = self ._prepare_latent_image_ids (batch_size , height // 2 , width // 2 , device , dtype )
557559
558560 if latents is not None :
559561 return latents .to (device = device , dtype = dtype ), latent_image_ids
@@ -852,7 +854,7 @@ def __call__(
852854 control_mode = control_mode .reshape ([- 1 , 1 ])
853855
854856 sigmas = np .linspace (1.0 , 1 / num_inference_steps , num_inference_steps )
855- image_seq_len = (int (height ) // self .vae_scale_factor ) * (int (width ) // self .vae_scale_factor )
857+ image_seq_len = (int (height ) // self .vae_scale_factor // 2 ) * (int (width ) // self .vae_scale_factor // 2 )
856858 mu = calculate_shift (
857859 image_seq_len ,
858860 self .scheduler .config .base_image_seq_len ,
0 commit comments