Bez popisu
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

colab.py 1.0KB

1234567891011121314151617181920212223242526
  1. import os
  2. import gradio as gr
  3. from modules import scripts, script_callbacks
  4. from subprocess import getoutput
  5. def run(command):
  6. out = getoutput(f"{command}")
  7. return out
  8. def on_ui_tabs():
  9. with gr.Blocks() as terminal:
  10. gr.Markdown(
  11. """
  12. ### Google Colab Manually Run Command
  13. ```py
  14. Example : pip, git, curl, wget, aria2c, or something else (no need to add "!,$,#"etc. in first code)
  15. ```
  16. """)
  17. with gr.Group():
  18. with gr.Box():
  19. command = gr.Textbox(label="Input Command Here", max_lines=1, placeholder="command")
  20. out_text = gr.Textbox(label="Output Results (no need to scroll down if the output code has appeared, if the output code appears, the code sign is complete)", placeholder="outputs")
  21. btn_run = gr.Button("run command")
  22. btn_run.click(fn=run, inputs=command, outputs=out_text)
  23. return (terminal, "Colab Terminal", "terminal"),
  24. script_callbacks.on_ui_tabs(on_ui_tabs)