diff options
| author | chzhang <zch921005@126.com> | 2022-11-05 19:36:49 +0800 |
|---|---|---|
| committer | chzhang <zch921005@126.com> | 2022-11-05 19:36:49 +0800 |
| commit | 24da1a1db479f26d2b854102d817baf4fa412b6e (patch) | |
| tree | 9980388a299290c5b976599515ab27320051da55 /diffusion/tutorials/01_tut.py | |
| parent | 1b105470efecf90fe1a7e153191835cf0c4dfb19 (diff) | |
stable diffusion 01
Diffstat (limited to 'diffusion/tutorials/01_tut.py')
| -rw-r--r-- | diffusion/tutorials/01_tut.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/diffusion/tutorials/01_tut.py b/diffusion/tutorials/01_tut.py new file mode 100644 index 0000000..beb6819 --- /dev/null +++ b/diffusion/tutorials/01_tut.py @@ -0,0 +1,17 @@ + +from torch import autocast +from diffusers import StableDiffusionPipeline +from PIL import Image +prompt = 'a photo of an astronaut riding a horse on mars' + +pipeline = StableDiffusionPipeline.from_pretrained('CompVis/stable-diffusion-v1-4', + use_auth_token=True, + revision='fp16' + ).to('cuda') +with autocast('cuda'): + output = pipeline(prompt) + +print(output) +img = output['images'][0] +img.show() +img.save('./output/fp16.png') |
