ironjr commited on
Commit
cbcc7c3
1 Parent(s): eeac019

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -146,7 +146,7 @@ opt.colors = [
146
  # '#92C6EC',
147
  # '#FECAC0',
148
  ]
149
- opt.excluded_keys = ['inpainting_mode', 'is_runing', 'active_palettes', 'current_palette', 'model']
150
 
151
 
152
  ### Event handlers
@@ -292,13 +292,15 @@ def change_neg_prompt(state, neg_prompt):
292
 
293
 
294
  def import_state(state, json_text):
295
- current_palette = state.current_palette
296
- # active_palettes = state.active_palettes
297
  state_dict = json.loads(json_text)
298
  for k in opt.excluded_keys:
299
  if k in state_dict:
300
  del state_dict[k]
 
301
  state = argparse.Namespace(**state_dict)
 
 
302
  state.active_palettes = opt.max_palettes
303
  return [state] + [
304
  gr.update(value=v, visible=True) for v in state.prompt_names
@@ -317,9 +319,6 @@ def import_state(state, json_text):
317
 
318
  ### Main worker
319
 
320
- def generate():
321
- return model()
322
-
323
 
324
  def register(state, drawpad):
325
  seed_everything(state.seed if state.seed >=0 else np.random.randint(2147483647))
@@ -395,12 +394,12 @@ def run(state, drawpad):
395
 
396
  tic = time.time()
397
  while True:
398
- yield [state, generate()]
399
  toc = time.time()
400
  tdelta = toc - tic
401
  if tdelta > opt.run_time:
402
  state.is_running = False
403
- return [state, generate()]
404
 
405
 
406
  def hide_element():
 
146
  # '#92C6EC',
147
  # '#FECAC0',
148
  ]
149
+ opt.excluded_keys = ['inpainting_mode', 'is_running', 'active_palettes', 'current_palette', 'model']
150
 
151
 
152
  ### Event handlers
 
292
 
293
 
294
  def import_state(state, json_text):
295
+ prev_state_dict = {k: v in vars(state).items() if k in opt.excluded_keys}
 
296
  state_dict = json.loads(json_text)
297
  for k in opt.excluded_keys:
298
  if k in state_dict:
299
  del state_dict[k]
300
+ state_dict.update(prev_state_dict)
301
  state = argparse.Namespace(**state_dict)
302
+
303
+ current_palette = state.current_palette
304
  state.active_palettes = opt.max_palettes
305
  return [state] + [
306
  gr.update(value=v, visible=True) for v in state.prompt_names
 
319
 
320
  ### Main worker
321
 
 
 
 
322
 
323
  def register(state, drawpad):
324
  seed_everything(state.seed if state.seed >=0 else np.random.randint(2147483647))
 
394
 
395
  tic = time.time()
396
  while True:
397
+ yield [state, state.model()]
398
  toc = time.time()
399
  tdelta = toc - tic
400
  if tdelta > opt.run_time:
401
  state.is_running = False
402
+ return [state, state.model()]
403
 
404
 
405
  def hide_element():