(
self,
cond: Dict,
uc: Union[Dict, None] = None,
batch_size: int = 16,
shape: Union[None, Tuple, List] = None,
prefix=None, # * enabled for predictive mode: sampling_kwargs['prefix'] = z[:, self.cond_inds]
concat_images=None,
**kwargs,
)
| 259 | |
| 260 | @torch.no_grad() |
| 261 | def sample( |
| 262 | self, |
| 263 | cond: Dict, |
| 264 | uc: Union[Dict, None] = None, |
| 265 | batch_size: int = 16, |
| 266 | shape: Union[None, Tuple, List] = None, |
| 267 | prefix=None, # * enabled for predictive mode: sampling_kwargs['prefix'] = z[:, self.cond_inds] |
| 268 | concat_images=None, |
| 269 | **kwargs, |
| 270 | ): |
| 271 | randn = torch.randn(batch_size, *shape).to(torch.float32).to(self.device) |
| 272 | if hasattr(self, "seeded_noise"): |
| 273 | randn = self.seeded_noise(randn) |
| 274 | |
| 275 | if prefix is not None: |
| 276 | randn = torch.cat([prefix, randn[:, prefix.shape[1] :]], dim=1) |
| 277 | |
| 278 | # broadcast noise |
| 279 | mp_size = mpu.get_model_parallel_world_size() |
| 280 | if mp_size > 1: |
| 281 | global_rank = torch.distributed.get_rank() // mp_size |
| 282 | src = global_rank * mp_size |
| 283 | torch.distributed.broadcast(randn, src=src, group=mpu.get_model_parallel_group()) |
| 284 | |
| 285 | # * Why is scale None? |
| 286 | # * scale will be determined within the guider |
| 287 | scale = None |
| 288 | scale_emb = None |
| 289 | |
| 290 | denoiser = lambda input, sigma, c, **addtional_model_inputs: self.denoiser( |
| 291 | self.model, input, sigma, c, concat_images=concat_images, **addtional_model_inputs |
| 292 | ) |
| 293 | |
| 294 | |
| 295 | fixed_frames = prefix.shape[1] if prefix is not None else None |
| 296 | |
| 297 | samples = self.sampler(denoiser, randn, cond, uc=uc, scale=scale, scale_emb=scale_emb, |
| 298 | fixed_frames=fixed_frames, |
| 299 | **kwargs) # go to VPSDEDPMPP2MSampler |
| 300 | samples = samples.to(self.dtype) |
| 301 | return samples |
| 302 | |
| 303 | @torch.no_grad() |
| 304 | def log_conditionings(self, batch: Dict, n: int) -> Dict: |
no test coverage detected