MCPcopy
hub / github.com/vladmandic/sdnext / images_tensor_to_samples

Function images_tensor_to_samples

modules/processing_helpers.py:142–155  ·  view source on GitHub ↗
(image, approximation=None, model=None)

Source from the content-addressed store, hash-verified

140
141
142def images_tensor_to_samples(image, approximation=None, model=None): # pylint: disable=unused-argument
143 if model is None:
144 model = shared.sd_model
145 model.first_stage_model.to(devices.dtype_vae)
146 image = image.to(shared.device, dtype=devices.dtype_vae)
147 image = image * 2 - 1
148 if len(image) > 1:
149 x_latent = torch.stack([
150 model.get_first_stage_encoding(model.encode_first_stage(torch.unsqueeze(img, 0)))[0]
151 for img in image
152 ])
153 else:
154 x_latent = model.get_first_stage_encoding(model.encode_first_stage(image))
155 return x_latent
156
157
158def get_sampler_name(sampler_index: int | None = None, img: bool = False) -> str:

Callers

nothing calls this directly

Calls 1

toMethod · 0.45

Tested by

no test coverage detected