Browse Source

Create colab.py

Iyashinouta 1 year ago
parent
commit
6ab11c5db2
No account linked to committer's email address
1 changed files with 27 additions and 0 deletions
  1. 27
    0
      scripts/colab.py

+ 27
- 0
scripts/colab.py View File

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

Loading…
Cancel
Save