Update run.py
Browse files
run.py
CHANGED
|
@@ -1,21 +1,20 @@
|
|
| 1 |
-
import torch
|
| 2 |
from diffusers import StableDiffusionPipeline
|
|
|
|
| 3 |
|
| 4 |
-
# Load the
|
| 5 |
pipeline = StableDiffusionPipeline.from_pretrained(
|
| 6 |
-
"
|
| 7 |
torch_dtype=torch.float16
|
| 8 |
)
|
| 9 |
-
pipeline.to("cuda") # Use the GPU
|
| 10 |
|
| 11 |
-
#
|
| 12 |
-
pipeline.
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
# Generate
|
| 15 |
-
|
| 16 |
-
result = pipeline(prompt, guidance_scale=7.5) # Adjust guidance scale if needed
|
| 17 |
-
image = result.images[0]
|
| 18 |
|
| 19 |
-
# Save
|
| 20 |
image.save("generated_image.png")
|
| 21 |
-
image.show()
|
|
|
|
|
|
|
| 1 |
from diffusers import StableDiffusionPipeline
|
| 2 |
+
import torch
|
| 3 |
|
| 4 |
+
# Load the model (make sure the model is loaded from the correct path)
|
| 5 |
pipeline = StableDiffusionPipeline.from_pretrained(
|
| 6 |
+
"Malik99999/MyModel",
|
| 7 |
torch_dtype=torch.float16
|
| 8 |
)
|
|
|
|
| 9 |
|
| 10 |
+
# Move model to GPU (if available)
|
| 11 |
+
pipeline.to("cuda" if torch.cuda.is_available() else "cpu")
|
| 12 |
+
|
| 13 |
+
# Example prompt
|
| 14 |
+
prompt = "A beautiful landscape at sunrise"
|
| 15 |
|
| 16 |
+
# Generate the image
|
| 17 |
+
image = pipeline(prompt).images[0]
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
# Save or display the image
|
| 20 |
image.save("generated_image.png")
|
|
|