Prgckwb commited on
Commit
59df77b
1 Parent(s): 5566482

:memo: Change

Browse files
Files changed (1) hide show
  1. app.py +6 -0
app.py CHANGED
@@ -79,6 +79,7 @@ def inference(
79
  num_images: int = 4,
80
  safety_checker: bool = True,
81
  use_model_offload:bool = False,
 
82
  progress=gr.Progress(track_tqdm=True),
83
  ) -> Image.Image:
84
  progress(0, "Starting inference...")
@@ -113,6 +114,8 @@ def inference(
113
  else:
114
  pipe = pipe.to('cuda')
115
 
 
 
116
  images = pipe(
117
  prompt,
118
  negative_prompt=negative_prompt,
@@ -121,6 +124,7 @@ def inference(
121
  guidance_scale=guidance_scale,
122
  num_inference_steps=num_inference_steps,
123
  num_images_per_prompt=num_images,
 
124
  ).images
125
 
126
  if num_images % 2 == 1:
@@ -155,6 +159,7 @@ if __name__ == "__main__":
155
  width = gr.Number(label="Width", value=512, step=64, minimum=64, maximum=2048)
156
  height = gr.Number(label="Height", value=512, step=64, minimum=64, maximum=2048)
157
  num_images = gr.Number(label="Num Images", value=4, minimum=1, maximum=10, step=1)
 
158
 
159
  guidance_scale = gr.Slider(label="Guidance Scale", value=7.5, step=0.5, minimum=0, maximum=10)
160
  num_inference_step = gr.Slider(
@@ -179,6 +184,7 @@ if __name__ == "__main__":
179
  num_images,
180
  use_safety_checker,
181
  use_model_offload,
 
182
  ]
183
 
184
  btn = gr.Button("Generate")
 
79
  num_images: int = 4,
80
  safety_checker: bool = True,
81
  use_model_offload:bool = False,
82
+ seed: int = 8888,
83
  progress=gr.Progress(track_tqdm=True),
84
  ) -> Image.Image:
85
  progress(0, "Starting inference...")
 
114
  else:
115
  pipe = pipe.to('cuda')
116
 
117
+ generator = torch.Generator(device=device).manual_seed(seed)
118
+
119
  images = pipe(
120
  prompt,
121
  negative_prompt=negative_prompt,
 
124
  guidance_scale=guidance_scale,
125
  num_inference_steps=num_inference_steps,
126
  num_images_per_prompt=num_images,
127
+ generator=generator,
128
  ).images
129
 
130
  if num_images % 2 == 1:
 
159
  width = gr.Number(label="Width", value=512, step=64, minimum=64, maximum=2048)
160
  height = gr.Number(label="Height", value=512, step=64, minimum=64, maximum=2048)
161
  num_images = gr.Number(label="Num Images", value=4, minimum=1, maximum=10, step=1)
162
+ seed = gr.Number(label="Seed", value=8888, step=1)
163
 
164
  guidance_scale = gr.Slider(label="Guidance Scale", value=7.5, step=0.5, minimum=0, maximum=10)
165
  num_inference_step = gr.Slider(
 
184
  num_images,
185
  use_safety_checker,
186
  use_model_offload,
187
+ seed,
188
  ]
189
 
190
  btn = gr.Button("Generate")