setup_seed_ui_musicgen.py 832 B

123456789101112131415161718192021222324252627
  1. import gradio as gr
  2. def setup_seed_ui_musicgen():
  3. gr.Markdown("Seed")
  4. with gr.Row():
  5. seed_input = gr.Number(value=-1, show_label=False, container=False)
  6. set_random_seed_button = gr.Button(
  7. "backspace", elem_classes="btn-sm material-symbols-outlined", size="sm"
  8. )
  9. set_random_seed_button.click(
  10. fn=lambda: gr.Number(value=-1), outputs=[seed_input]
  11. )
  12. set_old_seed_button = gr.Button(
  13. "repeat", elem_classes="btn-sm material-symbols-outlined", size="sm"
  14. )
  15. def link_seed_cache(seed_cache):
  16. set_old_seed_button.click(
  17. fn=lambda x: gr.Number(value=x),
  18. inputs=seed_cache,
  19. outputs=seed_input,
  20. )
  21. return seed_input, set_old_seed_button, link_seed_cache