(
self,
cond: Dict,
uc: Union[Dict, None] = None,
batch_size: int = 16,
shape: Union[None, Tuple, List] = None,
prefix=None,
concat_images=None,
flow=None,
aroutput=None,
**kwargs,
)
| 249 | |
| 250 | @torch.no_grad() |
| 251 | def sample( |
| 252 | self, |
| 253 | cond: Dict, |
| 254 | uc: Union[Dict, None] = None, |
| 255 | batch_size: int = 16, |
| 256 | shape: Union[None, Tuple, List] = None, |
| 257 | prefix=None, |
| 258 | concat_images=None, |
| 259 | flow=None, |
| 260 | aroutput=None, |
| 261 | **kwargs, |
| 262 | ): |
| 263 | # breakpoint() |
| 264 | #torch.manual_seed(23) |
| 265 | #torch.cuda.manual_seed(23) |
| 266 | #print('FIX SEED TO 23') |
| 267 | randn = torch.randn(batch_size, *shape).to(torch.float32).to(self.device) |
| 268 | if hasattr(self, "seeded_noise"): |
| 269 | randn = self.seeded_noise(randn) |
| 270 | |
| 271 | if prefix is not None: |
| 272 | randn = torch.cat([prefix, randn[:, prefix.shape[1] :]], dim=1) |
| 273 | |
| 274 | # broadcast noise |
| 275 | mp_size = mpu.get_model_parallel_world_size() |
| 276 | if mp_size > 1: |
| 277 | global_rank = torch.distributed.get_rank() // mp_size |
| 278 | src = global_rank * mp_size |
| 279 | torch.distributed.broadcast(randn, src=src, group=mpu.get_model_parallel_group()) |
| 280 | |
| 281 | scale = None |
| 282 | scale_emb = None |
| 283 | denoiser = lambda input, sigma, c, **addtional_model_inputs: self.denoiser( |
| 284 | self.model, input, sigma, c, concat_images=concat_images, **addtional_model_inputs |
| 285 | ) |
| 286 | |
| 287 | samples = self.sampler(denoiser, randn, cond, uc=uc, scale=scale, scale_emb=scale_emb, flow=flow, aroutput=aroutput) |
| 288 | samples = samples.to(self.dtype) |
| 289 | return samples |
| 290 | |
| 291 | @torch.no_grad() |
| 292 | def log_conditionings(self, batch: Dict, n: int) -> Dict: |
no outgoing calls
no test coverage detected