Spaces:
Paused
Paused
Download comfy/pixel_space_convert.py from raubatz/reactorswap-CPU: direct link, hf CLI and curl.
- Browser
- Download file 528 Bytes
-
https://huggingface.co/spaces/raubatz/reactorswap-CPU/resolve/main/comfy/pixel_space_convert.py
- Command line
-
hf download hf://spaces/raubatz/reactorswap-CPU/comfy/pixel_space_convert.py
-
curl -L -o pixel_space_convert.py https://huggingface.co/spaces/raubatz/reactorswap-CPU/resolve/main/comfy/pixel_space_convert.py
528 Bytes
| import torch | |
| # "Fake" VAE that converts from IMAGE B, H, W, C and values on the scale of 0..1 | |
| # to LATENT B, C, H, W and values on the scale of -1..1. | |
| class PixelspaceConversionVAE(torch.nn.Module): | |
| def __init__(self): | |
| super().__init__() | |
| self.pixel_space_vae = torch.nn.Parameter(torch.tensor(1.0)) | |
| def encode(self, pixels: torch.Tensor, *_args, **_kwargs) -> torch.Tensor: | |
| return pixels | |
| def decode(self, samples: torch.Tensor, *_args, **_kwargs) -> torch.Tensor: | |
| return samples | |