rootonchair commited on
Commit
4422f13
1 Parent(s): 80d5501

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +51 -3
README.md CHANGED
@@ -1,3 +1,51 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+ # Diffusers API of Transparent Image Layer Diffusion using Latent Transparency
5
+ Create transparent image with Diffusers!
6
+
7
+ Please check the Github repo [here](https://github.com/rootonchair/diffuser_layerdiffuse)
8
+
9
+ This is a port to Diffuser from original [SD Webui's Layer Diffusion](https://github.com/layerdiffusion/sd-forge-layerdiffuse) to extend the ability to generate transparent image with your favorite API
10
+
11
+
12
+ Paper: [Transparent Image Layer Diffusion using Latent Transparency](https://arxiv.org/abs/2402.17113)
13
+ ## Quickstart
14
+
15
+ Generate transparent image with SD1.5 models. In this example, we will use [digiplay/Juggernaut_final](https://huggingface.co/digiplay/Juggernaut_final) as the base model
16
+
17
+ ```python
18
+ from huggingface_hub import hf_hub_download
19
+ from safetensors.torch import load_file
20
+ import torch
21
+
22
+ from diffusers import StableDiffusionPipeline
23
+
24
+ from models import TransparentVAEDecoder
25
+ from loaders import load_lora_to_unet
26
+
27
+
28
+
29
+ if __name__ == "__main__":
30
+
31
+ model_path = hf_hub_download(
32
+ 'LayerDiffusion/layerdiffusion-v1',
33
+ 'layer_sd15_vae_transparent_decoder.safetensors',
34
+ )
35
+
36
+ vae_transparent_decoder = TransparentVAEDecoder.from_pretrained("digiplay/Juggernaut_final", subfolder="vae", torch_dtype=torch.float16).to("cuda")
37
+ vae_transparent_decoder.set_transparent_decoder(load_file(model_path))
38
+
39
+ pipeline = StableDiffusionPipeline.from_pretrained("digiplay/Juggernaut_final", vae=vae_transparent_decoder, torch_dtype=torch.float16, safety_checker=None).to("cuda")
40
+
41
+ model_path = hf_hub_download(
42
+ 'LayerDiffusion/layerdiffusion-v1',
43
+ 'layer_sd15_transparent_attn.safetensors'
44
+ )
45
+
46
+ load_lora_to_unet(pipeline.unet, model_path, frames=1)
47
+
48
+ image = pipeline(prompt="a dog sitting in room, high quality",
49
+ width=512, height=512,
50
+ num_images_per_prompt=1, return_dict=False)[0]
51
+ ```