hysts HF Staff commited on
Commit
bb7103b
·
1 Parent(s): 0b1e25f

Update libraries

Browse files
Files changed (3) hide show
  1. README.md +1 -1
  2. app.py +17 -10
  3. requirements.txt +1 -1
README.md CHANGED
@@ -4,7 +4,7 @@ emoji: ⚡
4
  colorFrom: red
5
  colorTo: purple
6
  sdk: gradio
7
- sdk_version: 3.34.0
8
  python_version: 3.10.11
9
  app_file: app.py
10
  pinned: false
 
4
  colorFrom: red
5
  colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 3.36.0
8
  python_version: 3.10.11
9
  app_file: app.py
10
  pinned: false
app.py CHANGED
@@ -79,25 +79,31 @@ def save_preference(config_path: str, gallery: list[dict[str, Any]],
79
  scheduler.append(data)
80
 
81
 
 
 
 
 
82
  def clear() -> tuple[dict, dict, dict]:
83
  return (
84
  gr.update(value=None),
85
  gr.update(value=None),
86
- gr.update(interactive=False),
87
  )
88
 
89
 
90
  with gr.Blocks(css='style.css') as demo:
91
  with gr.Group():
92
  prompt = gr.Text(show_label=False, placeholder='Prompt')
93
- gallery = gr.Gallery(show_label=False).style(columns=2,
94
- rows=2,
95
- height='600px',
96
- object_fit='scale-down')
 
 
97
  save_preference_button = gr.Button('Save preference', interactive=False)
98
 
99
  config_path = gr.Text(visible=False)
100
- selected_index = gr.Number(visible=False, precision=0)
101
 
102
  with gr.Accordion(label='About this Space', open=False):
103
  gr.Markdown(ABOUT_THIS_SPACE)
@@ -106,12 +112,13 @@ with gr.Blocks(css='style.css') as demo:
106
  fn=generate,
107
  inputs=prompt,
108
  outputs=[config_path, gallery],
109
- ).success(
110
- fn=lambda: gr.update(interactive=True),
 
 
111
  outputs=save_preference_button,
112
  queue=False,
113
  )
114
-
115
  gallery.select(
116
  fn=get_selected_index,
117
  outputs=selected_index,
@@ -123,7 +130,7 @@ with gr.Blocks(css='style.css') as demo:
123
  queue=False,
124
  ).then(
125
  fn=clear,
126
- outputs=[config_path, gallery, save_preference_button],
127
  queue=False,
128
  )
129
  demo.queue(concurrency_count=5).launch()
 
79
  scheduler.append(data)
80
 
81
 
82
+ def update_save_button(selected_index: int) -> dict:
83
+ return gr.update(interactive=selected_index != -1)
84
+
85
+
86
  def clear() -> tuple[dict, dict, dict]:
87
  return (
88
  gr.update(value=None),
89
  gr.update(value=None),
90
+ gr.update(value=-1),
91
  )
92
 
93
 
94
  with gr.Blocks(css='style.css') as demo:
95
  with gr.Group():
96
  prompt = gr.Text(show_label=False, placeholder='Prompt')
97
+ gallery = gr.Gallery(show_label=False,
98
+ columns=2,
99
+ rows=2,
100
+ height='600px',
101
+ object_fit='scale-down',
102
+ allow_preview=False)
103
  save_preference_button = gr.Button('Save preference', interactive=False)
104
 
105
  config_path = gr.Text(visible=False)
106
+ selected_index = gr.Number(visible=False, precision=0, value=-1)
107
 
108
  with gr.Accordion(label='About this Space', open=False):
109
  gr.Markdown(ABOUT_THIS_SPACE)
 
112
  fn=generate,
113
  inputs=prompt,
114
  outputs=[config_path, gallery],
115
+ )
116
+ selected_index.change(
117
+ fn=update_save_button,
118
+ inputs=selected_index,
119
  outputs=save_preference_button,
120
  queue=False,
121
  )
 
122
  gallery.select(
123
  fn=get_selected_index,
124
  outputs=selected_index,
 
130
  queue=False,
131
  ).then(
132
  fn=clear,
133
+ outputs=[config_path, gallery, selected_index],
134
  queue=False,
135
  )
136
  demo.queue(concurrency_count=5).launch()
requirements.txt CHANGED
@@ -1,3 +1,3 @@
1
- git+https://github.com/huggingface/huggingface_hub@928e138
2
  gradio_client==0.2.7
 
3
  pyarrow==12.0.1
 
 
1
  gradio_client==0.2.7
2
+ huggingface_hub==0.16.2
3
  pyarrow==12.0.1