Spaces:
Running
Running
Download app.py from marahaa/image-generator-sd: direct link, hf CLI and curl.
- Browser
- Download file 534 Bytes
-
https://huggingface.co/spaces/marahaa/image-generator-sd/resolve/main/app.py
- Command line
-
hf download hf://spaces/marahaa/image-generator-sd/app.py
-
curl -L -o app.py https://huggingface.co/spaces/marahaa/image-generator-sd/resolve/main/app.py
534 Bytes
| 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) | |