Skip to content

Commit 18c085c

Browse files
committed
Parameterize frequency_embedding_size in CombinedTimestepGuidanceTextProjEmbeddings
1 parent 39c2171 commit 18c085c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/maxdiffusion/models/embeddings_flax.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,20 +497,21 @@ class CombinedTimestepGuidanceTextProjEmbeddings(nn.Module):
497497
embedding_dim: int
498498
pooled_projection_dim: int
499499
guidance_embeds: bool = True
500+
frequency_embedding_size: int = 256
500501
dtype: jnp.dtype = jnp.float32
501502
weights_dtype: jnp.dtype = jnp.float32
502503
precision: jax.lax.Precision = None
503504

504505
@nn.compact
505506
def __call__(self, timestep, guidance, pooled_projection=None):
506-
timesteps_proj = FlaxTimesteps(dim=256, flip_sin_to_cos=True, freq_shift=0)(timestep)
507+
timesteps_proj = FlaxTimesteps(dim=self.frequency_embedding_size, flip_sin_to_cos=True, freq_shift=0)(timestep)
507508
dtype = pooled_projection.dtype if pooled_projection is not None else jnp.float32
508509
timestep_emb = FlaxTimestepEmbedding(
509510
time_embed_dim=self.embedding_dim, dtype=self.dtype, weights_dtype=self.weights_dtype
510511
)(timesteps_proj.astype(dtype))
511512

512513
if self.guidance_embeds and guidance is not None:
513-
guidance_proj = FlaxTimesteps(dim=256, flip_sin_to_cos=True, freq_shift=0)(guidance)
514+
guidance_proj = FlaxTimesteps(dim=self.frequency_embedding_size, flip_sin_to_cos=True, freq_shift=0)(guidance)
514515
guidance_emb = FlaxTimestepEmbedding(
515516
time_embed_dim=self.embedding_dim, dtype=self.dtype, weights_dtype=self.weights_dtype
516517
)(guidance_proj.astype(dtype))

0 commit comments

Comments
 (0)