audrey06100 commited on
Commit
ba1c502
·
1 Parent(s): e59c290
Files changed (1) hide show
  1. app.py +19 -11
app.py CHANGED
@@ -291,7 +291,7 @@ with gr.Blocks() as demo:
291
 
292
  # +========================================================================================+
293
  # | Stage1: channel mapping |
294
- # +========================================================================================+
295
  def reset_all(in_loc):
296
  # establish a new folder for the current session
297
  rootpath = os.path.dirname(str(in_loc))
@@ -437,8 +437,8 @@ with gr.Blocks() as demo:
437
  tpl_img : gr.Image(visible=False),
438
  mapped_img : gr.Image(visible=False),
439
  next_btn : gr.Button(visible=False),
440
- out_json_file : gr.File(filename, visible=True),
441
- run_btn : gr.Button(interactive=True)}
442
 
443
  # step1 to step2
444
  # matched_num < 30, and there're still some unmatched in_channels
@@ -538,8 +538,8 @@ with gr.Blocks() as demo:
538
  radio_group : gr.Radio(visible=False),
539
  out_json_file : gr.File(filename, visible=True),
540
  clear_btn : gr.Button(visible=False),
541
- next_btn : gr.Button(visible=False),
542
- run_btn : gr.Button(interactive=True)}
543
  # step2 to step3-1
544
  else:
545
  md = """
@@ -579,8 +579,8 @@ with gr.Blocks() as demo:
579
  desc_md : gr.Markdown(md),
580
  in_fillmode : gr.Dropdown(visible=False),
581
  fillmode_btn : gr.Button(visible=False),
582
- out_json_file : gr.File(filename, visible=True),
583
- run_btn : gr.Button(interactive=True)}
584
  # step3-1 to step3-2
585
  elif fillmode == "mean":
586
  md = """
@@ -653,14 +653,14 @@ with gr.Blocks() as demo:
653
  desc_md : gr.Markdown(md),
654
  chkbox_group : gr.CheckboxGroup(visible=False),
655
  next_btn : gr.Button(visible=False),
656
- out_json_file : gr.File(filename, visible=True),
657
- run_btn : gr.Button(interactive=True)}
658
 
659
  next_btn.click(
660
  fn = init_next_step,
661
  inputs = [app_info_json, channel_info_json, in_fillmode, radio_group, chkbox_group],
662
  outputs = [app_info_json, channel_info_json, desc_md, tpl_img, mapped_img, radio_group, clear_btn, step2_btn,
663
- in_fillmode, fillmode_btn, chkbox_group, step3_btn, out_json_file, next_btn, run_btn]
664
  ).success(
665
  fn = None,
666
  js = init_js,
@@ -796,7 +796,7 @@ with gr.Blocks() as demo:
796
  fn = init_next_step,
797
  inputs = [app_info_json, channel_info_json, in_fillmode, radio_group, chkbox_group],
798
  outputs = [app_info_json, channel_info_json, desc_md, in_fillmode, fillmode_btn, chkbox_group, step3_btn,
799
- out_json_file, next_btn, run_btn]
800
  ).success(
801
  fn = None,
802
  js = init_js,
@@ -819,6 +819,14 @@ with gr.Blocks() as demo:
819
  # +========================================================================================+
820
  # | Stage2: decode data |
821
  # +========================================================================================+
 
 
 
 
 
 
 
 
822
  def reset_run(app_info, in_data, samplerate, modelname):
823
  stage1_info = app_info["stage1"]
824
  stage2_info = app_info["stage2"]
 
291
 
292
  # +========================================================================================+
293
  # | Stage1: channel mapping |
294
+ # +========================================================================================+
295
  def reset_all(in_loc):
296
  # establish a new folder for the current session
297
  rootpath = os.path.dirname(str(in_loc))
 
437
  tpl_img : gr.Image(visible=False),
438
  mapped_img : gr.Image(visible=False),
439
  next_btn : gr.Button(visible=False),
440
+ out_json_file : gr.File(filename, visible=True)}
441
+ #run_btn : gr.Button(interactive=True)}
442
 
443
  # step1 to step2
444
  # matched_num < 30, and there're still some unmatched in_channels
 
538
  radio_group : gr.Radio(visible=False),
539
  out_json_file : gr.File(filename, visible=True),
540
  clear_btn : gr.Button(visible=False),
541
+ next_btn : gr.Button(visible=False)}
542
+ #run_btn : gr.Button(interactive=True)}
543
  # step2 to step3-1
544
  else:
545
  md = """
 
579
  desc_md : gr.Markdown(md),
580
  in_fillmode : gr.Dropdown(visible=False),
581
  fillmode_btn : gr.Button(visible=False),
582
+ out_json_file : gr.File(filename, visible=True)}
583
+ #run_btn : gr.Button(interactive=True)}
584
  # step3-1 to step3-2
585
  elif fillmode == "mean":
586
  md = """
 
653
  desc_md : gr.Markdown(md),
654
  chkbox_group : gr.CheckboxGroup(visible=False),
655
  next_btn : gr.Button(visible=False),
656
+ out_json_file : gr.File(filename, visible=True)}
657
+ #run_btn : gr.Button(interactive=True)}
658
 
659
  next_btn.click(
660
  fn = init_next_step,
661
  inputs = [app_info_json, channel_info_json, in_fillmode, radio_group, chkbox_group],
662
  outputs = [app_info_json, channel_info_json, desc_md, tpl_img, mapped_img, radio_group, clear_btn, step2_btn,
663
+ in_fillmode, fillmode_btn, chkbox_group, step3_btn, out_json_file, next_btn]
664
  ).success(
665
  fn = None,
666
  js = init_js,
 
796
  fn = init_next_step,
797
  inputs = [app_info_json, channel_info_json, in_fillmode, radio_group, chkbox_group],
798
  outputs = [app_info_json, channel_info_json, desc_md, in_fillmode, fillmode_btn, chkbox_group, step3_btn,
799
+ out_json_file, next_btn]
800
  ).success(
801
  fn = None,
802
  js = init_js,
 
819
  # +========================================================================================+
820
  # | Stage2: decode data |
821
  # +========================================================================================+
822
+ @gr.on(triggers = [in_data_file.upload, in_data_file.clear, in_samplerate.change, out_json_file.change],
823
+ inputs = [app_info_json, in_data_file, in_samplerate], outputs = run_btn)
824
+ def check_input2(app_info, in_data, samplerate):
825
+ if app_info["stage1"]["state"]=="finished" and in_data!=None and samplerate!="":
826
+ return gr.Button(interactive=True)
827
+ else:
828
+ return gr.Button(interactive=False)
829
+
830
  def reset_run(app_info, in_data, samplerate, modelname):
831
  stage1_info = app_info["stage1"]
832
  stage2_info = app_info["stage2"]