MCPcopy Create free account
hub / github.com/IceClear/StableSR / sample

Method sample

ldm/models/diffusion/ddpm.py:1382–1397  ·  view source on GitHub ↗
(self, cond, batch_size=16, return_intermediates=False, x_T=None,
               verbose=True, timesteps=None, quantize_denoised=False,
               mask=None, x0=None, shape=None,**kwargs)

Source from the content-addressed store, hash-verified

1380
1381 @torch.no_grad()
1382 def sample(self, cond, batch_size=16, return_intermediates=False, x_T=None,
1383 verbose=True, timesteps=None, quantize_denoised=False,
1384 mask=None, x0=None, shape=None,**kwargs):
1385 if shape is None:
1386 shape = (batch_size, self.channels, self.image_size//8, self.image_size//8)
1387 if cond is not None:
1388 if isinstance(cond, dict):
1389 cond = {key: cond[key][:batch_size] if not isinstance(cond[key], list) else
1390 list(map(lambda x: x[:batch_size], cond[key])) for key in cond}
1391 else:
1392 cond = [c[:batch_size] for c in cond] if isinstance(cond, list) else cond[:batch_size]
1393 return self.p_sample_loop(cond,
1394 shape,
1395 return_intermediates=return_intermediates, x_T=x_T,
1396 verbose=verbose, timesteps=timesteps, quantize_denoised=quantize_denoised,
1397 mask=mask, x0=x0)
1398
1399 @torch.no_grad()
1400 def sample_log(self,cond,batch_size,ddim, ddim_steps,**kwargs):

Callers 1

sample_logMethod · 0.95

Calls 1

p_sample_loopMethod · 0.95

Tested by

no test coverage detected