Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

Repository files navigation

Consistency Decoder

[DALL·E 3][Improving Image Generation with Better Captions][Consistency Models]

Improved decoding for stable diffusion vaes.

Installation

$ pip install git+https://github.com/openai/consistencydecoder.git

Usage

importtorchfromdiffusersimportStableDiffusionPipelinefromconsistencydecoderimportConsistencyDecoder, save_image, load_image# encode with stable diffusion vaepipe=StableDiffusionPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16, device="cuda:0"
)
pipe.vae.cuda()
decoder_consistency=ConsistencyDecoder(device="cuda:0") # Model size: 2.49 GBimage=load_image("assets/gt1.png", size=(256, 256), center_crop=True)
latent=pipe.vae.encode(image.half().cuda()).latent_dist.mean# decode with gansample_gan=pipe.vae.decode(latent).sample.detach()
save_image(sample_gan, "gan.png")
# decode with vaesample_consistency=decoder_consistency(latent)
save_image(sample_consistency, "con.png")

Examples

Original ImageGAN DecoderConsistency Decoder
Original ImageGAN ImageVAE Image
Original ImageGAN ImageVAE Image
Original ImageGAN ImageVAE Image

About

Consistency Distilled Diff VAE

Resources

Security policy

Stars

2.2k stars

Watchers

20 watching

Forks

Releases

Packages

Used by

Contributors

Languages