Ei kuvausta
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

123456789101112131415161718192021222324252627
  1. import os
  2. import numpy as np
  3. import gradio as gr
  4. from modules import scripts, script_callbacks
  5. from subprocess import getoutput
  6. def run(command):
  7. out = getoutput(f"{command}")
  8. return out
  9. def on_ui_tabs():
  10. with gr.Blocks() as ccolab:
  11. gr.Markdown(
  12. """
  13. ### Google Colab Manually Run Command
  14. ```py
  15. Example : pip, git, curl, wget, aria2c, or something else (no need to add "!,$,#"etc. in first code)
  16. ```
  17. """)
  18. with gr.Group():
  19. with gr.Box():
  20. command = gr.Textbox(label="Input Command Here", max_lines=1, placeholder="command")
  21. 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")
  22. btn_run = gr.Button("run command")
  23. btn_run.click(fn=run, inputs=command, outputs=out_text)
  24. return (ccolab, "C Colab", "ccolab"),
  25. script_callbacks.on_ui_tabs(on_ui_tabs)