patrickvonplaten commited on
Commit
93b080b
1 Parent(s): c9822f0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +15 -12
README.md CHANGED
@@ -58,20 +58,22 @@ In addition make sure to install `transformers`, `safetensors`, `accelerate` as
58
  pip install invisible_watermark transformers accelerate safetensors
59
  ```
60
 
61
- You can use the model then as follows
 
62
  ```py
63
- from diffusers import DiffusionPipeline
64
  import torch
65
-
66
- pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
67
- pipe.to("cuda")
68
-
69
- # if using torch < 2.0
70
- # pipe.enable_xformers_memory_efficient_attention()
71
-
72
- prompt = "An astronaut riding a green horse"
73
-
74
- images = pipe(prompt=prompt).images[0]
 
 
75
  ```
76
 
77
  When using `torch >= 2.0`, you can improve the inference speed by 20-30% with torch.compile. Simple wrap the unet with torch compile before running the pipeline:
@@ -87,6 +89,7 @@ instead of `.to("cuda")`:
87
  + pipe.enable_model_cpu_offload()
88
  ```
89
 
 
90
 
91
  ## Uses
92
 
 
58
  pip install invisible_watermark transformers accelerate safetensors
59
  ```
60
 
61
+ Yon can then use the refiner to improve images.
62
+
63
  ```py
 
64
  import torch
65
+ from diffusers import StableDiffusionXLImg2ImgPipeline
66
+ from diffusers.utils import load_image
67
+
68
+ pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(
69
+ "stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtype=torch.float16, variant="fp16", use_safetensors=True
70
+ )
71
+ pipe = pipe.to("cuda")
72
+ url = "https://huggingface.co/datasets/patrickvonplaten/images/resolve/main/aa_xl/000000009.png"
73
+
74
+ init_image = load_image(url).convert("RGB")
75
+ prompt = "a photo of an astronaut riding a horse on mars"
76
+ image = pipe(prompt, image=init_image).images
77
  ```
78
 
79
  When using `torch >= 2.0`, you can improve the inference speed by 20-30% with torch.compile. Simple wrap the unet with torch compile before running the pipeline:
 
89
  + pipe.enable_model_cpu_offload()
90
  ```
91
 
92
+ For more advanced use cases, please have a look at [the docs](https://huggingface.co/docs/diffusers/main/en/api/pipelines/stable_diffusion/stable_diffusion_xl).
93
 
94
  ## Uses
95