Spaces:
Sleeping
Sleeping
Download app.py from Python25/my-image-generator: direct link, hf CLI and curl.
- Browser
- Download file 396 Bytes
-
https://huggingface.co/spaces/Python25/my-image-generator/resolve/main/app.py
- Command line
-
hf download hf://spaces/Python25/my-image-generator/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Python25/my-image-generator/resolve/main/app.py
396 Bytes
| import gradio as gr | |
| from diffusers import StableDiffusionPipeline | |
| import torch | |
| # Load the model without torch_dtype=torch.float16 | |
| pipe = StableDiffusionPipeline.from_pretrained( | |
| "CompVis/stable-diffusion-v1-4" | |
| ) | |
| pipe = pipe.to("cpu") # Force CPU | |
| def generate(prompt): | |
| image = pipe(prompt).images[0] | |
| return image | |
| gr.Interface(fn=generate, inputs="text", outputs="image").launch() | |