File tree Expand file tree Collapse file tree
src/diffusers/models/autoencoders Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3131CACHE_T = 2
3232
3333
34+ # Copied from diffusers.models.autoencoders.autoencoder_kl_wan.AvgDown3D with AvgDown3D->QwenImage21AvgDown3D
3435class QwenImage21AvgDown3D (nn .Module ):
3536 def __init__ (
3637 self ,
@@ -46,7 +47,6 @@ def __init__(
4647 f"`in_channels` ({ in_channels } ) times the downsampling factor ({ factor } ) must be divisible by "
4748 f"`out_channels` ({ out_channels } )."
4849 )
49-
5050 self .in_channels = in_channels
5151 self .out_channels = out_channels
5252 self .factor_t = factor_t
Original file line number Diff line number Diff line change @@ -40,14 +40,18 @@ def __init__(
4040 factor_s = 1 ,
4141 ):
4242 super ().__init__ ()
43+ factor = factor_t * factor_s * factor_s
44+ if in_channels * factor % out_channels != 0 :
45+ raise ValueError (
46+ f"`in_channels` ({ in_channels } ) times the downsampling factor ({ factor } ) must be divisible by "
47+ f"`out_channels` ({ out_channels } )."
48+ )
4349 self .in_channels = in_channels
4450 self .out_channels = out_channels
4551 self .factor_t = factor_t
4652 self .factor_s = factor_s
47- self .factor = self .factor_t * self .factor_s * self .factor_s
48-
49- assert in_channels * self .factor % out_channels == 0
50- self .group_size = in_channels * self .factor // out_channels
53+ self .factor = factor
54+ self .group_size = in_channels * factor // out_channels
5155
5256 def forward (self , x : torch .Tensor ) -> torch .Tensor :
5357 pad_t = (self .factor_t - x .shape [2 ] % self .factor_t ) % self .factor_t
You can’t perform that action at this time.
0 commit comments