GitXplorerGitXplorer
o

consistencydecoder

public
2124 stars
74 forks
19 issues

Commits

List of commits on branch main.
Unverified
22a0449022f17a2d7bfc69535e8e8f3ff0585ecb

Initial commit

ggabgoh committed a year ago
Verified
b80b8df5b6280c1525b4f983c30b24961330cd12

Initial commit

ggabgoh committed a year ago

README

The README file for this repository.

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

import torch
from diffusers import StableDiffusionPipeline
from consistencydecoder import ConsistencyDecoder, save_image, load_image

# encode with stable diffusion vae
pipe = 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 GB

image = load_image("assets/gt1.png", size=(256, 256), center_crop=True)
latent = pipe.vae.encode(image.half().cuda()).latent_dist.mean

# decode with gan
sample_gan = pipe.vae.decode(latent).sample.detach()
save_image(sample_gan, "gan.png")

# decode with vae
sample_consistency = decoder_consistency(latent)
save_image(sample_consistency, "con.png")

Examples

Original Image GAN Decoder Consistency Decoder
Original Image GAN Image VAE Image
Original Image GAN Image VAE Image
Original Image GAN Image VAE Image