import torch; from diffusers import StableDiffusionPipeline; model_id = "CompVis/stable-diffusion-v1-4"; pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16); def text_to_image(text): image = pipe(text).images[0]; image.save("image.png"); text_to_image("A futuristic cityscape with flying cars and towering skyscrapers.");