MCPcopy Create free account
hub / github.com/00why00/JoDiffusion / encode

Method encode

pipelines/modeling_lightweight_vae.py:183–192  ·  view source on GitHub ↗
(
        self, x: torch.Tensor, return_dict: bool = True
    )

Source from the content-addressed store, hash-verified

181
182 @apply_forward_hook
183 def encode(
184 self, x: torch.Tensor, return_dict: bool = True
185 ) -> Union[AutoencoderKLOutput, Tuple[DiagonalGaussianDistribution]]:
186 moments = self.encoder(x)
187 posterior = DiagonalGaussianDistribution(moments)
188
189 if not return_dict:
190 return (posterior,)
191
192 return AutoencoderKLOutput(latent_dist=posterior)
193
194 @apply_forward_hook
195 def decode(self, z: torch.Tensor, interpolate=True, return_dict: bool = True) -> Union[DecoderOutput, Tuple[torch.Tensor]]:

Callers 2

forwardMethod · 0.95
encode_imagesFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected