pakdeveloper commited on
Commit
9f2ddb8
·
verified ·
1 Parent(s): af4d2c9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -2
app.py CHANGED
@@ -1,4 +1,7 @@
1
  import os
 
 
 
2
 
3
  # Change directory to Fooocus
4
  os.chdir("Fooocus-main")
@@ -6,5 +9,22 @@ os.chdir("Fooocus-main")
6
  # Install dependencies
7
  os.system("pip install pygit2==1.15.1")
8
 
9
- # Run Fooocus
10
- os.system("python entry_with_update.py --always-cpu")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import os
2
+ import subprocess
3
+ import time
4
+ import gradio as gr
5
 
6
  # Change directory to Fooocus
7
  os.chdir("Fooocus-main")
 
9
  # Install dependencies
10
  os.system("pip install pygit2==1.15.1")
11
 
12
+ # Function to start Fooocus server
13
+ def start_fooocus():
14
+ # Run Fooocus in the background
15
+ subprocess.Popen(["python", "entry_with_update.py", "--always-cpu", "--port", "7860"])
16
+ time.sleep(10) # Wait for the server to start
17
+ return "Fooocus AI is running! Visit the app below."
18
+
19
+ # Gradio interface to embed Fooocus
20
+ iface = gr.Interface(
21
+ fn=start_fooocus,
22
+ inputs=None,
23
+ outputs="text",
24
+ live=True,
25
+ title="Fooocus AI",
26
+ description="Fooocus AI is running directly in this Space."
27
+ )
28
+
29
+ # Launch Gradio app
30
+ iface.launch(server_name="0.0.0.0", server_port=7860)