Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| # تحميل النموذج | |
| pipe = StableDiffusionPipeline.from_pretrained("CompVis/stable-diffusion-v1-4") | |
| pipe.to("cuda" if torch.cuda.is_available() else "cpu") | |
| # دالة توليد الصورة من النص | |
| def generate_image(prompt): | |
| image = pipe(prompt).images[0] | |
| return image | |
| # واجهة Gradio | |
| gr.Interface( | |
| fn=generate_image, | |
| inputs="text", | |
| outputs="image", | |
| title="Text to Image Generator ✨" | |
| ).launch(share=True) | |