Spaces:
No application file
No application file
Download Generation.py from sandeep2003/Text_to_Image: direct link, hf CLI and curl.
- Browser
- Download file 653 Bytes
-
https://huggingface.co/spaces/sandeep2003/Text_to_Image/resolve/main/Generation.py
- Command line
-
hf download hf://spaces/sandeep2003/Text_to_Image/Generation.py
-
curl -L -o Generation.py https://huggingface.co/spaces/sandeep2003/Text_to_Image/resolve/main/Generation.py
653 Bytes
| pip install --upgrade git+https://github.com/huggingface/diffusers.git transformers accelerate scipy | |
| import torch | |
| from diffusers import StableDiffusionPipeline, EulerDiscreteScheduler | |
| torch.manual_seed(1000) | |
| model_id = "stabilityai/stable-diffusion-2" | |
| # Use the Euler scheduler here instead | |
| scheduler = EulerDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler") | |
| pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, revision="fp16", torch_dtype=torch.float16) | |
| pipe = pipe.to("cuda") | |
| prompt = input() | |
| image = pipe(prompt).images[0] | |
| image.save("./image.png") | |
| from IPython.display import Image | |
| Image("./image.png") | |