(
self,
model,
vae,
noise,
sampler,
sigmas,
guider,
latents,
horizontal_tiles,
vertical_tiles,
overlap,
latents_cond_strength,
boost_latent_similarity,
crop="disabled",
optional_cond_images=None,
optional_cond_indices="0",
images_cond_strengths="0.9",
)
| 59 | CATEGORY = "sampling" |
| 60 | |
| 61 | def sample( |
| 62 | self, |
| 63 | model, |
| 64 | vae, |
| 65 | noise, |
| 66 | sampler, |
| 67 | sigmas, |
| 68 | guider, |
| 69 | latents, |
| 70 | horizontal_tiles, |
| 71 | vertical_tiles, |
| 72 | overlap, |
| 73 | latents_cond_strength, |
| 74 | boost_latent_similarity, |
| 75 | crop="disabled", |
| 76 | optional_cond_images=None, |
| 77 | optional_cond_indices="0", |
| 78 | images_cond_strengths="0.9", |
| 79 | ): |
| 80 | |
| 81 | # Get the latent samples |
| 82 | samples = latents["samples"] |
| 83 | |
| 84 | batch, channels, frames, height, width = samples.shape |
| 85 | time_scale_factor, width_scale_factor, height_scale_factor = ( |
| 86 | vae.downscale_index_formula |
| 87 | ) |
| 88 | # Validate image dimensions if provided |
| 89 | if optional_cond_images is not None: |
| 90 | img_height = height * height_scale_factor |
| 91 | img_width = width * width_scale_factor |
| 92 | cond_images = comfy.utils.common_upscale( |
| 93 | optional_cond_images.movedim(-1, 1), |
| 94 | img_width, |
| 95 | img_height, |
| 96 | "bicubic", |
| 97 | crop=crop, |
| 98 | ).movedim(1, -1) |
| 99 | img_batch, img_height, img_width, img_channels = cond_images.shape |
| 100 | else: |
| 101 | cond_images = None |
| 102 | |
| 103 | if optional_cond_indices is not None and optional_cond_images is not None: |
| 104 | optional_cond_indices = optional_cond_indices.split(",") |
| 105 | optional_cond_indices = [int(i) for i in optional_cond_indices] |
| 106 | assert len(optional_cond_indices) == len( |
| 107 | optional_cond_images |
| 108 | ), "Number of optional cond images must match number of optional cond indices" |
| 109 | |
| 110 | images_cond_strengths = [float(i) for i in images_cond_strengths.split(",")] |
| 111 | if optional_cond_images is not None and len(images_cond_strengths) < len( |
| 112 | optional_cond_images |
| 113 | ): |
| 114 | # Repeat the last value to match the length of optional_cond_images |
| 115 | images_cond_strengths = images_cond_strengths + [ |
| 116 | images_cond_strengths[-1] |
| 117 | ] * (len(optional_cond_images) - len(images_cond_strengths)) |
| 118 |
nothing calls this directly
no test coverage detected