Spaces:
Sleeping
Sleeping
Update launch.py
Browse files
launch.py
CHANGED
|
@@ -1,48 +1,39 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
if args.test_server:
|
| 42 |
-
configure_for_tests()
|
| 43 |
-
|
| 44 |
-
start()
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
if __name__ == "__main__":
|
| 48 |
-
main()
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import subprocess
|
| 3 |
+
import threading
|
| 4 |
+
import gradio as gr
|
| 5 |
+
|
| 6 |
+
# -------------------------------
|
| 7 |
+
# 1️⃣ Install dependencies
|
| 8 |
+
# -------------------------------
|
| 9 |
+
subprocess.run(["pip", "install", "-r", "requirements.txt"])
|
| 10 |
+
|
| 11 |
+
# -------------------------------
|
| 12 |
+
# 2️⃣ Function to start WebUI
|
| 13 |
+
# -------------------------------
|
| 14 |
+
def start_webui():
|
| 15 |
+
"""Launch Automatic1111 WebUI in background thread."""
|
| 16 |
+
# Set command-line args for WebUI
|
| 17 |
+
os.environ["COMMANDLINE_ARGS"] = "--listen --xformers --enable-insecure-extension-access --medvram"
|
| 18 |
+
|
| 19 |
+
# Launch WebUI
|
| 20 |
+
subprocess.run(["python", "launch.py"])
|
| 21 |
+
|
| 22 |
+
# Run WebUI in a separate thread so Gradio stays alive
|
| 23 |
+
threading.Thread(target=start_webui, daemon=True).start()
|
| 24 |
+
|
| 25 |
+
# -------------------------------
|
| 26 |
+
# 3️⃣ Minimal Gradio interface
|
| 27 |
+
# -------------------------------
|
| 28 |
+
def status():
|
| 29 |
+
return "✅ WebUI is running in the background."
|
| 30 |
+
|
| 31 |
+
# Gradio app — one output textbox to keep Space alive
|
| 32 |
+
with gr.Blocks() as demo:
|
| 33 |
+
gr.Markdown("### Automatic1111 WebUI Launcher")
|
| 34 |
+
gr.Button("Check status").click(status, outputs=[gr.Textbox()])
|
| 35 |
+
|
| 36 |
+
# -------------------------------
|
| 37 |
+
# 4️⃣ Launch Gradio (HF-friendly)
|
| 38 |
+
# -------------------------------
|
| 39 |
+
demo.launch(server_name="0.0.0.0", server_port=int(os.environ.get("PORT", 7860)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|