Skip to content

Commit 231bdf2

Browse files
authored
UnCLIP Image Interpolation -> Keep same initial noise across interpolation steps (#3782)
* Maintain same decoder start noise for all interp steps * Correct comment * use batch_size for consistency
1 parent 75124fc commit 231bdf2

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

examples/community/unclip_image_interpolation.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,16 @@ def __call__(
376376
height = self.decoder.config.sample_size
377377
width = self.decoder.config.sample_size
378378

379+
# Get the decoder latents for 1 step and then repeat the same tensor for the entire batch to keep same noise across all interpolation steps.
379380
decoder_latents = self.prepare_latents(
380-
(batch_size, num_channels_latents, height, width),
381+
(1, num_channels_latents, height, width),
381382
text_encoder_hidden_states.dtype,
382383
device,
383384
generator,
384385
decoder_latents,
385386
self.decoder_scheduler,
386387
)
388+
decoder_latents = decoder_latents.repeat((batch_size, 1, 1, 1))
387389

388390
for i, t in enumerate(self.progress_bar(decoder_timesteps_tensor)):
389391
# expand the latents if we are doing classifier free guidance

0 commit comments

Comments
 (0)