akazmi commited on
Commit
f50533e
·
verified ·
1 Parent(s): da36322

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -6,7 +6,7 @@ api_key = "your_huggingface_api_key"
6
 
7
  # Load the Stable Diffusion pipeline with the API key
8
  pipeline = StableDiffusionPipeline.from_pretrained(
9
- "CompVis/stable-diffusion-v1-4",
10
  use_auth_token=api_key
11
  )
12
 
@@ -14,13 +14,13 @@ pipeline = StableDiffusionPipeline.from_pretrained(
14
  device = "cuda" if torch.cuda.is_available() else "cpu"
15
  pipeline.to(device)
16
 
17
- # Reduce the image resolution for faster generation
18
- pipeline.set_format("jpeg")
19
- pipeline.set_resolution(512) # Reduce resolution (e.g., 512x512)
20
 
21
  # Generate an image
22
  prompt = "A serene lake surrounded by mountains during sunset"
23
- image = pipeline(prompt).images[0]
24
 
25
  # Save the generated image
26
  image.save("generated_image.png")
 
6
 
7
  # Load the Stable Diffusion pipeline with the API key
8
  pipeline = StableDiffusionPipeline.from_pretrained(
9
+ "stabilityai/stable-diffusion-2", # You can try using the newer and faster version of Stable Diffusion.
10
  use_auth_token=api_key
11
  )
12
 
 
14
  device = "cuda" if torch.cuda.is_available() else "cpu"
15
  pipeline.to(device)
16
 
17
+ # Define a smaller resolution for faster generation
18
+ height = 512 # You can try 512 or 256 to make it faster
19
+ width = 512
20
 
21
  # Generate an image
22
  prompt = "A serene lake surrounded by mountains during sunset"
23
+ image = pipeline(prompt, height=height, width=width).images[0]
24
 
25
  # Save the generated image
26
  image.save("generated_image.png")