Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,12 +3,15 @@ from diffusers import StableDiffusionPipeline
|
|
| 3 |
import torch
|
| 4 |
|
| 5 |
# Load the pre-trained model from Hugging Face (CompVis is the original model repository)
|
| 6 |
-
pipe = StableDiffusionPipeline.from_pretrained("
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
|
| 9 |
def generate_image(prompt):
|
| 10 |
# Generate image based on the user's prompt
|
| 11 |
image = pipe(prompt).images[0]
|
|
|
|
| 12 |
return image
|
| 13 |
|
| 14 |
# Create a Gradio interface
|
|
|
|
| 3 |
import torch
|
| 4 |
|
| 5 |
# Load the pre-trained model from Hugging Face (CompVis is the original model repository)
|
| 6 |
+
pipe = StableDiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2", torch_dtype=torch.float16)
|
| 7 |
+
|
| 8 |
+
# Ensure that the model runs on CPU
|
| 9 |
+
pipe = pipe.to("cpu") # Use CPU instead of CUDA (GPU)
|
| 10 |
|
| 11 |
def generate_image(prompt):
|
| 12 |
# Generate image based on the user's prompt
|
| 13 |
image = pipe(prompt).images[0]
|
| 14 |
+
|
| 15 |
return image
|
| 16 |
|
| 17 |
# Create a Gradio interface
|