MCPcopy Create free account
hub / github.com/AlayaLab/Hive / get_codebook_entry

Method get_codebook_entry

models/flowsep/diffusers/models/vae.py:379–394  ·  view source on GitHub ↗
(self, indices, shape)

Source from the content-addressed store, hash-verified

377 return z_q, loss, (perplexity, min_encodings, min_encoding_indices)
378
379 def get_codebook_entry(self, indices, shape):
380 # shape specifying (batch, height, width, channel)
381 if self.remap is not None:
382 indices = indices.reshape(shape[0], -1) # add batch axis
383 indices = self.unmap_to_all(indices)
384 indices = indices.reshape(-1) # flatten again
385
386 # get quantized latent vectors
387 z_q = self.embedding(indices)
388
389 if shape is not None:
390 z_q = z_q.view(shape)
391 # reshape back to match original input shape
392 z_q = z_q.permute(0, 3, 1, 2).contiguous()
393
394 return z_q
395
396
397class DiagonalGaussianDistribution(object):

Callers 1

__call__Method · 0.80

Calls 1

unmap_to_allMethod · 0.95

Tested by

no test coverage detected