Spaces:
Sleeping
Sleeping
Download imagebuilder.py from rahulmolasi/text2image: direct link, hf CLI and curl.
- Browser
- Download file 592 Bytes
-
https://huggingface.co/spaces/rahulmolasi/text2image/resolve/main/imagebuilder.py
- Command line
-
hf download hf://spaces/rahulmolasi/text2image/imagebuilder.py
-
curl -L -o imagebuilder.py https://huggingface.co/spaces/rahulmolasi/text2image/resolve/main/imagebuilder.py
592 Bytes
| from diffusers import StableDiffusionPipeline | |
| import matplotlib.pyplot as plt | |
| import torch | |
| model_id1 = "dreamlike-art/dreamlike-diffusion-1.0" | |
| pipe = StableDiffusionPipeline.from_pretrained(model_id1, torch_dtype=torch.float16) | |
| pipe = pipe.to("cuda") | |
| def generate(prompt): | |
| image = pipe(prompt).images[0] | |
| return image | |
| # Gradio interface | |
| demo = gr.Interface( | |
| fn=generate, | |
| inputs=gr.Textbox(label="Enter your prompt"), | |
| outputs=gr.Image(label="Generated Image"), | |
| title="Text to Image Generator", | |
| description="Powered by Stable Diffusion" | |
| ) | |
| demo.launch(share=True) | |