MCPcopy Create free account
hub / github.com/TencentARC/BrushNet / decode

Method decode

src/diffusers/models/vq_model.py:140–156  ·  view source on GitHub ↗
(
        self, h: torch.FloatTensor, force_not_quantize: bool = False, return_dict: bool = True, shape=None
    )

Source from the content-addressed store, hash-verified

138
139 @apply_forward_hook
140 def decode(
141 self, h: torch.FloatTensor, force_not_quantize: bool = False, return_dict: bool = True, shape=None
142 ) -> Union[DecoderOutput, torch.FloatTensor]:
143 # also go through quantization layer
144 if not force_not_quantize:
145 quant, _, _ = self.quantize(h)
146 elif self.config.lookup_from_codebook:
147 quant = self.quantize.get_codebook_entry(h, shape)
148 else:
149 quant = h
150 quant2 = self.post_quant_conv(quant)
151 dec = self.decoder(quant2, quant if self.config.norm_type == "spatial" else None)
152
153 if not return_dict:
154 return (dec,)
155
156 return DecoderOutput(sample=dec)
157
158 def forward(
159 self, sample: torch.FloatTensor, return_dict: bool = True

Calls 2

DecoderOutputClass · 0.85
get_codebook_entryMethod · 0.80