Singularity666 commited on
Commit
80c4b54
Β·
verified Β·
1 Parent(s): d7692e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -28
app.py CHANGED
@@ -1,58 +1,44 @@
 
1
  import os
2
  import sys
3
  import subprocess
4
- import importlib
5
 
6
  def setup_environment():
7
  subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "pip"])
8
- subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "gradio==4.29.0", "pygit2==1.12.2"])
9
 
10
  def clone_repo():
11
  repo_url = "https://github.com/Cardano-max/Automated_DeFooocus.git"
12
  if not os.path.exists("Automated_DeFooocus"):
13
  subprocess.check_call(["git", "clone", repo_url])
14
  os.chdir("Automated_DeFooocus")
15
-
16
- # Install requirements, ignoring torchsde
17
- with open("requirements_versions.txt", "r") as f:
18
- requirements = f.read().splitlines()
19
-
20
- filtered_requirements = [req for req in requirements if not req.startswith("torchsde")]
21
-
22
- with open("temp_requirements.txt", "w") as f:
23
- f.write("\n".join(filtered_requirements))
24
-
25
- subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "temp_requirements.txt", "--ignore-installed"])
26
-
27
- # Install torchsde separately
28
- subprocess.check_call([sys.executable, "-m", "pip", "install", "torchsde==0.2.6", "--no-deps"])
29
 
30
- def run_fooocus(theme="dark", preset="default", advanced_args="--attention-split --always-high-vram --disable-offload-from-vram --all-in-fp16"):
31
  args = f"{advanced_args} --theme {theme}"
32
  if preset != "default":
33
  args += f" --preset {preset}"
34
 
35
- subprocess.Popen([sys.executable, "entry_with_update.py"] + args.split())
 
36
 
37
- def launch_interface():
38
- import gradio as gr
39
-
40
- with gr.Blocks() as demo:
41
- gr.Markdown("# DeFooocus Interface")
42
  with gr.Row():
43
  theme = gr.Dropdown(choices=["dark", "light"], value="dark", label="Theme")
44
  preset = gr.Dropdown(choices=["default", "realistic", "anime", "lcm", "sai", "turbo", "lighting", "hypersd", "playground_v2.5", "dpo", "spo", "sd1.5"], value="default", label="Preset")
45
  advanced_args = gr.Textbox(value="--attention-split --always-high-vram --disable-offload-from-vram --all-in-fp16", label="Advanced Arguments")
46
- launch_button = gr.Button("Launch DeFooocus")
 
47
 
48
- launch_button.click(fn=run_fooocus, inputs=[theme, preset, advanced_args])
49
 
50
  return demo
51
 
52
  if __name__ == "__main__":
53
- print("[DeFooocus] Preparing ...")
54
  setup_environment()
55
  clone_repo()
56
- print("[DeFooocus] Starting ...")
57
- demo = launch_interface()
58
  demo.launch()
 
1
+ import gradio as gr
2
  import os
3
  import sys
4
  import subprocess
 
5
 
6
  def setup_environment():
7
  subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "pip"])
8
+ subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])
9
 
10
  def clone_repo():
11
  repo_url = "https://github.com/Cardano-max/Automated_DeFooocus.git"
12
  if not os.path.exists("Automated_DeFooocus"):
13
  subprocess.check_call(["git", "clone", repo_url])
14
  os.chdir("Automated_DeFooocus")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ def run_fooocus(theme, preset, advanced_args):
17
  args = f"{advanced_args} --theme {theme}"
18
  if preset != "default":
19
  args += f" --preset {preset}"
20
 
21
+ result = subprocess.run([sys.executable, "entry_with_update.py"] + args.split(), capture_output=True, text=True)
22
+ return result.stdout + result.stderr
23
 
24
+ def create_interface():
25
+ with gr.Blocks(title="fashionCORE Interface") as demo:
26
+ gr.Markdown("# fashionCORE Interface")
 
 
27
  with gr.Row():
28
  theme = gr.Dropdown(choices=["dark", "light"], value="dark", label="Theme")
29
  preset = gr.Dropdown(choices=["default", "realistic", "anime", "lcm", "sai", "turbo", "lighting", "hypersd", "playground_v2.5", "dpo", "spo", "sd1.5"], value="default", label="Preset")
30
  advanced_args = gr.Textbox(value="--attention-split --always-high-vram --disable-offload-from-vram --all-in-fp16", label="Advanced Arguments")
31
+ launch_button = gr.Button("Run fashionCORE")
32
+ output = gr.Textbox(label="Output")
33
 
34
+ launch_button.click(fn=run_fooocus, inputs=[theme, preset, advanced_args], outputs=output)
35
 
36
  return demo
37
 
38
  if __name__ == "__main__":
39
+ print("[fashionCORE] Preparing ...")
40
  setup_environment()
41
  clone_repo()
42
+ print("[fashionCORE] Starting ...")
43
+ demo = create_interface()
44
  demo.launch()