KaiShin1885 commited on
Commit
0a253f5
·
verified ·
1 Parent(s): 5e1d000

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -5,6 +5,7 @@ from diffusers import DiffusionPipeline
5
  import torch
6
 
7
  device = "cuda" if torch.cuda.is_available() else "cpu"
 
8
 
9
  if torch.cuda.is_available():
10
  torch.cuda.max_memory_allocated(device=device)
@@ -21,17 +22,17 @@ MAX_IMAGE_SIZE = 1024
21
  def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
22
  if randomize_seed:
23
  seed = random.randint(0, MAX_SEED)
24
-
25
- generator = torch.Generator().manual_seed(seed)
26
 
27
  image = pipe(
28
- prompt = prompt,
29
- negative_prompt = negative_prompt,
30
- guidance_scale = guidance_scale,
31
- num_inference_steps = num_inference_steps,
32
- width = width,
33
- height = height,
34
- generator = generator
35
  ).images[0]
36
 
37
  return image
 
5
  import torch
6
 
7
  device = "cuda" if torch.cuda.is_available() else "cpu"
8
+ torch_device = torch.device(device)
9
 
10
  if torch.cuda.is_available():
11
  torch.cuda.max_memory_allocated(device=device)
 
22
  def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
23
  if randomize_seed:
24
  seed = random.randint(0, MAX_SEED)
25
+
26
+ generator = torch.Generator(device=torch_device).manual_seed(seed)
27
 
28
  image = pipe(
29
+ prompt=prompt,
30
+ negative_prompt=negative_prompt,
31
+ guidance_scale=guidance_scale,
32
+ num_inference_steps=num_inference_steps,
33
+ width=width,
34
+ height=height,
35
+ generator=generator
36
  ).images[0]
37
 
38
  return image