Commit ·
82eaca1
1
Parent(s): f505238
fixed output gallery updating every second, now updates only when generation finished
Browse files- gradio_server.py +13 -3
gradio_server.py
CHANGED
|
@@ -1057,8 +1057,7 @@ def build_callback(taskid, state, pipe, num_inference_steps, repeats):
|
|
| 1057 |
return update_progress
|
| 1058 |
|
| 1059 |
def refresh_gallery(state):
|
| 1060 |
-
|
| 1061 |
-
return file_list
|
| 1062 |
|
| 1063 |
def finalize_gallery(state):
|
| 1064 |
choice = 0
|
|
@@ -1465,6 +1464,7 @@ def generate_video(
|
|
| 1465 |
|
| 1466 |
print(f"New video saved to Path: "+video_path)
|
| 1467 |
file_list.append(video_path)
|
|
|
|
| 1468 |
seed += 1
|
| 1469 |
|
| 1470 |
last_model_type = image2video
|
|
@@ -1899,6 +1899,7 @@ def generate_video_tab(image2video=False):
|
|
| 1899 |
download_status = gr.Markdown()
|
| 1900 |
with gr.Row():
|
| 1901 |
with gr.Column():
|
|
|
|
| 1902 |
with gr.Row(visible= len(loras)>0) as presets_column:
|
| 1903 |
lset_choices = [ (preset, preset) for preset in loras_presets ] + [(get_new_preset_msg(advanced), "")]
|
| 1904 |
with gr.Column(scale=6):
|
|
@@ -2146,15 +2147,24 @@ def generate_video_tab(image2video=False):
|
|
| 2146 |
elif cell_value == "✖":
|
| 2147 |
return remove_task([selected_index])
|
| 2148 |
return queue_df
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2149 |
selected_indices = gr.State([])
|
| 2150 |
queue_df.select(
|
| 2151 |
fn=handle_selection,
|
| 2152 |
outputs=selected_indices
|
| 2153 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2154 |
queue_df.change(
|
| 2155 |
fn=refresh_gallery,
|
| 2156 |
inputs=[state],
|
| 2157 |
-
outputs=[
|
| 2158 |
)
|
| 2159 |
save_settings_btn.click( fn=validate_wizard_prompt, inputs =[state, wizard_prompt_activated_var, wizard_variables_var, prompt, wizard_prompt, *prompt_vars] , outputs= [prompt]).then(
|
| 2160 |
save_settings, inputs = [state, prompt, image_prompt_type_radio, video_length, resolution, num_inference_steps, seed, repeat_generation, multi_images_gen_type, guidance_scale, flow_shift, negative_prompt,
|
|
|
|
| 1057 |
return update_progress
|
| 1058 |
|
| 1059 |
def refresh_gallery(state):
|
| 1060 |
+
return state
|
|
|
|
| 1061 |
|
| 1062 |
def finalize_gallery(state):
|
| 1063 |
choice = 0
|
|
|
|
| 1464 |
|
| 1465 |
print(f"New video saved to Path: "+video_path)
|
| 1466 |
file_list.append(video_path)
|
| 1467 |
+
state['update_gallery'] = True
|
| 1468 |
seed += 1
|
| 1469 |
|
| 1470 |
last_model_type = image2video
|
|
|
|
| 1899 |
download_status = gr.Markdown()
|
| 1900 |
with gr.Row():
|
| 1901 |
with gr.Column():
|
| 1902 |
+
gallery_update_trigger = gr.Textbox(value="0", visible=False, label="_gallery_trigger")
|
| 1903 |
with gr.Row(visible= len(loras)>0) as presets_column:
|
| 1904 |
lset_choices = [ (preset, preset) for preset in loras_presets ] + [(get_new_preset_msg(advanced), "")]
|
| 1905 |
with gr.Column(scale=6):
|
|
|
|
| 2147 |
elif cell_value == "✖":
|
| 2148 |
return remove_task([selected_index])
|
| 2149 |
return queue_df
|
| 2150 |
+
def refresh_gallery_on_trigger(state):
|
| 2151 |
+
if(state.get("update_gallery", False)):
|
| 2152 |
+
state['update_gallery'] = False
|
| 2153 |
+
return gr.update(value=state.get("file_list", []))
|
| 2154 |
selected_indices = gr.State([])
|
| 2155 |
queue_df.select(
|
| 2156 |
fn=handle_selection,
|
| 2157 |
outputs=selected_indices
|
| 2158 |
)
|
| 2159 |
+
gallery_update_trigger.change(
|
| 2160 |
+
fn=refresh_gallery_on_trigger,
|
| 2161 |
+
inputs=[state],
|
| 2162 |
+
outputs=[output]
|
| 2163 |
+
)
|
| 2164 |
queue_df.change(
|
| 2165 |
fn=refresh_gallery,
|
| 2166 |
inputs=[state],
|
| 2167 |
+
outputs=[gallery_update_trigger]
|
| 2168 |
)
|
| 2169 |
save_settings_btn.click( fn=validate_wizard_prompt, inputs =[state, wizard_prompt_activated_var, wizard_variables_var, prompt, wizard_prompt, *prompt_vars] , outputs= [prompt]).then(
|
| 2170 |
save_settings, inputs = [state, prompt, image_prompt_type_radio, video_length, resolution, num_inference_steps, seed, repeat_generation, multi_images_gen_type, guidance_scale, flow_shift, negative_prompt,
|