Xu Ma commited on
Commit
19529cf
1 Parent(s): d47df74
Files changed (2) hide show
  1. app.py +11 -6
  2. main.py +2 -1
app.py CHANGED
@@ -109,11 +109,11 @@ cfg_arg = parse_args()
109
  temp_image = np.random.rand(224,224,3)
110
  temp_text = "start"
111
  temp_input = np.random.rand(224,224,3)
112
- def run_live(img, experiment_id, cfg_arg=cfg_arg):
113
  experiment = app_experiment_change(experiment_id)
114
  cfg_arg.target = img
115
  cfg_arg.experiment = experiment
116
- img, text = main_func(img, experiment_id, cfg_arg=cfg_arg)
117
  return temp_image, text
118
 
119
 
@@ -287,9 +287,9 @@ def run_live(img, experiment_id, cfg_arg=cfg_arg):
287
  def main(args):
288
  gr.close_all()
289
  # -------------------Inputs-------------------
290
- inputs_update = gr.inputs.Slider(
291
- label=" ",
292
- default=50, maximum=100, minimum=1, step=1)
293
  inputs_img = gr.inputs.Image(type="pil", label="Input Image")
294
  experiment_id = gr.inputs.Radio(
295
  choices=[
@@ -304,7 +304,7 @@ def main(args):
304
 
305
  inputs_img, # input image
306
  experiment_id, # path adding scheduler
307
- # inputs_update, # update output
308
 
309
  ]
310
  # outputs
@@ -322,22 +322,27 @@ def main(args):
322
  [
323
  "./examples/1.png",
324
  "add [1, 1, 1, 1, 1] total 5 paths one by one",
 
325
  ],
326
  [
327
  "./examples/2.png",
328
  "add [1, 1, 1, 1, 1] total 5 paths one by one",
 
329
  ],
330
  [
331
  "./examples/3.jpg",
332
  "add [1,2,4,8,16,32, ...] total 128 paths",
 
333
  ],
334
  [
335
  "./examples/4.png",
336
  "add [1,2,4,8,16,32, ...] total 256 paths",
 
337
  ],
338
  [
339
  "./examples/5.png",
340
  "add [1, 1, 1, 1, 1] total 5 paths one by one",
 
341
  ],
342
  ]
343
 
 
109
  temp_image = np.random.rand(224,224,3)
110
  temp_text = "start"
111
  temp_input = np.random.rand(224,224,3)
112
+ def run_live(img, experiment_id, num_iter, cfg_arg=cfg_arg):
113
  experiment = app_experiment_change(experiment_id)
114
  cfg_arg.target = img
115
  cfg_arg.experiment = experiment
116
+ img, text = main_func(img, experiment_id, num_iter, cfg_arg=cfg_arg)
117
  return temp_image, text
118
 
119
 
 
287
  def main(args):
288
  gr.close_all()
289
  # -------------------Inputs-------------------
290
+ inputs_iteration = gr.inputs.Slider(
291
+ label="Optimization Iteration",
292
+ default=500, maximum=600, minimum=100, step=100)
293
  inputs_img = gr.inputs.Image(type="pil", label="Input Image")
294
  experiment_id = gr.inputs.Radio(
295
  choices=[
 
304
 
305
  inputs_img, # input image
306
  experiment_id, # path adding scheduler
307
+ inputs_iteration, # input iteration
308
 
309
  ]
310
  # outputs
 
322
  [
323
  "./examples/1.png",
324
  "add [1, 1, 1, 1, 1] total 5 paths one by one",
325
+ 300,
326
  ],
327
  [
328
  "./examples/2.png",
329
  "add [1, 1, 1, 1, 1] total 5 paths one by one",
330
+ 300,
331
  ],
332
  [
333
  "./examples/3.jpg",
334
  "add [1,2,4,8,16,32, ...] total 128 paths",
335
+ 300,
336
  ],
337
  [
338
  "./examples/4.png",
339
  "add [1,2,4,8,16,32, ...] total 256 paths",
340
+ 300,
341
  ],
342
  [
343
  "./examples/5.png",
344
  "add [1, 1, 1, 1, 1] total 5 paths one by one",
345
+ 300,
346
  ],
347
  ]
348
 
main.py CHANGED
@@ -345,7 +345,7 @@ class linear_decay_lrlambda_f(object):
345
  lr = lr_s * (1-r) + lr_e * r
346
  return lr
347
 
348
- def main_func(target, experiment, cfg_arg):
349
  with open(cfg_arg.config, 'r') as f:
350
  cfg = yaml.load(f, Loader=yaml.FullLoader)
351
  cfg_default = edict(cfg['default'])
@@ -358,6 +358,7 @@ def main_func(target, experiment, cfg_arg):
358
  osp.join(cfg.log_dir, '{}_{}'.format(cfg.exid, '_'.join(cfg.signature)))
359
  cfg.target = target
360
  cfg.experiment = experiment
 
361
 
362
  configfile = osp.join(cfg.experiment_dir, 'config.yaml')
363
  check_and_create_dir(configfile)
 
345
  lr = lr_s * (1-r) + lr_e * r
346
  return lr
347
 
348
+ def main_func(target, experiment, num_iter, cfg_arg):
349
  with open(cfg_arg.config, 'r') as f:
350
  cfg = yaml.load(f, Loader=yaml.FullLoader)
351
  cfg_default = edict(cfg['default'])
 
358
  osp.join(cfg.log_dir, '{}_{}'.format(cfg.exid, '_'.join(cfg.signature)))
359
  cfg.target = target
360
  cfg.experiment = experiment
361
+ cfg.num_iter = num_iter
362
 
363
  configfile = osp.join(cfg.experiment_dir, 'config.yaml')
364
  check_and_create_dir(configfile)