File size: 2,006 Bytes
80c4b54
0be5689
 
 
 
 
8c79566
80c4b54
0be5689
 
 
4af25d0
 
0be5689
 
80c4b54
0be5689
 
 
 
80c4b54
 
0be5689
80c4b54
 
 
0be5689
 
 
 
80c4b54
 
0be5689
80c4b54
0be5689
 
 
 
80c4b54
0be5689
 
80c4b54
 
22b0aff
 
 
 
 
 
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
42
43
44
45
46
47
48
49
import gradio as gr
import os
import sys
import subprocess

def setup_environment():
    subprocess.check_call([sys.executable, "-m", "pip", "install", "--upgrade", "pip"])
    subprocess.check_call([sys.executable, "-m", "pip", "install", "-r", "requirements.txt"])

def clone_repo():
    repo_url = "https://github.com/Cardano-max/Automated_DeFooocus.git"
    if not os.path.exists("Automated_DeFooocus"):
        subprocess.check_call(["git", "clone", repo_url])
    os.chdir("Automated_DeFooocus")

def run_fooocus(theme, preset, advanced_args):
    args = f"{advanced_args} --theme {theme}"
    if preset != "default":
        args += f" --preset {preset}"
    
    result = subprocess.run([sys.executable, "entry_with_update.py"] + args.split(), capture_output=True, text=True)
    return result.stdout + result.stderr

def create_interface():
    with gr.Blocks(title="fashionCORE Interface") as demo:
        gr.Markdown("# fashionCORE Interface")
        with gr.Row():
            theme = gr.Dropdown(choices=["dark", "light"], value="dark", label="Theme")
            preset = gr.Dropdown(choices=["default", "realistic", "anime", "lcm", "sai", "turbo", "lighting", "hypersd", "playground_v2.5", "dpo", "spo", "sd1.5"], value="default", label="Preset")
        advanced_args = gr.Textbox(value="--attention-split --always-high-vram --disable-offload-from-vram --all-in-fp16", label="Advanced Arguments")
        launch_button = gr.Button("Run fashionCORE")
        output = gr.Textbox(label="Output")
        
        launch_button.click(fn=run_fooocus, inputs=[theme, preset, advanced_args], outputs=output)
    
    return demo

if __name__ == "__main__":
    print("[fashionCORE] Preparing ...")
    setup_environment()
    clone_repo()
    print("[fashionCORE] Starting ...")
    demo = create_interface()
    
    # Use gr.mount_gradio_app for newer Gradio versions
    if hasattr(gr, 'mount_gradio_app'):
        gr.mount_gradio_app(app, demo.app, path="/")
    else:
        demo.launch()