Fabrice-TIERCELIN commited on
Commit
26068fd
·
verified ·
1 Parent(s): 2458729
Files changed (1) hide show
  1. app.py +34 -1
app.py CHANGED
@@ -110,6 +110,23 @@ os.makedirs(outputs_folder, exist_ok=True)
110
 
111
  input_image_debug_value = input_video_debug_value = prompt_debug_value = total_second_length_debug_value = None
112
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  def check_parameters(generation_mode, input_image, input_video):
114
  if generation_mode == "image" and input_image is None:
115
  raise gr.Error("Please provide an image to extend.")
@@ -971,7 +988,7 @@ with block:
971
  gr.HTML(title_html)
972
  with gr.Row():
973
  with gr.Column():
974
- generation_mode = gr.Radio([["Text-to-Video", "text"], ["Image-to-Video", "image"], ["Video Extension", "video"]], label="Generation mode", value = "image")
975
  text_to_video_hint = gr.HTML("I discourage to use the Text-to-Video feature. You should rather generate an image with Flux and use Image-to-Video. You will save time.")
976
  input_image = gr.Image(sources='upload', type="numpy", label="Image", height=320)
977
  input_video = gr.Video(sources='upload', label="Input Video", height=320)
@@ -1056,6 +1073,13 @@ with block:
1056
  ], outputs = [end_button], queue = False, show_progress = False).success(fn=process_video, inputs=ips_video, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button_video, end_button])
1057
  end_button.click(fn=end_process)
1058
 
 
 
 
 
 
 
 
1059
  with gr.Row(elem_id="image_examples", visible=False):
1060
  gr.Examples(
1061
  examples = [
@@ -1194,4 +1218,13 @@ with block:
1194
  ]
1195
  )
1196
 
 
 
 
 
 
 
 
 
 
1197
  block.launch(mcp_server=True, ssr_mode=False)
 
110
 
111
  input_image_debug_value = input_video_debug_value = prompt_debug_value = total_second_length_debug_value = None
112
 
113
+ default_local_storage = {
114
+ "generation-mode": "image",
115
+ }
116
+
117
+ def save_preferences(preferences, value):
118
+ preferences["generation-mode"] = value
119
+ return preferences
120
+
121
+ def load_preferences(saved_prefs):
122
+ saved_prefs = init_preferences(saved_prefs)
123
+ return [saved_prefs["generation-mode"]]
124
+
125
+ def init_preferences(saved_prefs):
126
+ if saved_prefs is None:
127
+ saved_prefs = default_local_storage
128
+ return saved_prefs
129
+
130
  def check_parameters(generation_mode, input_image, input_video):
131
  if generation_mode == "image" and input_image is None:
132
  raise gr.Error("Please provide an image to extend.")
 
988
  gr.HTML(title_html)
989
  with gr.Row():
990
  with gr.Column():
991
+ generation_mode = gr.Radio([["Text-to-Video", "text"], ["Image-to-Video", "image"], ["Video Extension", "video"]], elem_id="generation-mode", label="Generation mode", value = "image")
992
  text_to_video_hint = gr.HTML("I discourage to use the Text-to-Video feature. You should rather generate an image with Flux and use Image-to-Video. You will save time.")
993
  input_image = gr.Image(sources='upload', type="numpy", label="Image", height=320)
994
  input_video = gr.Video(sources='upload', label="Input Video", height=320)
 
1073
  ], outputs = [end_button], queue = False, show_progress = False).success(fn=process_video, inputs=ips_video, outputs=[result_video, preview_image, progress_desc, progress_bar, start_button_video, end_button])
1074
  end_button.click(fn=end_process)
1075
 
1076
+ generation_mode.change(fn = save_preferences, inputs = [
1077
+ local_storage,
1078
+ generation_mode,
1079
+ ], outputs = [
1080
+ local_storage
1081
+ ])
1082
+
1083
  with gr.Row(elem_id="image_examples", visible=False):
1084
  gr.Examples(
1085
  examples = [
 
1218
  ]
1219
  )
1220
 
1221
+ # Load saved preferences when the page loads
1222
+ block.load(
1223
+ fn=load_preferences, inputs = [
1224
+ local_storage
1225
+ ], outputs = [
1226
+ generation_mode
1227
+ ]
1228
+ )
1229
+
1230
  block.launch(mcp_server=True, ssr_mode=False)