Download scripts/decode.py from WeReCooking/DFlow2-4step-ONNX-WebGPU: direct link, hf CLI and curl.
- Browser
- Download file 505 Bytes
-
https://huggingface.co/WeReCooking/DFlow2-4step-ONNX-WebGPU/resolve/main/scripts/decode.py
- Command line
-
hf download hf://WeReCooking/DFlow2-4step-ONNX-WebGPU/scripts/decode.py
-
curl -L -o decode.py https://huggingface.co/WeReCooking/DFlow2-4step-ONNX-WebGPU/resolve/main/scripts/decode.py
505 Bytes
| """Decode saved latents with the PyTorch dinac3 decoder (fp32): decode.py LATENT.npy OUT.png""" | |
| import sys | |
| import numpy as np, torch | |
| from PIL import Image | |
| import dfl | |
| torch.set_num_threads(4) | |
| vae = dfl.load_vae() | |
| x = torch.from_numpy(np.load(sys.argv[1])).float() | |
| with torch.no_grad(): | |
| rgb = vae.decode(x, x.shape[2] * 16, x.shape[3] * 16).clamp(-1, 1) | |
| Image.fromarray(((rgb[0].permute(1, 2, 0).numpy() + 1) * 127.5).round().clip(0, 255).astype(np.uint8)).save(sys.argv[2]) | |
| print("saved", sys.argv[2]) | |