17 lines
462 B
Python
17 lines
462 B
Python
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') |