Spaces:
Running
on
Zero
Running
on
Zero
Update injection_main.py
Browse files- injection_main.py +12 -5
injection_main.py
CHANGED
@@ -236,15 +236,22 @@ def sample_disentangled(
|
|
236 |
generative_latent *= pipe.scheduler.init_noise_sigma
|
237 |
|
238 |
latents = start_latents.clone()
|
239 |
-
|
240 |
latents = latents.repeat(len(prompt), 1, 1, 1)
|
241 |
# randomly initialize the 1st latent for generation
|
242 |
-
|
243 |
latents[1] = generative_latent
|
244 |
-
|
|
|
|
|
245 |
for i in range(start_step, num_inference_steps):
|
246 |
-
if use_content_anchor:
|
247 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
248 |
t = pipe.scheduler.timesteps[i]
|
249 |
|
250 |
# Expand the latents if we are doing classifier free guidance
|
|
|
236 |
generative_latent *= pipe.scheduler.init_noise_sigma
|
237 |
|
238 |
latents = start_latents.clone()
|
|
|
239 |
latents = latents.repeat(len(prompt), 1, 1, 1)
|
240 |
# randomly initialize the 1st latent for generation
|
|
|
241 |
latents[1] = generative_latent
|
242 |
+
|
243 |
+
num_intermediate_latents = len(intermediate_latents) if intermediate_latents is not None else 0
|
244 |
+
|
245 |
for i in range(start_step, num_inference_steps):
|
246 |
+
if use_content_anchor and intermediate_latents is not None:
|
247 |
+
# Ensure that the index is within bounds
|
248 |
+
if -i >= -num_intermediate_latents:
|
249 |
+
latents[0] = intermediate_latents[-i]
|
250 |
+
else:
|
251 |
+
# Handle case when the index is out of bounds
|
252 |
+
# You could use a default latent or skip this step
|
253 |
+
latents[0] = intermediate_latents[0] # Example: use the first latent
|
254 |
+
|
255 |
t = pipe.scheduler.timesteps[i]
|
256 |
|
257 |
# Expand the latents if we are doing classifier free guidance
|