cross-attention
commited on
Commit
•
a2ba96d
1
Parent(s):
b7571e1
add model_card
Browse files
README.md
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
tags:
|
3 |
+
- stable-diffusion
|
4 |
+
- stable-diffusion-diffusers
|
5 |
+
inference: false
|
6 |
+
library_name: diffusers
|
7 |
+
---
|
8 |
+
# Asymmetric Autoencoder KL
|
9 |
+
|
10 |
+
[Designing a Better Asymmetric VQGAN for StableDiffusion](https://arxiv.org/abs/2306.04632)
|
11 |
+
|
12 |
+
## Abstract
|
13 |
+
*StableDiffusion is a revolutionary text-to-image generator that is causing a stir in the world of image generation and editing. Unlike traditional methods that learn a diffusion model in pixel space, StableDiffusion learns a diffusion model in the latent space via a VQGAN, ensuring both efficiency and quality. It not only supports image generation tasks, but also enables image editing for real images, such as image inpainting and local editing. However, we have observed that the vanilla VQGAN used in StableDiffusion leads to significant information loss, causing distortion artifacts even in non-edited image regions. To this end, we propose a new asymmetric VQGAN with two simple designs. Firstly, in addition to the input from the encoder, the decoder contains a conditional branch that incorporates information from task-specific priors, such as the unmasked image region in inpainting. Secondly, the decoder is much heavier than the encoder, allowing for more detailed recovery while only slightly increasing the total inference cost. The training cost of our asymmetric VQGAN is cheap, and we only need to retrain a new asymmetric decoder while keeping the vanilla VQGAN encoder and StableDiffusion unchanged. Our asymmetric VQGAN can be widely used in StableDiffusion-based inpainting and local editing methods. Extensive experiments demonstrate that it can significantly improve the inpainting and editing performance, while maintaining the original text-to-image capability. The code is available at https://github.com/buxiangzhiren/Asymmetric_VQGAN/tree/main*
|
14 |
+
|
15 |
+
## Scales
|
16 |
+
* https://huggingface.co/cross-attention/asymmetric-autoencoder-kl-x-1-5
|
17 |
+
* https://huggingface.co/cross-attention/asymmetric-autoencoder-kl-x-2
|
18 |
+
|
19 |
+
## Diffusers
|
20 |
+
```python
|
21 |
+
from diffusers import AsymmetricAutoencoderKL, StableDiffusionInpaintPipeline
|
22 |
+
|
23 |
+
pipe = StableDiffusionInpaintPipeline.from_pretrained(
|
24 |
+
"runwayml/stable-diffusion-inpainting"
|
25 |
+
)
|
26 |
+
pipe.vae = AsymmetricAutoencoderKL.from_pretrained(
|
27 |
+
"cross-attention/asymmetric-autoencoder-kl-x-2"
|
28 |
+
)
|
29 |
+
|
30 |
+
image = pipe(prompt=prompt, image=image, mask_image=mask_image).images[0]
|
31 |
+
```
|
32 |
+
|
33 |
+
### Visual
|
34 |
+
_Visualization of VAE perfomance on 512x512 image with runwayml/stable-diffusion-inpainting_
|
35 |
+
|
36 |
+
<p align="center">
|
37 |
+
<br>original image, masked image, mask
|
38 |
+
<br><b>runwayml/stable-diffusion-inpainting original VAE</b>
|
39 |
+
<br><b>stabilityai/sd-vae-ft-mse VAE</b>
|
40 |
+
<br><b>Asymmetric Autoencoder KL x1.5 VAE</b>
|
41 |
+
<br><b>Asymmetric Autoencoder KL x2 VAE</b>
|
42 |
+
</p>
|
43 |
+
|
44 |
+
<p align="center">
|
45 |
+
<img src=https://huggingface.co/cross-attention/asymmetric-autoencoder-kl-x-2/resolve/main/compare.jpeg width="50%"/>
|
46 |
+
</p>
|