Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| # Используем официальную модель | |
| model_id = "CompVis/stable-diffusion-v1-4" | |
| # Загружаем модель без указания torch_dtype для работы на CPU | |
| pipe = StableDiffusionPipeline.from_pretrained(model_id) | |
| pipe.to("cpu") # Переносим модель на CPU | |
| def generate_image(prompt): | |
| image = pipe(prompt).images[0] | |
| return image | |
| # Запуск Gradio интерфейса с публичной ссылкой | |
| gr.Interface( | |
| fn=generate_image, | |
| inputs="text", | |
| outputs="image", | |
| title="Stable Diffusion WebUI" | |
| ).launch(share=True) | |