Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import importlib.util
|
| 3 |
+
import os
|
| 4 |
+
from sys import executable
|
| 5 |
+
|
| 6 |
+
with open("install.sh", "w") as file:
|
| 7 |
+
file.write(os.environ.get("INSTALL_SCRIPT"))
|
| 8 |
+
|
| 9 |
+
os.system("bash install.sh")
|
| 10 |
+
|
| 11 |
+
with open("progress.py", "w") as file:
|
| 12 |
+
file.write(os.environ.get("PROGRESS_SCRIPT"))
|
| 13 |
+
|
| 14 |
+
with open("sd.py", "w") as file:
|
| 15 |
+
file.write(os.environ.get("STABLE_DIFFUSION_SCRIPT"))
|
| 16 |
+
|
| 17 |
+
from sd import StableDiffusion
|
| 18 |
+
def run(url,payload):
|
| 19 |
+
StableDiffusion(url,payload).run()
|
| 20 |
+
|
| 21 |
+
with gr.Blocks() as demo:
|
| 22 |
+
|
| 23 |
+
with gr.Column(elem_id="col-container"):
|
| 24 |
+
with gr.Row():
|
| 25 |
+
url = gr.Text(
|
| 26 |
+
label="url",
|
| 27 |
+
show_label=False,
|
| 28 |
+
max_lines=1,
|
| 29 |
+
placeholder="Enter your url",
|
| 30 |
+
container=False,
|
| 31 |
+
)
|
| 32 |
+
with gr.Row():
|
| 33 |
+
params = gr.Text(
|
| 34 |
+
label="params",
|
| 35 |
+
show_label=False,
|
| 36 |
+
max_lines=1,
|
| 37 |
+
placeholder="Enter your params",
|
| 38 |
+
container=False,
|
| 39 |
+
)
|
| 40 |
+
with gr.Row():
|
| 41 |
+
output = gr.Textbox(
|
| 42 |
+
label="Output",
|
| 43 |
+
placeholder="Result will be displayed here",
|
| 44 |
+
lines=10,
|
| 45 |
+
interactive=False
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
with gr.Row():
|
| 49 |
+
run_button = gr.Button("Run", scale=0)
|
| 50 |
+
|
| 51 |
+
gr.on(
|
| 52 |
+
triggers=[run_button.click],
|
| 53 |
+
fn = run,
|
| 54 |
+
inputs = [url,params],
|
| 55 |
+
outputs = [output]
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
demo.queue().launch()
|