concauu commited on
Commit
0981b86
·
verified ·
1 Parent(s): 95b5847

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -186,15 +186,15 @@ pipe.encode_prompt = custom_encode_prompt.__get__(pipe)
186
 
187
  pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
188
 
189
- def patched_time_embed(x):
190
- # Get the weight and bias from the time embedder.
191
- weight = pipe.transformer.time_text_embed.weight # shape: (768, 3072)
192
- bias = pipe.transformer.time_text_embed.bias
193
- # Transpose weight to shape (3072, 768) so that input (B, 3072) can multiply correctly.
194
- return F.linear(x, weight.t(), bias)
195
-
196
- # Apply the patch:
197
- pipe.transformer.time_text_embed.forward = patched_time_embed
198
  # History functions
199
  def append_to_history(image, prompt, seed, width, height, guidance_scale, steps, history):
200
  """Store only the final generated image"""
 
186
 
187
  pipe.flux_pipe_call_that_returns_an_iterable_of_images = flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
188
 
189
+ def patched_time_embed(self, timestep, guidance, pooled_projections):
190
+ # 'timestep' and 'guidance' are not used in our patch; we operate on pooled_projections.
191
+ weight = self.weight # shape should be (768, 3072)
192
+ bias = self.bias # shape (768,)
193
+ # Transpose weight so that pooled_projections (shape (B, 3072)) multiplies correctly:
194
+ return F.linear(pooled_projections, weight.t(), bias)
195
+
196
+ # Patch the time embedder on the transformer:
197
+ pipe.transformer.time_text_embed.forward = patched_time_embed.__get__(pipe.transformer.time_text_embed)
198
  # History functions
199
  def append_to_history(image, prompt, seed, width, height, guidance_scale, steps, history):
200
  """Store only the final generated image"""