Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import sys
|
3 |
+
import subprocess
|
4 |
+
import gradio as gr
|
5 |
+
|
6 |
+
def setup_environment():
|
7 |
+
# Install required packages
|
8 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "pygit2==1.12.2"])
|
9 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "-r", "requirements_versions.txt"])
|
10 |
+
|
11 |
+
def clone_repo():
|
12 |
+
# Clone the repository
|
13 |
+
repo_url = "https://github.com/Cardano-max/Automated_DeFooocus.git"
|
14 |
+
subprocess.check_call(["git", "clone", repo_url])
|
15 |
+
os.chdir("Automated_DeFooocus")
|
16 |
+
|
17 |
+
def run_fooocus(theme="dark", preset="default", advanced_args="--attention-split --always-high-vram --disable-offload-from-vram --all-in-fp16"):
|
18 |
+
args = f"{advanced_args} --theme {theme}"
|
19 |
+
if preset != "default":
|
20 |
+
args += f" --preset {preset}"
|
21 |
+
|
22 |
+
# Run the entry_with_update.py script
|
23 |
+
subprocess.Popen([sys.executable, "entry_with_update.py"] + args.split())
|
24 |
+
|
25 |
+
def launch_interface():
|
26 |
+
with gr.Blocks() as demo:
|
27 |
+
gr.Markdown("# DeFooocus Interface")
|
28 |
+
with gr.Row():
|
29 |
+
theme = gr.Dropdown(choices=["dark", "light"], value="dark", label="Theme")
|
30 |
+
preset = gr.Dropdown(choices=["default", "realistic", "anime", "lcm", "sai", "turbo", "lighting", "hypersd", "playground_v2.5", "dpo", "spo", "sd1.5"], value="default", label="Preset")
|
31 |
+
advanced_args = gr.Textbox(value="--attention-split --always-high-vram --disable-offload-from-vram --all-in-fp16", label="Advanced Arguments")
|
32 |
+
launch_button = gr.Button("Launch DeFooocus")
|
33 |
+
|
34 |
+
launch_button.click(fn=run_fooocus, inputs=[theme, preset, advanced_args])
|
35 |
+
|
36 |
+
return demo
|
37 |
+
|
38 |
+
if __name__ == "__main__":
|
39 |
+
print("[DeFooocus] Preparing ...")
|
40 |
+
setup_environment()
|
41 |
+
clone_repo()
|
42 |
+
print("[DeFooocus] Starting ...")
|
43 |
+
demo = launch_interface()
|
44 |
+
demo.launch()
|