(
self,
positive,
negative,
vae,
latent,
image,
frame_idx,
strength,
crf,
blur_radius,
interpolation,
crop,
attention_strength=1.0,
attention_mask=None,
)
| 367 | ) |
| 368 | |
| 369 | def generate( |
| 370 | self, |
| 371 | positive, |
| 372 | negative, |
| 373 | vae, |
| 374 | latent, |
| 375 | image, |
| 376 | frame_idx, |
| 377 | strength, |
| 378 | crf, |
| 379 | blur_radius, |
| 380 | interpolation, |
| 381 | crop, |
| 382 | attention_strength=1.0, |
| 383 | attention_mask=None, |
| 384 | ): |
| 385 | from .iclora_attention import append_guide_attention_entry, normalize_mask |
| 386 | |
| 387 | # Preprocessing: resize, CRF, blur (same as LTXVAddGuideAdvanced) |
| 388 | scale_factors = vae.downscale_index_formula |
| 389 | _, width_scale_factor, height_scale_factor = scale_factors |
| 390 | latent_image = latent["samples"] |
| 391 | noise_mask = nodes_lt.get_noise_mask(latent) |
| 392 | _, _, latent_length, latent_height, latent_width = latent_image.shape |
| 393 | |
| 394 | width = latent_width * width_scale_factor |
| 395 | height = latent_height * height_scale_factor |
| 396 | image = ( |
| 397 | comfy.utils.common_upscale( |
| 398 | image.movedim(-1, 1), width, height, interpolation, crop=crop |
| 399 | ) |
| 400 | .movedim(1, -1) |
| 401 | .clamp(0, 1) |
| 402 | ) |
| 403 | image = nodes_lt.LTXVPreprocess().execute(image, crf)[0] |
| 404 | image = blur_internal(image, blur_radius) |
| 405 | |
| 406 | # Encode |
| 407 | _, t = nodes_lt.LTXVAddGuide.encode( |
| 408 | vae, latent_width, latent_height, image, scale_factors |
| 409 | ) |
| 410 | |
| 411 | # Compute latent index |
| 412 | frame_idx, latent_idx = nodes_lt.LTXVAddGuide.get_latent_index( |
| 413 | positive, latent_length, len(image), frame_idx, scale_factors |
| 414 | ) |
| 415 | assert ( |
| 416 | latent_idx + t.shape[2] <= latent_length |
| 417 | ), "Conditioning frames exceed the length of the latent sequence." |
| 418 | |
| 419 | # Append keyframe |
| 420 | positive, negative, latent_image, noise_mask = ( |
| 421 | nodes_lt.LTXVAddGuide.append_keyframe( |
| 422 | positive, |
| 423 | negative, |
| 424 | frame_idx, |
| 425 | latent_image, |
| 426 | noise_mask, |
nothing calls this directly
no test coverage detected