Basic SDXL text to image generation

This commit is contained in:
moshferatu 2023-11-08 09:50:10 -08:00
commit 817329ff04
2 changed files with 141 additions and 0 deletions

124
text-to-image.ipynb Normal file

File diff suppressed because one or more lines are too long

17
text-to-image.py Normal file
View File

@ -0,0 +1,17 @@
import torch
from diffusers import StableDiffusionXLPipeline
pipe = StableDiffusionXLPipeline.from_pretrained(
'stabilityai/stable-diffusion-xl-base-1.0',
torch_dtype=torch.float16,
use_safetensors=True,
variant='fp16')
pipe.to('cuda')
def generate_image(prompt: str):
return pipe(prompt=prompt, num_inference_steps=20).images[0]
image = generate_image('cthulhu, paper craft art, minimal detail')
image.show()
# image.save('image.png')