JingyeChen commited on
Commit
d643014
1 Parent(s): 2c2aeff
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -145,6 +145,14 @@ def exe_redo(i, t, guest_id):
145
  def get_pixels(i, t, guest_id, evt: gr.SelectData):
146
  # global state
147
 
 
 
 
 
 
 
 
 
148
  text_position = evt.index
149
 
150
  if global_dict[guest_id]['state'] == 0:
@@ -189,7 +197,7 @@ def get_pixels(i, t, guest_id, evt: gr.SelectData):
189
 
190
  print('stack', global_dict[guest_id]['stack'])
191
 
192
- return image
193
 
194
 
195
  font_layout = ImageFont.truetype('./Arial.ttf', 16)
@@ -414,12 +422,9 @@ def text_to_image(guest_id, prompt,keywords,positive_prompt,radio,slider_step,sl
414
  with gr.Blocks() as demo:
415
 
416
 
417
- guest_id = random.randint(0,100000000)
418
  # register
419
- global_dict[str(guest_id)] = {
420
- 'state': 0,
421
- 'stack': []
422
- }
423
 
424
  gr.HTML(
425
  """
@@ -482,8 +487,10 @@ with gr.Blocks() as demo:
482
  # slider_seed = gr.Slider(minimum=1, maximum=10000, label="Seed", randomize=True)
483
  button = gr.Button("Generate")
484
 
485
- guest_id_box = gr.Textbox(label="guest_id", value=f"{guest_id}")
486
- i.select(get_pixels,[i,t,guest_id_box],[i])
 
 
487
  redo.click(exe_redo, [i,t,guest_id_box],[i])
488
  undo.click(exe_undo, [i,t,guest_id_box],[i])
489
  skip_button.click(skip_fun, [i,t,guest_id_box])
 
145
  def get_pixels(i, t, guest_id, evt: gr.SelectData):
146
  # global state
147
 
148
+ # register
149
+ if guest_id == '-1':
150
+ seed = int(time.time())
151
+ global_dict[str(seed)] = {
152
+ 'state': 0,
153
+ 'stack': []
154
+ }
155
+
156
  text_position = evt.index
157
 
158
  if global_dict[guest_id]['state'] == 0:
 
197
 
198
  print('stack', global_dict[guest_id]['stack'])
199
 
200
+ return image, seed
201
 
202
 
203
  font_layout = ImageFont.truetype('./Arial.ttf', 16)
 
422
  with gr.Blocks() as demo:
423
 
424
 
425
+ # guest_id = random.randint(0,100000000)
426
  # register
427
+
 
 
 
428
 
429
  gr.HTML(
430
  """
 
487
  # slider_seed = gr.Slider(minimum=1, maximum=10000, label="Seed", randomize=True)
488
  button = gr.Button("Generate")
489
 
490
+
491
+
492
+ guest_id_box = gr.Textbox(label="guest_id", value=f"-1")
493
+ i.select(get_pixels,[i,t,guest_id_box],[i,guest_id_box])
494
  redo.click(exe_redo, [i,t,guest_id_box],[i])
495
  undo.click(exe_undo, [i,t,guest_id_box],[i])
496
  skip_button.click(skip_fun, [i,t,guest_id_box])