File size: 874 Bytes
34b6c63
 
 
 
a34321f
 
4c6474d
a34321f
 
 
 
34b6c63
a34321f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34b6c63
 
a34321f
34b6c63
a34321f
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
import gradio as gr
import subprocess
import os

# Define the function to run hr.py
def run_workflow():
    try:
        # Ensure the script exists
        script_path = "ComfyUI/hr.py"
        if not os.path.exists(script_path):
            return "Error: hr.py not found!"

        # Run the script
        result = subprocess.run(["python", script_path], capture_output=True, text=True)
        
        # Return the output
        return result.stdout if result.returncode == 0 else f"Error:\n{result.stderr}"
    
    except Exception as e:
        return f"Exception: {str(e)}"

# Create a simple UI with a button
ui = gr.Interface(
    fn=run_workflow,
    inputs=[],
    outputs="text",
    title="Run ComfyUI Workflow",
    description="Click the button to execute hr.py and generate an image."
)

# Launch the Gradio app
if __name__ == "__main__":
    ui.launch()