alex commited on
Commit
9189b21
Β·
1 Parent(s): 58e56c8

duration added

Browse files
Files changed (1) hide show
  1. app.py +14 -7
app.py CHANGED
@@ -871,12 +871,6 @@ with gr.Blocks(css=css, title="Wan 2.2 Animate --replace", theme=gr.themes.Ocean
871
  """)
872
  output_video = gr.Video(label="Edited Video", height=512)
873
 
874
- duration_s = get_display_time_required(2, default_replace_string)
875
- duration_m = duration_s / 60
876
-
877
- time_required = f"⌚ Zero GPU Required: ~{duration_s}.0s ({duration_m:.1f} mins)"
878
-
879
- time_required = gr.Text(value=time_required, show_label=False, visible=False)
880
  action_button = gr.Button("Wan Animate πŸ¦†", variant='primary', elem_classes="button-gradient")
881
 
882
  with gr.Accordion("Generated Masks 🎭", open=False, visible=True):
@@ -952,6 +946,7 @@ with gr.Blocks(css=css, title="Wan 2.2 Animate --replace", theme=gr.themes.Ocean
952
  gr.Markdown("Choose a frame and adjust the relevant mask, by including and excluding points, to propagate across frames. If no mask is selected, one will be chosen automatically.")
953
  gr.Markdown("")
954
  with gr.Row():
 
955
  frame_index = gr.Slider(label="Frame Index", minimum=0, maximum=0, value=0, step=1,)
956
  with gr.Row():
957
  first_frame = gr.Image(type="filepath", height=384, interactive=False)
@@ -963,6 +958,13 @@ with gr.Blocks(css=css, title="Wan 2.2 Animate --replace", theme=gr.themes.Ocean
963
  )
964
 
965
  with gr.Column():
 
 
 
 
 
 
 
966
  confirm_sam2_points = gr.Button("Wan Animate πŸ¦†", variant='primary', elem_classes="button-gradient")
967
  cancel_button = gr.Button("Cancel")
968
 
@@ -970,8 +972,13 @@ with gr.Blocks(css=css, title="Wan 2.2 Animate --replace", theme=gr.themes.Ocean
970
  replace_character_string.change(update_time_required, inputs=[max_duration_slider, replace_character_string], outputs=[time_required]) \
971
  .then(log_change, inputs=[gr.State("mode"), session_state, replace_character_string])
972
 
 
 
 
 
973
  max_duration_slider.change(log_change, inputs=[gr.State("slider"), session_state, max_duration_slider]) \
974
- .then(update_time_required, inputs=[max_duration_slider, replace_character_string], outputs=[time_required])
 
975
 
976
  input_video.change(log_change, inputs=[gr.State("video"), session_state]) \
977
  .then(set_reset, inputs=[prompt_state], outputs=[prompt_state, sam2_mode_select])
 
871
  """)
872
  output_video = gr.Video(label="Edited Video", height=512)
873
 
 
 
 
 
 
 
874
  action_button = gr.Button("Wan Animate πŸ¦†", variant='primary', elem_classes="button-gradient")
875
 
876
  with gr.Accordion("Generated Masks 🎭", open=False, visible=True):
 
946
  gr.Markdown("Choose a frame and adjust the relevant mask, by including and excluding points, to propagate across frames. If no mask is selected, one will be chosen automatically.")
947
  gr.Markdown("")
948
  with gr.Row():
949
+ max_duration_slider_2 = gr.Slider(2, 10, 2, step=2, label="Max Duration", visible=True)
950
  frame_index = gr.Slider(label="Frame Index", minimum=0, maximum=0, value=0, step=1,)
951
  with gr.Row():
952
  first_frame = gr.Image(type="filepath", height=384, interactive=False)
 
958
  )
959
 
960
  with gr.Column():
961
+ duration_s = get_display_time_required(2, default_replace_string)
962
+ duration_m = duration_s / 60
963
+
964
+ time_required = f"⌚ Zero GPU Required: ~{duration_s}.0s ({duration_m:.1f} mins)"
965
+
966
+ time_required = gr.Text(value=time_required, show_label=False, visible=False)
967
+
968
  confirm_sam2_points = gr.Button("Wan Animate πŸ¦†", variant='primary', elem_classes="button-gradient")
969
  cancel_button = gr.Button("Cancel")
970
 
 
972
  replace_character_string.change(update_time_required, inputs=[max_duration_slider, replace_character_string], outputs=[time_required]) \
973
  .then(log_change, inputs=[gr.State("mode"), session_state, replace_character_string])
974
 
975
+ def sync_slider(val):
976
+ return val
977
+
978
+ max_duration_slider_2.change(sync_slider, max_duration_slider_2, max_duration_slider)
979
  max_duration_slider.change(log_change, inputs=[gr.State("slider"), session_state, max_duration_slider]) \
980
+ .then(update_time_required, inputs=[max_duration_slider, replace_character_string], outputs=[time_required]) \
981
+ .then(extract_frames, inputs=[input_video, max_duration_slider, session_state], outputs=[first_frame, frames, frame_index])
982
 
983
  input_video.change(log_change, inputs=[gr.State("video"), session_state]) \
984
  .then(set_reset, inputs=[prompt_state], outputs=[prompt_state, sam2_mode_select])