H-Liu1997 commited on
Commit
8123b5f
1 Parent(s): 00b061d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -516,7 +516,7 @@ character_name_to_yaml = {
516
  }
517
 
518
  @spaces.GPU(duration=200)
519
- def tango(audio_path, character_name, seed, create_graph=False, video_folder_path=None):
520
  os.system("rm -r ./outputs/")
521
  cfg = prepare_all("./configs/gradio.yaml")
522
  cfg.seed = seed
@@ -551,7 +551,7 @@ def tango(audio_path, character_name, seed, create_graph=False, video_folder_pat
551
  graph_save_path = "./outputs/save_video.pkl"
552
  os.system(f"cd ./SMPLer-X/ && python app.py --video_folder_path .{video_folder_path} --data_save_path .{data_save_path} --json_save_path .{json_save_path} && cd ..")
553
  print(f"cd ./SMPLer-X/ && python app.py --video_folder_path .{video_folder_path} --data_save_path .{data_save_path} --json_save_path .{json_save_path} && cd ..")
554
- os.system(f"python ./create_graph.py --json_save_path {json_save_path} --graph_save_path {graph_save_path}")
555
  cfg.data.test_meta_paths = json_save_path
556
  gc.collect()
557
  torch.cuda.empty_cache()
@@ -609,7 +609,7 @@ examples_video = [
609
  ]
610
 
611
  combined_examples = [
612
- ["./datasets/cached_audio/example_female_voice_9_seconds.wav", "./datasets/cached_audio/female_test_V1.mp4", 2024],
613
  # ["./datasets/cached_audio/example_female_voice_9_seconds.wav", "./datasets/cached_audio/101099-00_18_09-00_18_19.mp4", 2024],
614
  ]
615
 
@@ -664,10 +664,12 @@ def make_demo():
664
  with gr.Row():
665
  gr.Markdown(
666
  """
667
- <div style="display: flex; justify-content: center; align-items: center; text-align: center;">
 
 
668
  This is an open-source project supported by Hugging Face's free L40S GPU. Runtime is limited, so it operates in low-quality mode. Some generated results from high-quality mode are shown above.
669
  <br>
670
- News:
671
  <br>
672
  [10/15]: Add watermark, fix bugs on custom character by downgrades to py3.9, fix bugs to support audio less than 4s.
673
  <br>
@@ -716,7 +718,7 @@ def make_demo():
716
  with gr.Row():
717
  with gr.Column(scale=1):
718
  audio_input = gr.Audio(label="Upload your audio")
719
- seed_input = gr.Number(label="Seed", value=2024, interactive=True)
720
  with gr.Column(scale=2):
721
  gr.Examples(
722
  examples=examples_audio,
@@ -727,6 +729,7 @@ def make_demo():
727
  )
728
  with gr.Column(scale=1):
729
  video_input = gr.Video(label="Your Character", elem_classes="video")
 
730
  with gr.Column(scale=2):
731
  gr.Examples(
732
  examples=examples_video,
@@ -735,6 +738,7 @@ def make_demo():
735
  label="Character Examples",
736
  cache_examples=False
737
  )
 
738
 
739
  # Fourth row: Generate video button
740
  with gr.Row():
@@ -743,7 +747,7 @@ def make_demo():
743
  # Define button click behavior
744
  run_button.click(
745
  fn=tango,
746
- inputs=[audio_input, video_input, seed_input],
747
  outputs=[video_output_1, video_output_2, file_output_1, file_output_2]
748
  )
749
 
@@ -751,7 +755,7 @@ def make_demo():
751
  with gr.Column(scale=4):
752
  gr.Examples(
753
  examples=combined_examples,
754
- inputs=[audio_input, video_input, seed_input], # Both audio and video as inputs
755
  outputs=[video_output_1, video_output_2, file_output_1, file_output_2],
756
  fn=tango, # Function that processes both audio and video inputs
757
  label="Select Combined Audio and Video Examples (Cached)",
 
516
  }
517
 
518
  @spaces.GPU(duration=200)
519
+ def tango(audio_path, character_name, seed, threshold=1.0, create_graph=False, video_folder_path=None):
520
  os.system("rm -r ./outputs/")
521
  cfg = prepare_all("./configs/gradio.yaml")
522
  cfg.seed = seed
 
551
  graph_save_path = "./outputs/save_video.pkl"
552
  os.system(f"cd ./SMPLer-X/ && python app.py --video_folder_path .{video_folder_path} --data_save_path .{data_save_path} --json_save_path .{json_save_path} && cd ..")
553
  print(f"cd ./SMPLer-X/ && python app.py --video_folder_path .{video_folder_path} --data_save_path .{data_save_path} --json_save_path .{json_save_path} && cd ..")
554
+ os.system(f"python ./create_graph.py --json_save_path {json_save_path} --graph_save_path {graph_save_path} --threshold {threshold}")
555
  cfg.data.test_meta_paths = json_save_path
556
  gc.collect()
557
  torch.cuda.empty_cache()
 
609
  ]
610
 
611
  combined_examples = [
612
+ ["./datasets/cached_audio/example_female_voice_9_seconds.wav", "./datasets/cached_audio/female_test_V1.mp4", 2024, 1.0],
613
  # ["./datasets/cached_audio/example_female_voice_9_seconds.wav", "./datasets/cached_audio/101099-00_18_09-00_18_19.mp4", 2024],
614
  ]
615
 
 
664
  with gr.Row():
665
  gr.Markdown(
666
  """
667
+ <div style="display: flex; justify-content: center; align-items: center; text-align: left;">
668
+ News:
669
+ <br>
670
  This is an open-source project supported by Hugging Face's free L40S GPU. Runtime is limited, so it operates in low-quality mode. Some generated results from high-quality mode are shown above.
671
  <br>
672
+ [10/19]: Add a parameter to control "smooth" or "jumpy" for custom uploaded video. lower threshold is more smooth but more repeated gestures.
673
  <br>
674
  [10/15]: Add watermark, fix bugs on custom character by downgrades to py3.9, fix bugs to support audio less than 4s.
675
  <br>
 
718
  with gr.Row():
719
  with gr.Column(scale=1):
720
  audio_input = gr.Audio(label="Upload your audio")
721
+ seed_input = gr.Number(label="Random Seed", value=2024, interactive=True)
722
  with gr.Column(scale=2):
723
  gr.Examples(
724
  examples=examples_audio,
 
729
  )
730
  with gr.Column(scale=1):
731
  video_input = gr.Video(label="Your Character", elem_classes="video")
732
+ # threshold_input = gr.Slider(label="Result's Smoothness, lower is more smooth, only effective for custom uploaded videos.", minimum=0.7, maximum=1.0, value=1.0, step=0.01, interactive=True)
733
  with gr.Column(scale=2):
734
  gr.Examples(
735
  examples=examples_video,
 
738
  label="Character Examples",
739
  cache_examples=False
740
  )
741
+ threshold_input = gr.Slider(label="Result's Smoothness, lower is more smooth, only effective for custom uploaded videos.", minimum=0.7, maximum=1.0, value=1.0, step=0.01, interactive=True)
742
 
743
  # Fourth row: Generate video button
744
  with gr.Row():
 
747
  # Define button click behavior
748
  run_button.click(
749
  fn=tango,
750
+ inputs=[audio_input, video_input, seed_input, threshold_input],
751
  outputs=[video_output_1, video_output_2, file_output_1, file_output_2]
752
  )
753
 
 
755
  with gr.Column(scale=4):
756
  gr.Examples(
757
  examples=combined_examples,
758
+ inputs=[audio_input, video_input, seed_input, threshold_input], # Both audio and video as inputs
759
  outputs=[video_output_1, video_output_2, file_output_1, file_output_2],
760
  fn=tango, # Function that processes both audio and video inputs
761
  label="Select Combined Audio and Video Examples (Cached)",