Malik99999 commited on
Commit
d278887
·
verified ·
1 Parent(s): 1969a56

Update run.py

Browse files
Files changed (1) hide show
  1. run.py +11 -12
run.py CHANGED
@@ -1,21 +1,20 @@
1
- import torch
2
  from diffusers import StableDiffusionPipeline
 
3
 
4
- # Load the Stable Diffusion pipeline
5
  pipeline = StableDiffusionPipeline.from_pretrained(
6
- "runwayml/stable-diffusion-v1-5",
7
  torch_dtype=torch.float16
8
  )
9
- pipeline.to("cuda") # Use the GPU
10
 
11
- # Load your safetensors weights
12
- pipeline.unet.load_attn_procs("v1-5-pruned-emaonly.safetensors")
 
 
 
13
 
14
- # Generate an image
15
- prompt = "A serene landscape with mountains and a lake at sunset"
16
- result = pipeline(prompt, guidance_scale=7.5) # Adjust guidance scale if needed
17
- image = result.images[0]
18
 
19
- # Save and display the image
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")