Linoy Tsaban commited on
Commit
b4d4a0c
1 Parent(s): ae89a1f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -12
app.py CHANGED
@@ -116,7 +116,7 @@ def invert_and_reconstruct(
116
  input_image,
117
  do_inversion,
118
  wts, zs,
119
- seed,
120
  src_prompt ="",
121
  tar_prompt="",
122
  steps=100,
@@ -127,7 +127,9 @@ def invert_and_reconstruct(
127
 
128
  ):
129
 
 
130
  x0 = load_512(input_image, device=device)
 
131
 
132
  if do_inversion:
133
  # invert and retrieve noise maps and latent
@@ -199,11 +201,7 @@ def edit(input_image,
199
  return sega_out.images[0]
200
 
201
 
202
- def randomize_seed_fn(seed, randomize_seed):
203
- if randomize_seed:
204
- seed = random.randint(0, np.iinfo(np.int32).max)
205
- torch.manual_seed(seed)
206
- return seed
207
 
208
  ########
209
  # demo #
@@ -229,6 +227,12 @@ with gr.Blocks(css='style.css') as demo:
229
  do_inversion = True
230
  return do_inversion
231
 
 
 
 
 
 
 
232
  gr.HTML(intro)
233
  wts = gr.State()
234
  zs = gr.State()
@@ -281,16 +285,11 @@ with gr.Blocks(css='style.css') as demo:
281
  # gr.Markdown(help_text)
282
 
283
  invert_button.click(
284
- fn = randomize_seed_fn,
285
- inputs = [seed, randomize_seed],
286
- outputs = [seed],
287
- queue=False
288
- ).success(
289
  fn=invert_and_reconstruct,
290
  inputs=[input_image,
291
  do_inversion,
292
  wts, zs,
293
- seed,
294
  src_prompt,
295
  tar_prompt,
296
  steps,
 
116
  input_image,
117
  do_inversion,
118
  wts, zs,
119
+ seed, randomize_seed,
120
  src_prompt ="",
121
  tar_prompt="",
122
  steps=100,
 
127
 
128
  ):
129
 
130
+
131
  x0 = load_512(input_image, device=device)
132
+ randomize_seed_fn(seed, randomize_seed)
133
 
134
  if do_inversion:
135
  # invert and retrieve noise maps and latent
 
201
  return sega_out.images[0]
202
 
203
 
204
+
 
 
 
 
205
 
206
  ########
207
  # demo #
 
227
  do_inversion = True
228
  return do_inversion
229
 
230
+ def randomize_seed_fn(seed, randomize_seed):
231
+ if randomize_seed:
232
+ seed = random.randint(0, np.iinfo(np.int32).max)
233
+ torch.manual_seed(seed)
234
+ # return seed
235
+
236
  gr.HTML(intro)
237
  wts = gr.State()
238
  zs = gr.State()
 
285
  # gr.Markdown(help_text)
286
 
287
  invert_button.click(
 
 
 
 
 
288
  fn=invert_and_reconstruct,
289
  inputs=[input_image,
290
  do_inversion,
291
  wts, zs,
292
+ seed, randomize_seed
293
  src_prompt,
294
  tar_prompt,
295
  steps,