Вот мой код:
Код: Выделить всё
from diffusers import StableDiffusionPipeline
import torch
# Load the pre-trained Stable Diffusion model
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4")
pipe = pipe.to("cuda")
# Define the prompt
prompt = "a futuristic cityscape, high resolution, ultra detailed"
# Generate the image
image = pipe(prompt).images[0]
# Show the image
image.show()
< /code>
Я попытался запустить код, как показано выше, ожидая, что он сгенерирует высококачественное изображение из текстовой подсказки без проблем с памятью. Я также попытался добавить TORCH_DTYPE = TORCH.FLOAT16
pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4", torch_dtype=torch.float16)
pipe = pipe.to("cuda")
< /code>
Однако я все еще сталкиваюсь с ошибками в памяти, особенно с более крупными подсказками или более высокими разрешениями. Я ожидал, что настройка Float16 поможет, но она не полностью решила проблему.>
Подробнее здесь: https://stackoverflow.com/questions/795 ... ingface-di