Spaces:
Runtime error
Runtime error
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() |