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()