MCPcopy Create free account
hub / github.com/bbaaii/DreamDiffusion / get_codebook_entry

Method get_codebook_entry

code/dc_ldm/models/autoencoder.py:118–133  ·  view source on GitHub ↗
(self, indices, shape)

Source from the content-addressed store, hash-verified

116 return z_q, loss, (perplexity, min_encodings, min_encoding_indices)
117
118 def get_codebook_entry(self, indices, shape):
119 # shape specifying (batch, height, width, channel)
120 if self.remap is not None:
121 indices = indices.reshape(shape[0],-1) # add batch axis
122 indices = self.unmap_to_all(indices)
123 indices = indices.reshape(-1) # flatten again
124
125 # get quantized latent vectors
126 z_q = self.embedding(indices)
127
128 if shape is not None:
129 z_q = z_q.view(shape)
130 # reshape back to match original input shape
131 z_q = z_q.permute(0, 3, 1, 2).contiguous()
132
133 return z_q
134
135class VQModel(pl.LightningModule):
136 def __init__(self,

Callers 2

decode_first_stageMethod · 0.80

Calls 1

unmap_to_allMethod · 0.95

Tested by

no test coverage detected