jammmmm commited on
Commit
856c526
·
1 Parent(s): 290e347

Fix preprocess button

Browse files
Files changed (1) hide show
  1. demo_gr.py +12 -2
demo_gr.py CHANGED
@@ -852,7 +852,8 @@ def main(server_port: int | None = None, share: bool = True):
852
  with gr.Row():
853
  with gr.Column():
854
  with gr.Group():
855
- preprocess_btn = gr.Button("Preprocess images")
 
856
  preprocess_progress = gr.Textbox(
857
  label="",
858
  visible=False,
@@ -875,6 +876,12 @@ def main(server_port: int | None = None, share: bool = True):
875
  render=False,
876
  )
877
  preprocessed = gr.State()
 
 
 
 
 
 
878
  preprocess_btn.click(
879
  lambda r, *args: [
880
  *r.preprocess(*args),
@@ -1051,7 +1058,8 @@ def main(server_port: int | None = None, share: bool = True):
1051
  with gr.Row():
1052
  with gr.Column():
1053
  with gr.Group():
1054
- preprocess_btn = gr.Button("Preprocess images")
 
1055
  preprocess_progress = gr.Textbox(
1056
  label="",
1057
  visible=False,
@@ -1112,6 +1120,7 @@ def main(server_port: int | None = None, share: bool = True):
1112
  gr.update(visible=False),
1113
  gr.update(visible=False),
1114
  gr.update(visible=True),
 
1115
  ),
1116
  inputs=[example_imgs_expander],
1117
  outputs=[
@@ -1120,6 +1129,7 @@ def main(server_port: int | None = None, share: bool = True):
1120
  example_imgs_confirmer,
1121
  example_imgs_backer,
1122
  example_imgs,
 
1123
  ],
1124
  )
1125
  example_imgs_backer.click(
 
852
  with gr.Row():
853
  with gr.Column():
854
  with gr.Group():
855
+ # Initially disable the Preprocess Images button until an image is selected.
856
+ preprocess_btn = gr.Button("Preprocess images", interactive=False)
857
  preprocess_progress = gr.Textbox(
858
  label="",
859
  visible=False,
 
876
  render=False,
877
  )
878
  preprocessed = gr.State()
879
+ # Enable the Preprocess Images button only if an image is selected.
880
+ input_imgs.change(
881
+ lambda img: gr.update(interactive=bool(img)),
882
+ inputs=input_imgs,
883
+ outputs=preprocess_btn,
884
+ )
885
  preprocess_btn.click(
886
  lambda r, *args: [
887
  *r.preprocess(*args),
 
1058
  with gr.Row():
1059
  with gr.Column():
1060
  with gr.Group():
1061
+ # Initially disable the Preprocess Images button until images are selected.
1062
+ preprocess_btn = gr.Button("Preprocess images", interactive=False)
1063
  preprocess_progress = gr.Textbox(
1064
  label="",
1065
  visible=False,
 
1120
  gr.update(visible=False),
1121
  gr.update(visible=False),
1122
  gr.update(visible=True),
1123
+ gr.update(interactive=bool(x))
1124
  ),
1125
  inputs=[example_imgs_expander],
1126
  outputs=[
 
1129
  example_imgs_confirmer,
1130
  example_imgs_backer,
1131
  example_imgs,
1132
+ preprocess_btn
1133
  ],
1134
  )
1135
  example_imgs_backer.click(