Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
| 1 |
import os
|
| 2 |
-
os.environ["MPLCONFIGDIR"] = "/tmp"
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
from pathlib import Path
|
| 5 |
import subprocess, json, tempfile, sys
|
| 6 |
|
| 7 |
COMFY_DIR = Path("ComfyUI")
|
| 8 |
-
WORKFLOW_JSON = Path("workflow_api.json")
|
| 9 |
|
| 10 |
def patch_workflow(wf, pic_path, face_path, prompt):
|
| 11 |
for node in wf.values():
|
|
@@ -31,17 +32,21 @@ def run(picture, face, positive):
|
|
| 31 |
with open(tmp_wf, "w") as f:
|
| 32 |
json.dump(wf, f)
|
| 33 |
|
| 34 |
-
subprocess.run([
|
| 35 |
-
sys.executable, "
|
| 36 |
"--disable-auto-launch",
|
| 37 |
"--input", str(tmpdir),
|
| 38 |
"--output", str(tmpdir),
|
| 39 |
"--workflow", str(tmp_wf)
|
| 40 |
-
], cwd=COMFY_DIR,
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
out = list(tmpdir.glob("*.png"))
|
| 43 |
if not out:
|
| 44 |
-
raise RuntimeError("No output image")
|
| 45 |
return out[0]
|
| 46 |
|
| 47 |
demo = gr.Interface(
|
|
@@ -56,4 +61,5 @@ demo = gr.Interface(
|
|
| 56 |
title="ComfyUI InstantID Face Swap",
|
| 57 |
allow_flagging="never"
|
| 58 |
)
|
|
|
|
| 59 |
demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=True)
|
|
|
|
| 1 |
import os
|
| 2 |
+
os.environ["MPLCONFIGDIR"] = "/tmp" # matplotlib sans ~/.config
|
| 3 |
+
|
| 4 |
import gradio as gr
|
| 5 |
from pathlib import Path
|
| 6 |
import subprocess, json, tempfile, sys
|
| 7 |
|
| 8 |
COMFY_DIR = Path("ComfyUI")
|
| 9 |
+
WORKFLOW_JSON = Path("workflow_api.json")
|
| 10 |
|
| 11 |
def patch_workflow(wf, pic_path, face_path, prompt):
|
| 12 |
for node in wf.values():
|
|
|
|
| 32 |
with open(tmp_wf, "w") as f:
|
| 33 |
json.dump(wf, f)
|
| 34 |
|
| 35 |
+
result = subprocess.run([
|
| 36 |
+
sys.executable, "main.py",
|
| 37 |
"--disable-auto-launch",
|
| 38 |
"--input", str(tmpdir),
|
| 39 |
"--output", str(tmpdir),
|
| 40 |
"--workflow", str(tmp_wf)
|
| 41 |
+
], cwd=COMFY_DIR, capture_output=True, text=True)
|
| 42 |
+
|
| 43 |
+
if result.returncode != 0:
|
| 44 |
+
print("ComfyUI error:", result.stderr)
|
| 45 |
+
raise RuntimeError("ComfyUI failed to run")
|
| 46 |
|
| 47 |
out = list(tmpdir.glob("*.png"))
|
| 48 |
if not out:
|
| 49 |
+
raise RuntimeError("No output image generated.")
|
| 50 |
return out[0]
|
| 51 |
|
| 52 |
demo = gr.Interface(
|
|
|
|
| 61 |
title="ComfyUI InstantID Face Swap",
|
| 62 |
allow_flagging="never"
|
| 63 |
)
|
| 64 |
+
|
| 65 |
demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=True)
|